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

Unable to use Jackson AfterBurner or BlackBird modules #11253

Open
loicmathieu opened this issue Oct 11, 2024 · 4 comments
Open

Unable to use Jackson AfterBurner or BlackBird modules #11253

loicmathieu opened this issue Oct 11, 2024 · 4 comments

Comments

@loicmathieu
Copy link

Expected Behavior

We can use either Jackson AfterBurner or BalckBird modules.

Actual Behaviour

Adding either AfterBurner or BlackBird module in the classpath will make our Micronaut application crashing with

Caused by: java.lang.UnsupportedOperationException
	at java.base/java.util.ImmutableCollections.uoe(ImmutableCollections.java:142)
	at java.base/java.util.ImmutableCollections$ListItr.set(ImmutableCollections.java:426)
	at com.fasterxml.jackson.module.afterburner.ser.SerializerModifier.findProperties(SerializerModifier.java:143)
	at com.fasterxml.jackson.module.afterburner.ser.SerializerModifier.changeProperties(SerializerModifier.java:52)
	at com.fasterxml.jackson.databind.ser.BeanSerializerFactory.constructBeanOrAddOnSerializer(BeanSerializerFactory.java:415)
	at com.fasterxml.jackson.databind.ser.BeanSerializerFactory.findBeanOrAddOnSerializer(BeanSerializerFactory.java:295)
	at com.fasterxml.jackson.databind.ser.BeanSerializerFactory._createSerializer2(BeanSerializerFactory.java:240)
	at com.fasterxml.jackson.databind.ser.BeanSerializerFactory.createSerializer(BeanSerializerFactory.java:174)
	at com.fasterxml.jackson.databind.SerializerProvider._createUntypedSerializer(SerializerProvider.java:1523)
	at com.fasterxml.jackson.databind.SerializerProvider._createAndCacheUntypedSerializer(SerializerProvider.java:1491)
	at com.fasterxml.jackson.databind.SerializerProvider.findValueSerializer(SerializerProvider.java:619)
	at com.fasterxml.jackson.databind.SerializerProvider.findTypedValueSerializer(SerializerProvider.java:901)
	at com.fasterxml.jackson.databind.ObjectWriter$Prefetch.forRootType(ObjectWriter.java:1547)
	at com.fasterxml.jackson.databind.ObjectWriter.<init>(ObjectWriter.java:116)
	at com.fasterxml.jackson.databind.ObjectMapper._newWriter(ObjectMapper.java:840)
	at com.fasterxml.jackson.databind.ObjectMapper.writerFor(ObjectMapper.java:4187)
	at io.micronaut.jackson.databind.JacksonDatabindMapper.createWriter(JacksonDatabindMapper.java:147)
	at io.micronaut.jackson.databind.JacksonDatabindMapper.<init>(JacksonDatabindMapper.java:101)
	at io.micronaut.jackson.databind.JacksonDatabindMapper.createSpecific(JacksonDatabindMapper.java:118)
	at io.micronaut.json.body.JsonMessageHandler.createSpecific(JsonMessageHandler.java:97)
	at io.micronaut.http.netty.body.NettyJsonHandler.createSpecific(NettyJsonHandler.java:150)
	at io.micronaut.web.router.DefaultRouteInfo.lambda$new$0(DefaultRouteInfo.java:97)
	at java.base/java.util.Optional.map(Optional.java:260)
	at io.micronaut.web.router.DefaultRouteInfo.<init>(DefaultRouteInfo.java:97)
	at io.micronaut.web.router.DefaultMethodBasedRouteInfo.<init>(DefaultMethodBasedRouteInfo.java:75)
	at io.micronaut.web.router.DefaultRequestMatcher.<init>(DefaultRequestMatcher.java:51)
	at io.micronaut.web.router.DefaultUrlRouteInfo.<init>(DefaultUrlRouteInfo.java:74)
	at io.micronaut.web.router.DefaultRouteBuilder$DefaultUriRoute.toRouteInfo(DefaultRouteBuilder.java:872)
	at io.micronaut.web.router.DefaultRouter.<init>(DefaultRouter.java:112)
	at io.micronaut.web.router.$DefaultRouter$Definition.instantiate(Unknown Source)
	at io.micronaut.context.DefaultBeanContext.resolveByBeanFactory(DefaultBeanContext.java:2330)

Steps To Reproduce

No response

Environment Information

  • OS: Ubutu 24.04
  • Java 21

Example Application

No response

Version

4.6.3

@yawkat
Copy link
Member

yawkat commented Oct 17, 2024

You might have to disable the bean introspection module

@graemerocher
Copy link
Contributor

if you are using the bean introspection module then afterburner and/or blackbird will provide zero benefit since the bean introspection module is already eliminating reflection. All that will be achieved in moving the byte code generation from compile time to runtime.

That said as per @yawkat if you want to use these modules for some unknown reason then you have to disable the bean introspection module

@loicmathieu
Copy link
Author

@yawkat the same issue occurs if I disable the bean introspection module.

@graemerocher we have our own Jackson mapper that we use in a bunch of places (JSONB support, Kafka, ION support, ...) I'm not sure we can use the bean instrospection module for that with the same performance advantage. Would it mandate to have all classes annotation with @Introspected to generate serializer and deserializer?

@graemerocher
Copy link
Contributor

then it seems to be a Jackson bug

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

No branches or pull requests

3 participants