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

Adding DeserializationFeature.FAIL_ON_TRAILING_TOKENS in ContextFunctionCatalogAutoConfiguration breaks WebTestClient with HypermediaWebTestClientConfigurer #1148

Closed
guerricmerleHUG opened this issue Jun 3, 2024 · 21 comments
Assignees
Milestone

Comments

@guerricmerleHUG
Copy link

Describe the bug
We start by migrating our applications to Spring Boot 3.2.6, Spring Cloud 2023.0.2, these applications have these dependencies: spring-boot-starter-hateoas, spring-boot-starter-webflux and
spring-cloud-stream-test-binder / spring-cloud-starter-bus-amqp / ... any dependency that uses "spring-cloud-function-context", this last dependency breaks all tests because of adding "mapper .configure(DeserializationFeature.FAIL_ON_TRAILING_TOKENS, true);" in ContextFunctionCatalogAutoConfiguration in the version used by 2023.0.2..

No problem with Spring Boot 3.2.6, Spring Cloud 2023.0.1 .

Sample
demo.zip

Launch test PbHalApplicationTests#createTestAndCheck :
this error is raised :

org.springframework.core.codec.DecodingException: JSON decoding error: Trailing token (of type END_OBJECT) found after value (bound as `org.springframework.hateoas.Link`): not allowed as per `DeserializationFeature.FAIL_ON_TRAILING_TOKENS`
	at org.springframework.http.codec.json.AbstractJackson2Decoder.processException(AbstractJackson2Decoder.java:275)
	Suppressed: The stacktrace has been enhanced by Reactor, refer to additional information below: 
Error has been observed at the following site(s):
	*__checkpoint ⇢ Body from POST /tests [DefaultClientResponse]
