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

PropertyFiltering doesn't work when using Jackson 2.10 #19

Closed
kvirkki opened this issue Jan 27, 2020 · 6 comments · Fixed by #20
Closed

PropertyFiltering doesn't work when using Jackson 2.10 #19

kvirkki opened this issue Jan 27, 2020 · 6 comments · Fixed by #20

Comments

@kvirkki
Copy link

kvirkki commented Jan 27, 2020

Works still with 0.8.3 version, but the performance improvements in 0.8.4 seem to have broken it.

I think that PropertyFilteringJsonGenerator needs some fix as it's extending JsonGeneratorDelegate and that one has changed in Jackson 2.10.

Here's the stack trace I'm seeing thrown:

com.fasterxml.jackson.core.JsonGenerationException: Can not start an array, expecting field name (context: Object)
	at com.fasterxml.jackson.core.JsonGenerator._reportError(JsonGenerator.java:2080)
	at com.fasterxml.jackson.core.json.JsonGeneratorImpl._reportCantWriteValueExpectName(JsonGeneratorImpl.java:248)
	at com.fasterxml.jackson.core.json.UTF8JsonGenerator._verifyValueWrite(UTF8JsonGenerator.java:1132)
	at com.fasterxml.jackson.core.json.UTF8JsonGenerator.writeStartArray(UTF8JsonGenerator.java:331)
	at com.fasterxml.jackson.core.JsonGenerator.writeStartArray(JsonGenerator.java:770)
	at com.fasterxml.jackson.core.util.JsonGeneratorDelegate.writeStartArray(JsonGeneratorDelegate.java:206)
	at com.fasterxml.jackson.databind.ser.impl.IndexedListSerializer.serialize(IndexedListSerializer.java:78)
	at com.fasterxml.jackson.databind.ser.impl.IndexedListSerializer.serialize(IndexedListSerializer.java:18)
	at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:727)
	at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:722)
	at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:166)
	at com.fasterxml.jackson.databind.ser.impl.IndexedListSerializer.serializeContents(IndexedListSerializer.java:119)
	at com.fasterxml.jackson.databind.ser.impl.IndexedListSerializer.serialize(IndexedListSerializer.java:79)
	at com.fasterxml.jackson.databind.ser.impl.IndexedListSerializer.serialize(IndexedListSerializer.java:18)
	at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider._serialize(DefaultSerializerProvider.java:480)
	at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:319)
	at com.fasterxml.jackson.databind.ObjectWriter$Prefetch.serialize(ObjectWriter.java:1433)
	at com.fasterxml.jackson.databind.ObjectWriter.writeValue(ObjectWriter.java:921)
	at com.hubspot.jackson.jaxrs.PropertyFilteringMessageBodyWriter.writeValue(PropertyFilteringMessageBodyWriter.java:128)
	at com.hubspot.jackson.jaxrs.PropertyFilteringMessageBodyWriter.writeTo(PropertyFilteringMessageBodyWriter.java:72)
	at org.apache.cxf.jaxrs.utils.JAXRSUtils.writeMessageBody(JAXRSUtils.java:1472)
@jhaber
Copy link
Member

jhaber commented Jan 27, 2020

Sorry about that, I can take a look shortly. I also updated the Travis config so that we test against Jackson 2.9.10 and 2.10 (in addition to 2.9.9):

env:
- # use the Jackson versions from the POM
- MAVEN_OPTS="-Ddep.jackson.version=2.9.10 -Ddep.jackson-databind.version=2.9.10.2"
- MAVEN_OPTS="-Ddep.jackson.version=2.10.2 -Ddep.jackson-databind.version=2.10.2"

@jhaber
Copy link
Member

jhaber commented Jan 27, 2020

Nevermind, those env vars worked locally but don't seem to work in Travis 🤔

@jhaber
Copy link
Member

jhaber commented Jan 27, 2020

Travis setup seems to be working now with:

env:
- # use Jackson versions from POM
- JACKSON_VERSIONS="-Ddep.jackson.version=2.9.10 -Ddep.jackson-databind.version=2.9.10.2"
- JACKSON_VERSIONS="-Ddep.jackson.version=2.10.2 -Ddep.jackson-databind.version=2.10.2"
script: mvn -B -q verify $JACKSON_VERSIONS

@jhaber
Copy link
Member

jhaber commented Jan 27, 2020

Should be fixed by #20, I can cut a new release shortly. This should also be less fragile once FasterXML/jackson-core#573 lands because this code will live in jackson-core and stay in sync

@kvirkki
Copy link
Author

kvirkki commented Jan 27, 2020

Awesome! :) Thank you so much!

@jhaber
Copy link
Member

jhaber commented Jan 27, 2020

No problem, sorry for the headache. 0.8.5 is released and should show up in Maven Central shortly. I also added a warning to the 0.8.4 release notes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants