Skip to content
New issue

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

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

Already on GitHub? # to your account

Issues using jackson-databind 2.17.1 with Reactor (wrt DeserializerCache and ReentrantLock) #4561

Closed
1 task done
wdallastella opened this issue Jun 4, 2024 · 4 comments
Closed
1 task done
Labels
2.17 Issues planned at earliest for 2.17
Milestone

Comments

@wdallastella
Copy link

wdallastella commented Jun 4, 2024

Search before asking

  • I searched in the issues and found nothing similar.

Describe the bug

Related to: #4430 (comment)

After upgrading to Spring Boot 3 (jackson 2.17.1) we start having the bellow issue.

I'm using webflux with reactive-feign. Downgrading jackson to 2.17.0 fix the issue.

java.lang.IllegalMonitorStateException: null
	at java.base/java.util.concurrent.locks.ReentrantLock$Sync.tryRelease(ReentrantLock.java:175)
	Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException: 
Assembly trace from producer [reactor.core.publisher.MonoLiftFuseable] :
	reactor.core.publisher.Mono.flatMap(Mono.java:3171)
	reactivefeign.publisher.MonoPublisherHttpClient.executeRequest(MonoPublisherHttpClient.java:25)
Error has been observed at the following site(s):
	*____Mono.flatMap ⇢ at reactivefeign.publisher.MonoPublisherHttpClient.executeRequest(MonoPublisherHttpClient.java:25)
	|_ Mono.transform ⇢ at org.springframework.cloud.circuitbreaker.resilience4j.ReactiveResilience4JCircuitBreaker.run(ReactiveResilience4JCircuitBreaker.java:90)
	|_   Mono.timeout ⇢ at org.springframework.cloud.circuitbreaker.resilience4j.ReactiveResilience4JCircuitBreaker.run(ReactiveResilience4JCircuitBreaker.java:93)
	|_ Mono.doOnError ⇢ at org.springframework.cloud.circuitbreaker.resilience4j.ReactiveResilience4JCircuitBreaker.run(ReactiveResilience4JCircuitBreaker.java:97)
Original Stack Trace:
		at java.base/java.util.concurrent.locks.ReentrantLock$Sync.tryRelease(ReentrantLock.java:175)
		at java.base/java.util.concurrent.locks.AbstractQueuedSynchronizer.release(AbstractQueuedSynchronizer.java:1007)
		at java.base/java.util.concurrent.locks.ReentrantLock.unlock(ReentrantLock.java:494)
		at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCacheValueDeserializer(DeserializerCache.java:282)
		at com.fasterxml.jackson.databind.deser.DeserializerCache.hasValueDeserializerFor(DeserializerCache.java:219)
		at com.fasterxml.jackson.databind.DeserializationContext.hasValueDeserializerFor(DeserializationContext.java:614)
		at com.fasterxml.jackson.databind.ObjectMapper.canDeserialize(ObjectMapper.java:3673)
		at org.springframework.http.codec.json.AbstractJackson2Decoder.canDecode(AbstractJackson2Decoder.java:112)
		at org.springframework.http.codec.DecoderHttpMessageReader.canRead(DecoderHttpMessageReader.java:97)
		at org.springframework.web.reactive.function.BodyExtractors.readWithMessageReaders(BodyExtractors.java:198)
		at org.springframework.web.reactive.function.BodyExtractors.lambda$toMono$2(BodyExtractors.java:84)
		at org.springframework.web.reactive.function.client.DefaultClientResponse.body(DefaultClientResponse.java:135)
		at org.springframework.web.reactive.function.client.DefaultClientResponse.bodyToMono(DefaultClientResponse.java:155)
		at reactivefeign.webclient.client.WebReactiveHttpResponse.body(WebReactiveHttpResponse.java:53)

Tested as well with 2.18.0, in this case we have blockhound claiming:

reactor.blockhound.BlockingOperationError: Blocking call! jdk.internal.misc.Unsafe#park
	at java.base/jdk.internal.misc.Unsafe.park(Unsafe.java)
	Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException: 
Assembly trace from producer [reactor.core.publisher.MonoLiftFuseable] :
	reactor.core.publisher.Mono.flatMap(Mono.java:3171)
	reactivefeign.publisher.MonoPublisherHttpClient.executeRequest(MonoPublisherHttpClient.java:25)

If I ignore (like bellow), it works, but we might have issues if there is really a blocking call when using reactor.

class TestBlockHoundIntegration : BlockHoundIntegration {
    override fun applyTo(builder: BlockHound.Builder) {
        builder.allowBlockingCallsInside("com.fasterxml.jackson.databind.deser.DeserializerCache", "hasValueDeserializerFor")
    }
}