Original Stack Trace:
		at org.springframework.http.codec.json.AbstractJackson2Decoder.processException(AbstractJackson2Decoder.java:275)
		at org.springframework.http.codec.json.AbstractJackson2Decoder.decode(AbstractJackson2Decoder.java:211)
		at org.springframework.http.codec.json.AbstractJackson2Decoder.lambda$decodeToMono$2(AbstractJackson2Decoder.java:191)
		at reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:132)
		at reactor.core.publisher.FluxContextWrite$ContextWriteSubscriber.onNext(FluxContextWrite.java:107)
		at reactor.core.publisher.FluxMapFuseable$MapFuseableConditionalSubscriber.onNext(FluxMapFuseable.java:299)
		at reactor.core.publisher.FluxFilterFuseable$FilterFuseableConditionalSubscriber.onNext(FluxFilterFuseable.java:337)
		at reactor.core.publisher.Operators$BaseFluxToMonoOperator.completePossiblyEmpty(Operators.java:2097)
		at reactor.core.publisher.MonoCollect$CollectSubscriber.onComplete(MonoCollect.java:145)
		at reactor.core.publisher.FluxPeekFuseable$PeekFuseableSubscriber.onComplete(FluxPeekFuseable.java:277)
		at reactor.core.publisher.FluxPeekFuseable$PeekFuseableSubscriber.onComplete(FluxPeekFuseable.java:277)
		at reactor.core.publisher.FluxPeekFuseable$PeekFuseableSubscriber.onComplete(FluxPeekFuseable.java:277)
		at reactor.core.publisher.FluxPeekFuseable$PeekFuseableSubscriber.onComplete(FluxPeekFuseable.java:277)
		at reactor.core.publisher.FluxPeekFuseable$PeekFuseableSubscriber.onComplete(FluxPeekFuseable.java:277)
		at reactor.core.publisher.FluxContextWrite$ContextWriteSubscriber.onComplete(FluxContextWrite.java:126)
		at reactor.core.publisher.FluxPeekFuseable$PeekFuseableConditionalSubscriber.onComplete(FluxPeekFuseable.java:595)
		at reactor.core.publisher.MonoCallable$MonoCallableSubscription.request(MonoCallable.java:159)
		at reactor.core.publisher.FluxPeekFuseable$PeekFuseableConditionalSubscriber.request(FluxPeekFuseable.java:437)
		at reactor.core.publisher.FluxContextWrite$ContextWriteSubscriber.request(FluxContextWrite.java:136)
		at reactor.core.publisher.FluxPeekFuseable$PeekFuseableSubscriber.request(FluxPeekFuseable.java:144)
		at reactor.core.publisher.FluxPeekFuseable$PeekFuseableSubscriber.request(FluxPeekFuseable.java:144)
		at reactor.core.publisher.FluxPeekFuseable$PeekFuseableSubscriber.request(FluxPeekFuseable.java:144)
		at reactor.core.publisher.FluxPeekFuseable$PeekFuseableSubscriber.request(FluxPeekFuseable.java:144)
		at reactor.core.publisher.FluxPeekFuseable$PeekFuseableSubscriber.request(FluxPeekFuseable.java:144)
		at reactor.core.publisher.Operators$BaseFluxToMonoOperator.request(Operators.java:2067)
		at reactor.core.publisher.FluxFilterFuseable$FilterFuseableConditionalSubscriber.request(FluxFilterFuseable.java:411)
		at reactor.core.publisher.FluxMapFuseable$MapFuseableConditionalSubscriber.request(FluxMapFuseable.java:360)
		at reactor.core.publisher.FluxContextWrite$ContextWriteSubscriber.request(FluxContextWrite.java:136)
		at reactor.core.publisher.MonoFlatMap$FlatMapMain.request(MonoFlatMap.java:194)
		at reactor.core.publisher.BlockingSingleSubscriber.onSubscribe(BlockingSingleSubscriber.java:54)
		at reactor.core.publisher.MonoFlatMap$FlatMapMain.onSubscribe(MonoFlatMap.java:117)
		at reactor.core.publisher.FluxContextWrite$ContextWriteSubscriber.onSubscribe(FluxContextWrite.java:101)
		at reactor.core.publisher.FluxMapFuseable$MapFuseableConditionalSubscriber.onSubscribe(FluxMapFuseable.java:265)
		at reactor.core.publisher.FluxFilterFuseable$FilterFuseableConditionalSubscriber.onSubscribe(FluxFilterFuseable.java:305)
		at reactor.core.publisher.Operators$BaseFluxToMonoOperator.onSubscribe(Operators.java:2051)
		at reactor.core.publisher.FluxPeekFuseable$PeekFuseableSubscriber.onSubscribe(FluxPeekFuseable.java:178)
		at reactor.core.publisher.FluxPeekFuseable$PeekFuseableSubscriber.onSubscribe(FluxPeekFuseable.java:178)
		at reactor.core.publisher.FluxPeekFuseable$PeekFuseableSubscriber.onSubscribe(FluxPeekFuseable.java:178)
		at reactor.core.publisher.FluxPeekFuseable$PeekFuseableSubscriber.onSubscribe(FluxPeekFuseable.java:178)
		at reactor.core.publisher.FluxPeekFuseable$PeekFuseableSubscriber.onSubscribe(FluxPeekFuseable.java:178)
		at reactor.core.publisher.FluxContextWrite$ContextWriteSubscriber.onSubscribe(FluxContextWrite.java:101)
		at reactor.core.publisher.FluxPeekFuseable$PeekFuseableConditionalSubscriber.onSubscribe(FluxPeekFuseable.java:471)
		at reactor.core.publisher.MonoCallable.subscribe(MonoCallable.java:48)
		at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:76)
		at reactor.core.publisher.MonoDeferContextual.subscribe(MonoDeferContextual.java:55)
		at reactor.core.publisher.Mono.subscribe(Mono.java:4568)
		at reactor.core.publisher.Mono.block(Mono.java:1806)
		at org.springframework.test.web.reactive.server.DefaultWebTestClient$DefaultResponseSpec.expectBody(DefaultWebTestClient.java:442)
		at ch.hug.client.notification.PbHalApplicationTests.createTestAndCheck(PbHalApplicationTests.java:59)
		at java.base/java.lang.reflect.Method.invoke(Method.java:580)
		at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
		at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
	Suppressed: java.lang.Exception: #block terminated with an error
		at reactor.core.publisher.BlockingSingleSubscriber.blockingGet(BlockingSingleSubscriber.java:146)
		at reactor.core.publisher.Mono.block(Mono.java:1807)
		at org.springframework.test.web.reactive.server.DefaultWebTestClient$DefaultResponseSpec.expectBody(DefaultWebTestClient.java:442)
		at ch.hug.client.notification.PbHalApplicationTests.createTestAndCheck(PbHalApplicationTests.java:59)
		at java.base/java.lang.reflect.Method.invoke(Method.java:580)
		at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
		at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
