Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.without(YAMLGenerator.Feature.WRITE_DOC_START_MARKER) seems to be ignored #215

Open
jdimeo opened this issue Aug 13, 2020 · 5 comments
Open
Labels
has-failing-test Indicates that there exists a test case (under `failing/`) to reproduce the issue yaml Issue related to YAML format backend

Comments

@jdimeo
Copy link

jdimeo commented Aug 13, 2020

I feel like I may be using the APIs incorrectly, but I can't figure out what I'm doing wrong. The following code:

new YAMLMapper()
	.writer()
	.without(YAMLGenerator.Feature.WRITE_DOC_START_MARKER)
	.writeValueAsString(o)

still puts the --- at the beginning of the string.

I'm using version 2.11.2

P.S. YAML support is a game. changer. Huge fan and huge thanks!

@cowtowncoder
Copy link
Member

Hmmh. Yes, that looks like it ought to prevent start marker from being written. Thank you for reporting this, I will need to have a look!

One thing that might help is if you could try a work-around of explicitly creating YAMLFactory, configuring setting, constructing YAMLMapper with it -- I suspect this might be related to writer not applying settings correctly.

@cowtowncoder
Copy link
Member

Ok, I can reproduce this issue. I also realized that it may be tricky to fix with 2.x, the problem being that the document start marker is being written during construction of YAMLGenerator whereas ObjectWriter passes its settings right after construction but (supposedly) before actual output. 3.x (master) solves this initialization problem but that required bigger refactoring.

I'll have to think of how to tackle this.

You may be able to work around this issue by pre-configuring YAMLFactory however:

YAMLMapper mapper = new YAMLMapper(YAMLFactory.builder()
    .disable(YAMLGenerator.Feature.WRITE_DOC_START_MARKER)).build());

in which case setting is used as expected.

@jdimeo
Copy link
Author

jdimeo commented Aug 14, 2020

Thank you so much for your fast response! I can definitely wait for 3.x and/or use YAMLFactory in the meantime.

@cowtowncoder
Copy link
Member

Ok good. I hope I'll address this for 2.12(.0).

cowtowncoder added a commit that referenced this issue Aug 14, 2020
@cowtowncoder cowtowncoder added 2.12 yaml Issue related to YAML format backend and removed 2.11 labels Aug 19, 2020
@cowtowncoder cowtowncoder added 2.13 has-failing-test Indicates that there exists a test case (under `failing/`) to reproduce the issue and removed 2.12 labels Nov 22, 2020
@cowtowncoder cowtowncoder removed the 2.13 label Apr 22, 2023
@cowtowncoder
Copy link
Member

Unfortunately it seems unlikely this can be fixed for 2.x.

Work-around mentioned above does, however, work: that is, configuring YAMLFactory directly works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
has-failing-test Indicates that there exists a test case (under `failing/`) to reproduce the issue yaml Issue related to YAML format backend
Projects
None yet
Development

No branches or pull requests

2 participants