- what is the exact problem ? (failing test?)
- what is the proposed solution ?
Representer.defaultFlowStyle is always overridden by default value
Currently, if default flow style is configured on Representer
level, it's always overridden in Yaml
constructor:
Representer representer = new Representer();
representer.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
Yaml yaml = new Yaml(representer);
Yaml(representer)
calls this(new Constructor(), representer)
-> this(constructor, representer, new DumperOptions())
and eventually this(constructor, representer, dumperOptions, new LoaderOptions(), new Resolver())
In the body of the last constructor some Presenter
properties are overridden by the default properties of DumperOptions
, which is not expected behaviour, from my perspective:
representer.setDefaultFlowStyle(dumperOptions.getDefaultFlowStyle());
representer.setDefaultScalarStyle(dumperOptions.getDefaultScalarStyle());
representer.getPropertyUtils()
.setAllowReadOnlyProperties(dumperOptions.isAllowReadOnlyProperties());
representer.setTimeZone(dumperOptions.getTimeZone());
Comments (4)
-
-
reporter 1) I expect that with this configuration default flow style will be
BLOCK
, however it'sFLOW
:Representer representer = new Representer(); representer.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK); Yaml yaml = new Yaml(representer);
It's not obvious and I spent a while to figure out why it didn't work
2) Simple solution is initialize
DumperOptions
by the configuration fromRepresenter
. Replacenew DumperOptions()
bycreateDumperOptions(Representer)
-
Sorry, but after your explanation it does not become clear.
Can you please create a pull request or attach here a patch with the expected changes (and tests to see the usage) ?
-
- changed status to resolved
It will be delivered in version 1.19
- Log in to comment