Caused by: com.fasterxml.jackson.databind.exc.MismatchedInputException: Trailing token (of type END_OBJECT) found after value (bound as `org.springframework.hateoas.Link`): not allowed as per `DeserializationFeature.FAIL_ON_TRAILING_TOKENS`
 at [Source: (org.springframework.core.io.buffer.DataBufferInputStream); line: 1, column: 119] (through reference chain: org.springframework.hateoas.EntityModel["_links"])
	at com.fasterxml.jackson.databind.exc.MismatchedInputException.from(MismatchedInputException.java:63)
	at com.fasterxml.jackson.databind.DeserializationContext.reportTrailingTokens(DeserializationContext.java:1825)
	at com.fasterxml.jackson.databind.ObjectMapper._verifyNoTrailingTokens(ObjectMapper.java:4933)
	at com.fasterxml.jackson.databind.ObjectMapper._readValue(ObjectMapper.java:4806)
	at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2974)
	at com.fasterxml.jackson.core.JsonParser.readValueAs(JsonParser.java:2363)
	at org.springframework.hateoas.mediatype.hal.Jackson2HalModule$HalLinkListDeserializer.deserialize(Jackson2HalModule.java:607)
	at org.springframework.hateoas.mediatype.hal.Jackson2HalModule$HalLinkListDeserializer.deserialize(Jackson2HalModule.java:554)
	at com.fasterxml.jackson.databind.deser.impl.FieldProperty.deserializeAndSet(FieldProperty.java:138)
	at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeWithUnwrapped(BeanDeserializer.java:735)
	at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:347)
	at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:185)
	at com.fasterxml.jackson.databind.deser.DefaultDeserializationContext.readRootValue(DefaultDeserializationContext.java:323)
	at com.fasterxml.jackson.databind.ObjectReader._bindAndClose(ObjectReader.java:2105)
	at com.fasterxml.jackson.databind.ObjectReader.readValue(ObjectReader.java:1481)
	at org.springframework.http.codec.json.AbstractJackson2Decoder.decode(AbstractJackson2Decoder.java:206)
	at org.springframework.http.codec.json.AbstractJackson2Decoder.lambda$decodeToMono$2(AbstractJackson2Decoder.java:191)
	at reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:132)
	at reactor.core.publisher.FluxContextWrite$ContextWriteSubscriber.onNext(FluxContextWrite.java:107)
	at reactor.core.publisher.FluxMapFuseable$MapFuseableConditionalSubscriber.onNext(FluxMapFuseable.java:299)
	at reactor.core.publisher.FluxFilterFuseable$FilterFuseableConditionalSubscriber.onNext(FluxFilterFuseable.java:337)
	at reactor.core.publisher.Operators$BaseFluxToMonoOperator.completePossiblyEmpty(Operators.java:2097)
	at reactor.core.publisher.MonoCollect$CollectSubscriber.onComplete(MonoCollect.java:145)
	at reactor.core.publisher.FluxPeekFuseable$PeekFuseableSubscriber.onComplete(FluxPeekFuseable.java:277)
	at reactor.core.publisher.FluxPeekFuseable$PeekFuseableSubscriber.onComplete(FluxPeekFuseable.java:277)
	at reactor.core.publisher.FluxPeekFuseable$PeekFuseableSubscriber.onComplete(FluxPeekFuseable.java:277)
	at reactor.core.publisher.FluxPeekFuseable$PeekFuseableSubscriber.onComplete(FluxPeekFuseable.java:277)
	at reactor.core.publisher.FluxPeekFuseable$PeekFuseableSubscriber.onComplete(FluxPeekFuseable.java:277)
	at reactor.core.publisher.FluxContextWrite$ContextWriteSubscriber.onComplete(FluxContextWrite.java:126)
	at reactor.core.publisher.FluxPeekFuseable$PeekFuseableConditionalSubscriber.onComplete(FluxPeekFuseable.java:595)
	at reactor.core.publisher.MonoCallable$MonoCallableSubscription.request(MonoCallable.java:159)
	at reactor.core.publisher.FluxPeekFuseable$PeekFuseableConditionalSubscriber.request(FluxPeekFuseable.java:437)
	at reactor.core.publisher.FluxContextWrite$ContextWriteSubscriber.request(FluxContextWrite.java:136)
	at reactor.core.publisher.FluxPeekFuseable$PeekFuseableSubscriber.request(FluxPeekFuseable.java:144)
	at reactor.core.publisher.FluxPeekFuseable$PeekFuseableSubscriber.request(FluxPeekFuseable.java:144)
	at reactor.core.publisher.FluxPeekFuseable$PeekFuseableSubscriber.request(FluxPeekFuseable.java:144)
	at reactor.core.publisher.FluxPeekFuseable$PeekFuseableSubscriber.request(FluxPeekFuseable.java:144)
	at reactor.core.publisher.FluxPeekFuseable$PeekFuseableSubscriber.request(FluxPeekFuseable.java:144)
	at reactor.core.publisher.Operators$BaseFluxToMonoOperator.request(Operators.java:2067)
	at reactor.core.publisher.FluxFilterFuseable$FilterFuseableConditionalSubscriber.request(FluxFilterFuseable.java:411)
	at reactor.core.publisher.FluxMapFuseable$MapFuseableConditionalSubscriber.request(FluxMapFuseable.java:360)
	at reactor.core.publisher.FluxContextWrite$ContextWriteSubscriber.request(FluxContextWrite.java:136)
	at reactor.core.publisher.MonoFlatMap$FlatMapMain.request(MonoFlatMap.java:194)
	at reactor.core.publisher.FluxOnAssembly$OnAssemblySubscriber.request(FluxOnAssembly.java:649)
	at reactor.core.publisher.BlockingSingleSubscriber.onSubscribe(BlockingSingleSubscriber.java:54)
	at reactor.core.publisher.FluxOnAssembly$OnAssemblySubscriber.onSubscribe(FluxOnAssembly.java:633)
	at reactor.core.publisher.MonoFlatMap$FlatMapMain.onSubscribe(MonoFlatMap.java:117)
	at reactor.core.publisher.FluxContextWrite$ContextWriteSubscriber.onSubscribe(FluxContextWrite.java:101)
	at reactor.core.publisher.FluxMapFuseable$MapFuseableConditionalSubscriber.onSubscribe(FluxMapFuseable.java:265)
	at reactor.core.publisher.FluxFilterFuseable$FilterFuseableConditionalSubscriber.onSubscribe(FluxFilterFuseable.java:305)
	at reactor.core.publisher.Operators$BaseFluxToMonoOperator.onSubscribe(Operators.java:2051)
	at reactor.core.publisher.FluxPeekFuseable$PeekFuseableSubscriber.onSubscribe(FluxPeekFuseable.java:178)
	at reactor.core.publisher.FluxPeekFuseable$PeekFuseableSubscriber.onSubscribe(FluxPeekFuseable.java:178)
	at reactor.core.publisher.FluxPeekFuseable$PeekFuseableSubscriber.onSubscribe(FluxPeekFuseable.java:178)
	at reactor.core.publisher.FluxPeekFuseable$PeekFuseableSubscriber.onSubscribe(FluxPeekFuseable.java:178)
	at reactor.core.publisher.FluxPeekFuseable$PeekFuseableSubscriber.onSubscribe(FluxPeekFuseable.java:178)
	at reactor.core.publisher.FluxContextWrite$ContextWriteSubscriber.onSubscribe(FluxContextWrite.java:101)
	at reactor.core.publisher.FluxPeekFuseable$PeekFuseableConditionalSubscriber.onSubscribe(FluxPeekFuseable.java:471)
	at reactor.core.publisher.MonoCallable.subscribe(MonoCallable.java:48)
	at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:76)
	at reactor.core.publisher.MonoDeferContextual.subscribe(MonoDeferContextual.java:55)
	at reactor.core.publisher.Mono.subscribe(Mono.java:4568)
	at reactor.core.publisher.Mono.block(Mono.java:1806)
	at org.springframework.test.web.reactive.server.DefaultWebTestClient$DefaultResponseSpec.expectBody(DefaultWebTestClient.java:442)
	at ch.hug.client.notification.PbHalApplicationTests.createTestAndCheck(PbHalApplicationTests.java:59)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
