question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

JDK Serializing and using Deserialized `ObjectMapper` loses linkage back from `JsonParser.getCodec()`

See original GitHub issue

I am attaching a test project which is linked against 2.9.5 version. The test errors out. But if I change the pom to link against 2.2.0, it passes. It seems that this is broken since 2.2.1.

java.lang.IllegalStateException: No ObjectCodec defined for parser, needed for deserialization
	at com.fasterxml.jackson.core.JsonParser._codec(JsonParser.java:1788)
	at com.fasterxml.jackson.core.JsonParser.readValueAsTree(JsonParser.java:1782)
	at com.celeral.serializedobjectmapper.NewClassTest$JSONWrapperDeserializer.deserialize(NewClassTest.java:87)
	at com.celeral.serializedobjectmapper.NewClassTest$JSONWrapperDeserializer.deserialize(NewClassTest.java:72)
	at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4001)
	at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2992)
	at com.celeral.serializedobjectmapper.NewClassTest.testSerializationOfCodec(NewClassTest.java:164)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
	at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
	at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
	at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
	at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
	at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
	at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)


Results :

Tests in error:
  testSerializationOfCodec(com.celeral.serializedobjectmapper.NewClassTest): No ObjectCodec defined for parser, needed for deserialization

Tests run: 2, Failures: 0, Errors: 1, Skipped: 0

SerializedObjectMapper.zip

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
cowtowncodercommented, May 16, 2018

Also: I think what you found is a bug, hope to find time to fix it if possible at some point.

0reactions
cowtowncodercommented, Nov 12, 2018

@mserdur A reproduction would be needed to show how things do not work.

And if so, please file a new issue: release notes unfortunately do not work well with re-opened issues.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Java JSON deserialization problems with the Jackson ... - Snyk
Learn how Jackson ObjectMapper deserialization vulnerabilities work and how to make sure you are not affected by them.
Read more >
jackson deserialize object with list of spring's interface
the abstract GrantedAuthority is only filled with SimpleGrantedAuthority . so i tried: objectMapper.registerSubtypes(SimpleGrantedAuthority.class);. and still ...
Read more >
Jackson - Quick Guide - Tutorialspoint
Jackson is a simple java based library to serialize java objects to JSON and vice versa. ... Use readValue() method to get the...
Read more >
cannot deserialize value of type `java.lang.long` from string
JsonNode.toString() returns json representation of the node, like this you revert the node back to json to save in list. Then register the...
Read more >
SUSE alert SUSE-SU-2022:1678-1 (jackson-databind ...
readTree()' + IllegalArgumentException: Conflicting setter definitions for property with more than 2 setters + Serializing java.lang.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found