Version Information

2.17.1

Reproduction

Trying to create a sample project ...

Expected behavior

No issues while parsing messages using jackson-databind and reactor.

Additional context

#4430 (comment)

@wdallastella wdallastella added the to-evaluate Issue that has been received but not yet evaluated label Jun 4, 2024
cowtowncoder added a commit that referenced this issue Jun 5, 2024
@cowtowncoder
Copy link
Member

Will resolve by reverting #4430 in 2.17 (for 2.17.2) -- to go back to synchronized, instead of ReentrantLock -- will separately tackle use of ReentrantLock in 2.18 (for 2.18.0).

@cowtowncoder cowtowncoder added this to the 2.17.2 milestone Jun 5, 2024
@cowtowncoder cowtowncoder added 2.17 Issues planned at earliest for 2.17 and removed to-evaluate Issue that has been received but not yet evaluated labels Jun 5, 2024
cowtowncoder added a commit that referenced this issue Jun 6, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
This reverts commit b89886a.
@cowtowncoder
Copy link
Member

Ok, one more change of plans: will re-do ReentrantLock with better scoping (right before try-catch block) based on findings that explain the original problem, as discussed on #4430.

cowtowncoder added a commit that referenced this issue Jun 6, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
…or 2.17.2 (#4568)
@cowtowncoder cowtowncoder changed the title Issues using jackson-databind 2.17.1 with Reactor Issues using jackson-databind 2.17.1 with Reactor (wrt DeserializerCache and ReentrantLock) Jun 6, 2024
@cowtowncoder
Copy link
Member

Properly fixed, we believe, will be in 2.17.2 release (https://github.com/FasterXML/jackson/wiki/Jackson-Release-2.17.2) which will probably take a while.

@iProdigy
Copy link
Contributor

iProdigy commented Jun 6, 2024

Given 2.17.2 is keeping ReentrantLock in DeserializerCache (avoids pinning on virtual threads):

BlockHound users should add this class to avoid BlockingOperationError

public class JacksonBlockHoundIntegration implements BlockHoundIntegration {
    @Override
    public void applyTo(BlockHound.Builder builder) {
        builder.allowBlockingCallsInside("com.fasterxml.jackson.databind.deser.DeserializerCache", "_createAndCacheValueDeserializer");
    }
}

Given there's no I/O operations in DeserializerCache, the momentary thread parking can be ignored.

This fix also works for 2.17.1

Project reactor users that don't have BlockHound enabled should not be impacted

LuciferYang pushed a commit to apache/spark that referenced this issue Jul 9, 2024
### What changes were proposed in this pull request?

This PR amis to upgrade `fasterxml.jackson` from 2.17.1 to 2.17.2.

### Why are the changes needed?

There are some bug fixes about [Databind](https://github.com/FasterXML/jackson-databind):
[#4561](FasterXML/jackson-databind#4561): Issues using jackson-databind 2.17.1 with Reactor (wrt DeserializerCache and ReentrantLock)
[#4575](FasterXML/jackson-databind#4575): StdDelegatingSerializer does not consider a Converter that may return null for a non-null input
[#4577](FasterXML/jackson-databind#4577): Cannot deserialize value of type java.math.BigDecimal from String "3." (not a valid representation)
[#4595](FasterXML/jackson-databind#4595): No way to explicitly disable wrapping in custom annotation processor
[#4607](FasterXML/jackson-databind#4607): MismatchedInput: No Object Id found for an instance of X to assign to property 'id'
[#4610](FasterXML/jackson-databind#4610): DeserializationFeature.FAIL_ON_UNRESOLVED_OBJECT_IDS does not work when used with Polymorphic type handling

The full release note of 2.17.2:
https://github.com/FasterXML/jackson/wiki/Jackson-Release-2.17.2

### Does this PR introduce _any_ user-facing change?

No.

### How was this patch tested?

Pass GA.

### Was this patch authored or co-authored using generative AI tooling?

No.

Closes #47241 from wayneguow/upgrade_jackson.

Authored-by: Wei Guo <guow93@gmail.com>
Signed-off-by: yangjie01 <yangjie01@baidu.com>
ericm-db pushed a commit to ericm-db/spark that referenced this issue Jul 10, 2024
### What changes were proposed in this pull request?

This PR amis to upgrade `fasterxml.jackson` from 2.17.1 to 2.17.2.

### Why are the changes needed?

There are some bug fixes about [Databind](https://github.com/FasterXML/jackson-databind):
[apache#4561](FasterXML/jackson-databind#4561): Issues using jackson-databind 2.17.1 with Reactor (wrt DeserializerCache and ReentrantLock)
[apache#4575](FasterXML/jackson-databind#4575): StdDelegatingSerializer does not consider a Converter that may return null for a non-null input
[apache#4577](FasterXML/jackson-databind#4577): Cannot deserialize value of type java.math.BigDecimal from String "3." (not a valid representation)
[apache#4595](FasterXML/jackson-databind#4595): No way to explicitly disable wrapping in custom annotation processor
[apache#4607](FasterXML/jackson-databind#4607): MismatchedInput: No Object Id found for an instance of X to assign to property 'id'
[apache#4610](FasterXML/jackson-databind#4610): DeserializationFeature.FAIL_ON_UNRESOLVED_OBJECT_IDS does not work when used with Polymorphic type handling

The full release note of 2.17.2:
https://github.com/FasterXML/jackson/wiki/Jackson-Release-2.17.2

### Does this PR introduce _any_ user-facing change?

No.

### How was this patch tested?

Pass GA.

### Was this patch authored or co-authored using generative AI tooling?

No.

Closes apache#47241 from wayneguow/upgrade_jackson.

Authored-by: Wei Guo <guow93@gmail.com>
Signed-off-by: yangjie01 <yangjie01@baidu.com>
jingz-db pushed a commit to jingz-db/spark that referenced this issue Jul 22, 2024
### What changes were proposed in this pull request?

This PR amis to upgrade `fasterxml.jackson` from 2.17.1 to 2.17.2.

### Why are the changes needed?

There are some bug fixes about [Databind](https://github.com/FasterXML/jackson-databind):
[apache#4561](FasterXML/jackson-databind#4561): Issues using jackson-databind 2.17.1 with Reactor (wrt DeserializerCache and ReentrantLock)
[apache#4575](FasterXML/jackson-databind#4575): StdDelegatingSerializer does not consider a Converter that may return null for a non-null input
[apache#4577](FasterXML/jackson-databind#4577): Cannot deserialize value of type java.math.BigDecimal from String "3." (not a valid representation)
[apache#4595](FasterXML/jackson-databind#4595): No way to explicitly disable wrapping in custom annotation processor
[apache#4607](FasterXML/jackson-databind#4607): MismatchedInput: No Object Id found for an instance of X to assign to property 'id'
[apache#4610](FasterXML/jackson-databind#4610): DeserializationFeature.FAIL_ON_UNRESOLVED_OBJECT_IDS does not work when used with Polymorphic type handling

The full release note of 2.17.2:
https://github.com/FasterXML/jackson/wiki/Jackson-Release-2.17.2

### Does this PR introduce _any_ user-facing change?

No.

### How was this patch tested?

Pass GA.

### Was this patch authored or co-authored using generative AI tooling?

No.

Closes apache#47241 from wayneguow/upgrade_jackson.

Authored-by: Wei Guo <guow93@gmail.com>
Signed-off-by: yangjie01 <yangjie01@baidu.com>
attilapiros pushed a commit to attilapiros/spark that referenced this issue Oct 4, 2024
### What changes were proposed in this pull request?

This PR amis to upgrade `fasterxml.jackson` from 2.17.1 to 2.17.2.

### Why are the changes needed?

There are some bug fixes about [Databind](https://github.com/FasterXML/jackson-databind):
[apache#4561](FasterXML/jackson-databind#4561): Issues using jackson-databind 2.17.1 with Reactor (wrt DeserializerCache and ReentrantLock)
[apache#4575](FasterXML/jackson-databind#4575): StdDelegatingSerializer does not consider a Converter that may return null for a non-null input
[apache#4577](FasterXML/jackson-databind#4577): Cannot deserialize value of type java.math.BigDecimal from String "3." (not a valid representation)
[apache#4595](FasterXML/jackson-databind#4595): No way to explicitly disable wrapping in custom annotation processor
[apache#4607](FasterXML/jackson-databind#4607): MismatchedInput: No Object Id found for an instance of X to assign to property 'id'
[apache#4610](FasterXML/jackson-databind#4610): DeserializationFeature.FAIL_ON_UNRESOLVED_OBJECT_IDS does not work when used with Polymorphic type handling

The full release note of 2.17.2:
https://github.com/FasterXML/jackson/wiki/Jackson-Release-2.17.2

### Does this PR introduce _any_ user-facing change?

No.

### How was this patch tested?

Pass GA.

### Was this patch authored or co-authored using generative AI tooling?

No.

Closes apache#47241 from wayneguow/upgrade_jackson.

Authored-by: Wei Guo <guow93@gmail.com>
Signed-off-by: yangjie01 <yangjie01@baidu.com>
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
2.17 Issues planned at earliest for 2.17
Projects
None yet
Development

No branches or pull requests

3 participants