@jhengy-work
Copy link

Is there any update on this? I'm facing the same issue as well

@olegz
Copy link
Contributor

olegz commented Jun 5, 2024

Looking

@olegz
Copy link
Contributor

olegz commented Jun 5, 2024

Part of the issue is that Hateos (which you are using) is registering (overriding) it's own ObjectMapper instead of using the one provided by boot. This effectively means that using standard boot way of configuring ObjectMapper is out of the question - unfortunately.
So, I may need to do something manually
Basically access

spring:
  jackson:
    deserialization: 
      fail-on-trailing-tokens: true

. . and set it if exist.
We can't simply remove it as it was introduced to solve another issue with protobuf

@olegz
Copy link
Contributor

olegz commented Jun 5, 2024

I'll take that back, apparently you can, so let me remove it and let other users know that they can set it manually as:

spring:
  jackson:
    deserialization: 
      fail-on-trailing-tokens: true

@olegz
Copy link
Contributor

olegz commented Jun 5, 2024

Related - #1094

@olegz olegz self-assigned this Jun 5, 2024
@olegz olegz added this to the 4.1.3 milestone Jun 5, 2024
@olegz olegz closed this as completed in 812c39e Jun 5, 2024
@olegz
Copy link
Contributor

olegz commented Jun 7, 2024

