ffang commented on a change in pull request #2707: URL: https://github.com/apache/camel-quarkus/pull/2707#discussion_r643549806
########## File path: integration-tests/dataformats-json/src/main/java/org/apache/camel/quarkus/component/dataformats/json/RegisterSnakeCaseCustomizer.java ########## @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.quarkus.component.dataformats.json; + +import javax.inject.Singleton; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.PropertyNamingStrategies; +import io.quarkus.jackson.ObjectMapperCustomizer; + +@Singleton +public class RegisterSnakeCaseCustomizer implements ObjectMapperCustomizer { Review comment: I reused JsonComponentsTest#testRoutes, if this customized no used, we can see error like ``` 2021-06-01 19:19:26,719 ERROR [org.apa.cam.pro.err.DefaultErrorHandler] (Camel (camel-quarkus-integration-tests-dataformats-json) thread #8 - WireTap) Failed delivery for (MessageId: 0F582E3E655AE08-0000000000000011 on ExchangeId: 0F582E3E655AE08-0000000000000011). Exhausted after delivery attempt: 1 caught: com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "dummy_string" (class org.apache.camel.quarkus.component.dataformats.json.model.DummyObject), not marked as ignorable (one known property: "dummyString"]) at [Source: (ByteArrayInputStream); line: 1, column: 20] (through reference chain: java.util.ArrayList[0]->org.apache.camel.quarkus.component.dataformats.json.model.DummyObject["dummy_string"]) Message History (complete message history is disabled) --------------------------------------------------------------------------------------------------------------------------------------- RouteId ProcessorId Processor Elapsed (ms) [route76 ] [route76 ] [from[direct://Jackson-in] ] [ 18] ... [route77 ] [unmarshal36 ] [unmarshal[org.apache.camel.model.DataFormatDefinition@554e3de8] ] [ 0] Stacktrace --------------------------------------------------------------------------------------------------------------------------------------- : com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "dummy_string" (class org.apache.camel.quarkus.component.dataformats.json.model.DummyObject), not marked as ignorable (one known property: "dummyString"]) at [Source: (ByteArrayInputStream); line: 1, column: 20] (through reference chain: java.util.ArrayList[0]->org.apache.camel.quarkus.component.dataformats.json.model.DummyObject["dummy_string"]) at com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException.from(UnrecognizedPropertyException.java:61) at com.fasterxml.jackson.databind.DeserializationContext.handleUnknownProperty(DeserializationContext.java:987) at com.fasterxml.jackson.databind.deser.std.StdDeserializer.handleUnknownProperty(StdDeserializer.java:1974) at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownProperty(BeanDeserializerBase.java:1701) at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownVanilla(BeanDeserializerBase.java:1679) at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:330) at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:187) at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer._deserializeFromArray(CollectionDeserializer.java:355) at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:244) at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:28) at com.fasterxml.jackson.databind.deser.DefaultDeserializationContext.readRootValue(DefaultDeserializationContext.java:322) at com.fasterxml.jackson.databind.ObjectReader._bindAndClose(ObjectReader.java:2033) at com.fasterxml.jackson.databind.ObjectReader.readValue(ObjectReader.java:1426) at org.apache.camel.component.jackson.AbstractJacksonDataFormat.unmarshal(AbstractJacksonDataFormat.java:183) at org.apache.camel.support.processor.UnmarshalProcessor.process(UnmarshalProcessor.java:64) at org.apache.camel.processor.errorhandler.RedeliveryErrorHandler$SimpleTask.run(RedeliveryErrorHandler.java:463) at org.apache.camel.impl.engine.DefaultReactiveExecutor$Worker.schedule(DefaultReactiveExecutor.java:179) at org.apache.camel.impl.engine.DefaultReactiveExecutor.scheduleMain(DefaultReactiveExecutor.java:64) at org.apache.camel.processor.errorhandler.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:210) at org.apache.camel.impl.engine.CamelInternalProcessor.process(CamelInternalProcessor.java:398) at org.apache.camel.processor.WireTapProcessor$WireTapTask.run(WireTapProcessor.java:126) at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.base/java.lang.Thread.run(Thread.java:834) ``` And the RegisterSnakeCaseCustomizer basically just setPropertyNamingStrategy(PropertyNamingStrategies.SNAKE_CASE); to make the field name like field "dummy_string" valid. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org