I am going to revert this change since the problem has nothing to do with s-c-function as it is not even part of the stack trace of the failure. The issue i suspect is that Hateos have provided their own ObjectMapper over the one from boot and we are simply using it.
We'll configure our own ObjectMapper so it does not interfere with the provided one

olegz added a commit that referenced this issue Jun 7, 2024
olegz added a commit that referenced this issue Jun 7, 2024
@davidmestr
Copy link

Hi @olegz ,
Are you planning to release a version with this fix?

Thanks

@snussbaumer
Copy link

Same problem here, the simple fact of including spring-cloud-function changes the behaviour of the default objectMapper by adding FAIL_ON_TRAILING_TOKENS. I agree that spring cloud function probably needs must have its own objectMapper if you need to change settings ...

@olegz : this issue should be open again if the code that goes with it has been reverted, no ?

@mgimenoromanadevinta
Copy link

Hello
The fact that a new ObjectMapper is now instantiated is creating numerous issues, for instance when deserialising a payload into a Kotlin object

Is there a plan to fix this here?
Thanks

lbilger pushed a commit to lbilger/spring-cloud-function that referenced this issue Jul 17, 2024
lbilger pushed a commit to lbilger/spring-cloud-function that referenced this issue Jul 17, 2024
olegz pushed a commit that referenced this issue Aug 15, 2024
olegz pushed a commit that referenced this issue Aug 15, 2024
olegz pushed a commit that referenced this issue Aug 15, 2024
@wabrit
Copy link

wabrit commented Aug 21, 2024

Apologies if this is not the place to raise this, but I've had numerous issues moving my Spring Boot app from Spring Cloud 2023.0.1 to 2023.0.2/3, all of which seem to be related to the fact that parts of spring cloud are rolling their own fasterxml ObjectMapper and not taking account of spring boot-based customization.

I've hit this with

  • serialization of Optional values to JSON (presence of jackson-datatype-jdk8 on classpath should gracefully map Optionals to their value or null)
  • fail on trailing tokens issues
  • received messages being of type byte[] rather than the expected deserialized from JSON java object

If my guess is correct, are all of these related issues going to be addressed in 2024.0.0? TIA

@TheMorganHub
Copy link

To be blunt, this change broke so many things. Who thought it'd be a good idea to inject your own ObjectMapper completely disregarding the one that's already been registered (and possibly already customised) by the user?

@wojciech-piotrowiak
Copy link

Would be great to inform us when this fix will be released (milestone is not enough for my case).
With that, I can decide if it is better to wait for the next version or maybe try a workaround

@kubav182
Copy link

kubav182 commented Nov 29, 2024

is the issue solved? in 2023.0.4 I have test errors Trailing token (of type END_OBJECT) found after value (bound as int): not allowed as per DeserializationFeature.FAIL_ON_TRAILING_TOKENS when extracting array response from rest assured. 2023.0.1 is last working version

How can I disable FAIL_ON_TRAILING_TOKENS when I inject ObjectMapper? Spring properties have no effect.

@kubav182
Copy link

kubav182 commented Dec 2, 2024

1cd93cb

why isn't this backported to 4.1.x? @olegz

@ferblaca
Copy link

ferblaca commented Dec 3, 2024

@olegz It seems that for Spring Cloud 2023.0.4 fail again. In Spring Cloud 2023.0.3 version it was fixed.

We also have the same problem again with projects using Spring Cloud Bus + Spring Cloud 2023.0.4.

With the demo.zip of this same issue it is reproduced by upgrading to Spring Boot 3.3.6 + Spring Cloud 2023.0.4.

@kubav182
Copy link

kubav182 commented Dec 3, 2024

stupid workaround, but works

@Component
@RequiredArgsConstructor
@FieldDefaults(level = PRIVATE, makeFinal = true)
public class ContextRefreshedEventListener implements ApplicationListener<ContextRefreshedEvent> {

    ObjectMapper objectMapper;

    @Override
    public void onApplicationEvent(ContextRefreshedEvent event) {
        objectMapper.configure(FAIL_ON_TRAILING_TOKENS, false);
    }

}

@ferblaca
Copy link

ferblaca commented Dec 3, 2024

stupid workaround, but works

@Component
@RequiredArgsConstructor
@FieldDefaults(level = PRIVATE, makeFinal = true)
public class ContextRefreshedEventListener implements ApplicationListener<ContextRefreshedEvent> {

    ObjectMapper objectMapper;

    @Override
    public void onApplicationEvent(ContextRefreshedEvent event) {
        objectMapper.configure(FAIL_ON_TRAILING_TOKENS, false);
    }

}

@kubav182 this workaround works correctly! but for Spring Cloud version 2023.0.3 it was not necessary...

@ferblaca
Copy link

ferblaca commented Dec 3, 2024

Downgrading only the spring-cloud-function-context to version 4.1.3 is working properly again.

Is it possible that it could be due to this change?

@juliojgd
Copy link

juliojgd commented Dec 5, 2024

Downgrading only the spring-cloud-function-context to version 4.1.3 is working properly again.

Is it possible that it could be due to this change?

@olegz maybe this issue should be reopened? It seems to exist a regression as @ferblaca commented.

@guerricmerleHUG
Copy link
Author

@olegz i confirm that the issue occurs with Spring Boot 3.3.6 and Spring cloud 2023.0.4.

#1148 (comment)

I am going to revert this change since the problem has nothing to do with s-c-function as it is not even part of the stack trace of the failure. The issue i suspect is that Hateos have provided their own ObjectMapper over the one from boot and we are simply using it. We'll configure our own ObjectMapper so it does not interfere with the provided one

You think that Spring Hateaos should investigate the problem : do you reopen this issue spring-projects/spring-hateoas#2158 ?

@adamsmith118
Copy link

stupid workaround, but works

@Component
@RequiredArgsConstructor
@FieldDefaults(level = PRIVATE, makeFinal = true)
public class ContextRefreshedEventListener implements ApplicationListener<ContextRefreshedEvent> {

    ObjectMapper objectMapper;

    @Override
    public void onApplicationEvent(ContextRefreshedEvent event) {
        objectMapper.configure(FAIL_ON_TRAILING_TOKENS, false);
    }

}

@kubav182 this workaround works correctly! but for Spring Cloud version 2023.0.3 it was not necessary...

In 4.2.0 you can do...

  @Bean
  public JacksonMapper jsonMapper(ObjectMapper objectMapper) {
    objectMapper.addMixIn(...whatever...)
    return new JacksonMapper(objectMapper);
  }

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

No branches or pull requests