(camel-quarkus) 02/02: Workaround openstack4j incompatibility with Jackson 2.16.x #5604
This is an automated email from the ASF dual-hosted git repository. jamesnetherton pushed a commit to branch quarkus-main in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git commit 47f01592810b61afc714fb11c086bc16a426a8de Author: James Netherton AuthorDate: Mon Dec 11 08:53:29 2023 + Workaround openstack4j incompatibility with Jackson 2.16.x #5604 --- extensions/openstack/runtime/pom.xml | 11 .../OSBadBooleanDeserializerSubstitutions.java | 71 ++ 2 files changed, 82 insertions(+) diff --git a/extensions/openstack/runtime/pom.xml b/extensions/openstack/runtime/pom.xml index f8f4521943..4d3411bfd6 100644 --- a/extensions/openstack/runtime/pom.xml +++ b/extensions/openstack/runtime/pom.xml @@ -52,6 +52,17 @@ io.quarkus quarkus-jackson + + +com.fasterxml.jackson.core +jackson-databind +provided + + +org.graalvm.sdk +graal-sdk +provided + diff --git a/extensions/openstack/runtime/src/main/java/org/apache/camel/quarkus/component/openstack/graal/OSBadBooleanDeserializerSubstitutions.java b/extensions/openstack/runtime/src/main/java/org/apache/camel/quarkus/component/openstack/graal/OSBadBooleanDeserializerSubstitutions.java new file mode 100644 index 00..a099d8a6b1 --- /dev/null +++ b/extensions/openstack/runtime/src/main/java/org/apache/camel/quarkus/component/openstack/graal/OSBadBooleanDeserializerSubstitutions.java @@ -0,0 +1,71 @@ +package org.apache.camel.quarkus.component.openstack.graal; + +import java.io.IOException; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.util.ClassUtil; +import com.oracle.svm.core.annotate.Alias; +import com.oracle.svm.core.annotate.Substitute; +import com.oracle.svm.core.annotate.TargetClass; +import org.openstack4j.core.transport.internal.OSBadBooleanDeserializer; + +/** + * TODO: Remove this https://github.com/apache/camel-quarkus/issues/5604 + * + * Mostly a replica of the original OSBadBooleanDeserializer.deserialize but with references to + * deprecated & removed Jackson methods replaced. + */ +@TargetClass(OSBadBooleanDeserializer.class) +final class OSBadBooleanDeserializerSubstitutions { + +@Substitute +public Boolean deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { +JsonToken t = jp.getCurrentToken(); +if (t == JsonToken.VALUE_TRUE) { +return Boolean.TRUE; +} +if (t == JsonToken.VALUE_FALSE) { +return Boolean.FALSE; +} +// [JACKSON-78]: should accept ints too, (0 == false, otherwise true) +if (t == JsonToken.VALUE_NUMBER_INT) { +// 11-Jan-2012, tatus: May be outside of int... +if (jp.getNumberType() == JsonParser.NumberType.INT) { +return (jp.getIntValue() == 0) ? Boolean.FALSE : Boolean.TRUE; +} +return Boolean.valueOf(_parseBooleanFromNumber(jp, ctxt)); +} +if (t == JsonToken.VALUE_NULL) { +return null; +} +// And finally, let's allow Strings to be converted too +if (t == JsonToken.VALUE_STRING) { +String text = jp.getText().trim(); +if ("true".equalsIgnoreCase(text)) { +return Boolean.TRUE; +} +if ("false".equalsIgnoreCase(text)) { +return Boolean.FALSE; +} +if (text.length() == 0) { +return null; +} +throw ctxt.weirdStringException(text, Boolean.class, "only \"true\" or \"false\" recognized"); +} + +ctxt.handleUnexpectedToken(Boolean.class, ctxt.getParser()); +// Otherwise, no can do: +throw JsonMappingException.from(ctxt.getParser(), +String.format("Cannot deserialize instance of %s out of %s token", +ClassUtil.nameOf(Boolean.class), t)); +} + +@Alias +protected final boolean _parseBooleanFromNumber(JsonParser jp, DeserializationContext ctxt) { +return true; +} +}
(camel-quarkus) 02/02: Workaround openstack4j incompatibility with Jackson 2.16.x #5604
This is an automated email from the ASF dual-hosted git repository. zhfeng pushed a commit to branch quarkus-main in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git commit 07bb91592e4978658e6cf4124734ea29a2bfb574 Author: James Netherton AuthorDate: Mon Dec 11 08:53:29 2023 + Workaround openstack4j incompatibility with Jackson 2.16.x #5604 --- extensions/openstack/runtime/pom.xml | 11 +++ .../OSBadBooleanDeserializerSubstitutions.java | 87 ++ 2 files changed, 98 insertions(+) diff --git a/extensions/openstack/runtime/pom.xml b/extensions/openstack/runtime/pom.xml index f8f4521943..4d3411bfd6 100644 --- a/extensions/openstack/runtime/pom.xml +++ b/extensions/openstack/runtime/pom.xml @@ -52,6 +52,17 @@ io.quarkus quarkus-jackson + + +com.fasterxml.jackson.core +jackson-databind +provided + + +org.graalvm.sdk +graal-sdk +provided + diff --git a/extensions/openstack/runtime/src/main/java/org/apache/camel/quarkus/component/openstack/graal/OSBadBooleanDeserializerSubstitutions.java b/extensions/openstack/runtime/src/main/java/org/apache/camel/quarkus/component/openstack/graal/OSBadBooleanDeserializerSubstitutions.java new file mode 100644 index 00..7d7ef1ba62 --- /dev/null +++ b/extensions/openstack/runtime/src/main/java/org/apache/camel/quarkus/component/openstack/graal/OSBadBooleanDeserializerSubstitutions.java @@ -0,0 +1,87 @@ +/* + * 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.openstack.graal; + +import java.io.IOException; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.util.ClassUtil; +import com.oracle.svm.core.annotate.Alias; +import com.oracle.svm.core.annotate.Substitute; +import com.oracle.svm.core.annotate.TargetClass; +import org.openstack4j.core.transport.internal.OSBadBooleanDeserializer; + +/** + * TODO: Remove this https://github.com/apache/camel-quarkus/issues/5604 + * + * Mostly a replica of the original OSBadBooleanDeserializer.deserialize but with references to + * deprecated & removed Jackson methods replaced. + */ +@TargetClass(OSBadBooleanDeserializer.class) +final class OSBadBooleanDeserializerSubstitutions { + +@Substitute +public Boolean deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { +JsonToken t = jp.getCurrentToken(); +if (t == JsonToken.VALUE_TRUE) { +return Boolean.TRUE; +} +if (t == JsonToken.VALUE_FALSE) { +return Boolean.FALSE; +} +// [JACKSON-78]: should accept ints too, (0 == false, otherwise true) +if (t == JsonToken.VALUE_NUMBER_INT) { +// 11-Jan-2012, tatus: May be outside of int... +if (jp.getNumberType() == JsonParser.NumberType.INT) { +return (jp.getIntValue() == 0) ? Boolean.FALSE : Boolean.TRUE; +} +return Boolean.valueOf(_parseBooleanFromNumber(jp, ctxt)); +} +if (t == JsonToken.VALUE_NULL) { +return null; +} +// And finally, let's allow Strings to be converted too +if (t == JsonToken.VALUE_STRING) { +String text = jp.getText().trim(); +if ("true".equalsIgnoreCase(text)) { +return Boolean.TRUE; +} +if ("false".equalsIgnoreCase(text)) { +return Boolean.FALSE; +} +if (text.length() == 0) { +return null; +} +throw ctxt.weirdStringException(text, Boolean.class, "only \"true\" or \"false\" recognized"); +} + +ctxt.handleUnexpectedToken(Boolean.class, ctxt.getParser()); +// Otherwise, no can do: +throw JsonMappingException.from(ctxt.getParser(
(camel-quarkus) 02/02: Workaround openstack4j incompatibility with Jackson 2.16.x #5604
This is an automated email from the ASF dual-hosted git repository. jamesnetherton pushed a commit to branch quarkus-main in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git commit 0e5d28c09d1e18970e30288cbe488087f4cdfada Author: James Netherton AuthorDate: Mon Dec 11 08:53:29 2023 + Workaround openstack4j incompatibility with Jackson 2.16.x #5604 --- extensions/openstack/runtime/pom.xml | 11 +++ .../OSBadBooleanDeserializerSubstitutions.java | 87 ++ 2 files changed, 98 insertions(+) diff --git a/extensions/openstack/runtime/pom.xml b/extensions/openstack/runtime/pom.xml index f8f4521943..4d3411bfd6 100644 --- a/extensions/openstack/runtime/pom.xml +++ b/extensions/openstack/runtime/pom.xml @@ -52,6 +52,17 @@ io.quarkus quarkus-jackson + + +com.fasterxml.jackson.core +jackson-databind +provided + + +org.graalvm.sdk +graal-sdk +provided + diff --git a/extensions/openstack/runtime/src/main/java/org/apache/camel/quarkus/component/openstack/graal/OSBadBooleanDeserializerSubstitutions.java b/extensions/openstack/runtime/src/main/java/org/apache/camel/quarkus/component/openstack/graal/OSBadBooleanDeserializerSubstitutions.java new file mode 100644 index 00..7d7ef1ba62 --- /dev/null +++ b/extensions/openstack/runtime/src/main/java/org/apache/camel/quarkus/component/openstack/graal/OSBadBooleanDeserializerSubstitutions.java @@ -0,0 +1,87 @@ +/* + * 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.openstack.graal; + +import java.io.IOException; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.util.ClassUtil; +import com.oracle.svm.core.annotate.Alias; +import com.oracle.svm.core.annotate.Substitute; +import com.oracle.svm.core.annotate.TargetClass; +import org.openstack4j.core.transport.internal.OSBadBooleanDeserializer; + +/** + * TODO: Remove this https://github.com/apache/camel-quarkus/issues/5604 + * + * Mostly a replica of the original OSBadBooleanDeserializer.deserialize but with references to + * deprecated & removed Jackson methods replaced. + */ +@TargetClass(OSBadBooleanDeserializer.class) +final class OSBadBooleanDeserializerSubstitutions { + +@Substitute +public Boolean deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { +JsonToken t = jp.getCurrentToken(); +if (t == JsonToken.VALUE_TRUE) { +return Boolean.TRUE; +} +if (t == JsonToken.VALUE_FALSE) { +return Boolean.FALSE; +} +// [JACKSON-78]: should accept ints too, (0 == false, otherwise true) +if (t == JsonToken.VALUE_NUMBER_INT) { +// 11-Jan-2012, tatus: May be outside of int... +if (jp.getNumberType() == JsonParser.NumberType.INT) { +return (jp.getIntValue() == 0) ? Boolean.FALSE : Boolean.TRUE; +} +return Boolean.valueOf(_parseBooleanFromNumber(jp, ctxt)); +} +if (t == JsonToken.VALUE_NULL) { +return null; +} +// And finally, let's allow Strings to be converted too +if (t == JsonToken.VALUE_STRING) { +String text = jp.getText().trim(); +if ("true".equalsIgnoreCase(text)) { +return Boolean.TRUE; +} +if ("false".equalsIgnoreCase(text)) { +return Boolean.FALSE; +} +if (text.length() == 0) { +return null; +} +throw ctxt.weirdStringException(text, Boolean.class, "only \"true\" or \"false\" recognized"); +} + +ctxt.handleUnexpectedToken(Boolean.class, ctxt.getParser()); +// Otherwise, no can do: +throw JsonMappingException.from(ctxt.ge
(camel-quarkus) 02/02: Workaround openstack4j incompatibility with Jackson 2.16.x #5604
This is an automated email from the ASF dual-hosted git repository. jamesnetherton pushed a commit to branch quarkus-main in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git commit d9925445d623b733cd2ba39bab427fa37ef9d871 Author: James Netherton AuthorDate: Mon Dec 11 08:53:29 2023 + Workaround openstack4j incompatibility with Jackson 2.16.x #5604 --- extensions/openstack/runtime/pom.xml | 11 +++ .../OSBadBooleanDeserializerSubstitutions.java | 87 ++ 2 files changed, 98 insertions(+) diff --git a/extensions/openstack/runtime/pom.xml b/extensions/openstack/runtime/pom.xml index f8f4521943..4d3411bfd6 100644 --- a/extensions/openstack/runtime/pom.xml +++ b/extensions/openstack/runtime/pom.xml @@ -52,6 +52,17 @@ io.quarkus quarkus-jackson + + +com.fasterxml.jackson.core +jackson-databind +provided + + +org.graalvm.sdk +graal-sdk +provided + diff --git a/extensions/openstack/runtime/src/main/java/org/apache/camel/quarkus/component/openstack/graal/OSBadBooleanDeserializerSubstitutions.java b/extensions/openstack/runtime/src/main/java/org/apache/camel/quarkus/component/openstack/graal/OSBadBooleanDeserializerSubstitutions.java new file mode 100644 index 00..7d7ef1ba62 --- /dev/null +++ b/extensions/openstack/runtime/src/main/java/org/apache/camel/quarkus/component/openstack/graal/OSBadBooleanDeserializerSubstitutions.java @@ -0,0 +1,87 @@ +/* + * 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.openstack.graal; + +import java.io.IOException; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.util.ClassUtil; +import com.oracle.svm.core.annotate.Alias; +import com.oracle.svm.core.annotate.Substitute; +import com.oracle.svm.core.annotate.TargetClass; +import org.openstack4j.core.transport.internal.OSBadBooleanDeserializer; + +/** + * TODO: Remove this https://github.com/apache/camel-quarkus/issues/5604 + * + * Mostly a replica of the original OSBadBooleanDeserializer.deserialize but with references to + * deprecated & removed Jackson methods replaced. + */ +@TargetClass(OSBadBooleanDeserializer.class) +final class OSBadBooleanDeserializerSubstitutions { + +@Substitute +public Boolean deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { +JsonToken t = jp.getCurrentToken(); +if (t == JsonToken.VALUE_TRUE) { +return Boolean.TRUE; +} +if (t == JsonToken.VALUE_FALSE) { +return Boolean.FALSE; +} +// [JACKSON-78]: should accept ints too, (0 == false, otherwise true) +if (t == JsonToken.VALUE_NUMBER_INT) { +// 11-Jan-2012, tatus: May be outside of int... +if (jp.getNumberType() == JsonParser.NumberType.INT) { +return (jp.getIntValue() == 0) ? Boolean.FALSE : Boolean.TRUE; +} +return Boolean.valueOf(_parseBooleanFromNumber(jp, ctxt)); +} +if (t == JsonToken.VALUE_NULL) { +return null; +} +// And finally, let's allow Strings to be converted too +if (t == JsonToken.VALUE_STRING) { +String text = jp.getText().trim(); +if ("true".equalsIgnoreCase(text)) { +return Boolean.TRUE; +} +if ("false".equalsIgnoreCase(text)) { +return Boolean.FALSE; +} +if (text.length() == 0) { +return null; +} +throw ctxt.weirdStringException(text, Boolean.class, "only \"true\" or \"false\" recognized"); +} + +ctxt.handleUnexpectedToken(Boolean.class, ctxt.getParser()); +// Otherwise, no can do: +throw JsonMappingException.from(ctxt.ge
(camel-quarkus) 02/02: Workaround openstack4j incompatibility with Jackson 2.16.x #5604
This is an automated email from the ASF dual-hosted git repository. jamesnetherton pushed a commit to branch quarkus-main in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git commit 9d73d2fb251ad2dfe9dd51f6ddcfb9c4c6fe8e76 Author: James Netherton AuthorDate: Mon Dec 11 08:53:29 2023 + Workaround openstack4j incompatibility with Jackson 2.16.x #5604 --- extensions/openstack/runtime/pom.xml | 11 +++ .../OSBadBooleanDeserializerSubstitutions.java | 87 ++ 2 files changed, 98 insertions(+) diff --git a/extensions/openstack/runtime/pom.xml b/extensions/openstack/runtime/pom.xml index f8f4521943..4d3411bfd6 100644 --- a/extensions/openstack/runtime/pom.xml +++ b/extensions/openstack/runtime/pom.xml @@ -52,6 +52,17 @@ io.quarkus quarkus-jackson + + +com.fasterxml.jackson.core +jackson-databind +provided + + +org.graalvm.sdk +graal-sdk +provided + diff --git a/extensions/openstack/runtime/src/main/java/org/apache/camel/quarkus/component/openstack/graal/OSBadBooleanDeserializerSubstitutions.java b/extensions/openstack/runtime/src/main/java/org/apache/camel/quarkus/component/openstack/graal/OSBadBooleanDeserializerSubstitutions.java new file mode 100644 index 00..7d7ef1ba62 --- /dev/null +++ b/extensions/openstack/runtime/src/main/java/org/apache/camel/quarkus/component/openstack/graal/OSBadBooleanDeserializerSubstitutions.java @@ -0,0 +1,87 @@ +/* + * 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.openstack.graal; + +import java.io.IOException; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.util.ClassUtil; +import com.oracle.svm.core.annotate.Alias; +import com.oracle.svm.core.annotate.Substitute; +import com.oracle.svm.core.annotate.TargetClass; +import org.openstack4j.core.transport.internal.OSBadBooleanDeserializer; + +/** + * TODO: Remove this https://github.com/apache/camel-quarkus/issues/5604 + * + * Mostly a replica of the original OSBadBooleanDeserializer.deserialize but with references to + * deprecated & removed Jackson methods replaced. + */ +@TargetClass(OSBadBooleanDeserializer.class) +final class OSBadBooleanDeserializerSubstitutions { + +@Substitute +public Boolean deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { +JsonToken t = jp.getCurrentToken(); +if (t == JsonToken.VALUE_TRUE) { +return Boolean.TRUE; +} +if (t == JsonToken.VALUE_FALSE) { +return Boolean.FALSE; +} +// [JACKSON-78]: should accept ints too, (0 == false, otherwise true) +if (t == JsonToken.VALUE_NUMBER_INT) { +// 11-Jan-2012, tatus: May be outside of int... +if (jp.getNumberType() == JsonParser.NumberType.INT) { +return (jp.getIntValue() == 0) ? Boolean.FALSE : Boolean.TRUE; +} +return Boolean.valueOf(_parseBooleanFromNumber(jp, ctxt)); +} +if (t == JsonToken.VALUE_NULL) { +return null; +} +// And finally, let's allow Strings to be converted too +if (t == JsonToken.VALUE_STRING) { +String text = jp.getText().trim(); +if ("true".equalsIgnoreCase(text)) { +return Boolean.TRUE; +} +if ("false".equalsIgnoreCase(text)) { +return Boolean.FALSE; +} +if (text.length() == 0) { +return null; +} +throw ctxt.weirdStringException(text, Boolean.class, "only \"true\" or \"false\" recognized"); +} + +ctxt.handleUnexpectedToken(Boolean.class, ctxt.getParser()); +// Otherwise, no can do: +throw JsonMappingException.from(ctxt.ge
(camel-quarkus) 02/02: Workaround openstack4j incompatibility with Jackson 2.16.x #5604
This is an automated email from the ASF dual-hosted git repository. jamesnetherton pushed a commit to branch quarkus-main in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git commit 14343502274ff5aaf7e78420a2cc32e8e4d9bf35 Author: James Netherton AuthorDate: Mon Dec 11 08:53:29 2023 + Workaround openstack4j incompatibility with Jackson 2.16.x #5604 --- extensions/openstack/runtime/pom.xml | 11 +++ .../OSBadBooleanDeserializerSubstitutions.java | 87 ++ 2 files changed, 98 insertions(+) diff --git a/extensions/openstack/runtime/pom.xml b/extensions/openstack/runtime/pom.xml index f8f4521943..4d3411bfd6 100644 --- a/extensions/openstack/runtime/pom.xml +++ b/extensions/openstack/runtime/pom.xml @@ -52,6 +52,17 @@ io.quarkus quarkus-jackson + + +com.fasterxml.jackson.core +jackson-databind +provided + + +org.graalvm.sdk +graal-sdk +provided + diff --git a/extensions/openstack/runtime/src/main/java/org/apache/camel/quarkus/component/openstack/graal/OSBadBooleanDeserializerSubstitutions.java b/extensions/openstack/runtime/src/main/java/org/apache/camel/quarkus/component/openstack/graal/OSBadBooleanDeserializerSubstitutions.java new file mode 100644 index 00..7d7ef1ba62 --- /dev/null +++ b/extensions/openstack/runtime/src/main/java/org/apache/camel/quarkus/component/openstack/graal/OSBadBooleanDeserializerSubstitutions.java @@ -0,0 +1,87 @@ +/* + * 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.openstack.graal; + +import java.io.IOException; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.util.ClassUtil; +import com.oracle.svm.core.annotate.Alias; +import com.oracle.svm.core.annotate.Substitute; +import com.oracle.svm.core.annotate.TargetClass; +import org.openstack4j.core.transport.internal.OSBadBooleanDeserializer; + +/** + * TODO: Remove this https://github.com/apache/camel-quarkus/issues/5604 + * + * Mostly a replica of the original OSBadBooleanDeserializer.deserialize but with references to + * deprecated & removed Jackson methods replaced. + */ +@TargetClass(OSBadBooleanDeserializer.class) +final class OSBadBooleanDeserializerSubstitutions { + +@Substitute +public Boolean deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { +JsonToken t = jp.getCurrentToken(); +if (t == JsonToken.VALUE_TRUE) { +return Boolean.TRUE; +} +if (t == JsonToken.VALUE_FALSE) { +return Boolean.FALSE; +} +// [JACKSON-78]: should accept ints too, (0 == false, otherwise true) +if (t == JsonToken.VALUE_NUMBER_INT) { +// 11-Jan-2012, tatus: May be outside of int... +if (jp.getNumberType() == JsonParser.NumberType.INT) { +return (jp.getIntValue() == 0) ? Boolean.FALSE : Boolean.TRUE; +} +return Boolean.valueOf(_parseBooleanFromNumber(jp, ctxt)); +} +if (t == JsonToken.VALUE_NULL) { +return null; +} +// And finally, let's allow Strings to be converted too +if (t == JsonToken.VALUE_STRING) { +String text = jp.getText().trim(); +if ("true".equalsIgnoreCase(text)) { +return Boolean.TRUE; +} +if ("false".equalsIgnoreCase(text)) { +return Boolean.FALSE; +} +if (text.length() == 0) { +return null; +} +throw ctxt.weirdStringException(text, Boolean.class, "only \"true\" or \"false\" recognized"); +} + +ctxt.handleUnexpectedToken(Boolean.class, ctxt.getParser()); +// Otherwise, no can do: +throw JsonMappingException.from(ctxt.ge
(camel-quarkus) 02/02: Workaround openstack4j incompatibility with Jackson 2.16.x #5604
This is an automated email from the ASF dual-hosted git repository. jamesnetherton pushed a commit to branch quarkus-main in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git commit 3c78a4169902a482454978633e2674d41a78dd1a Author: James Netherton AuthorDate: Mon Dec 11 08:53:29 2023 + Workaround openstack4j incompatibility with Jackson 2.16.x #5604 --- extensions/openstack/runtime/pom.xml | 11 +++ .../OSBadBooleanDeserializerSubstitutions.java | 87 ++ 2 files changed, 98 insertions(+) diff --git a/extensions/openstack/runtime/pom.xml b/extensions/openstack/runtime/pom.xml index f8f4521943..4d3411bfd6 100644 --- a/extensions/openstack/runtime/pom.xml +++ b/extensions/openstack/runtime/pom.xml @@ -52,6 +52,17 @@ io.quarkus quarkus-jackson + + +com.fasterxml.jackson.core +jackson-databind +provided + + +org.graalvm.sdk +graal-sdk +provided + diff --git a/extensions/openstack/runtime/src/main/java/org/apache/camel/quarkus/component/openstack/graal/OSBadBooleanDeserializerSubstitutions.java b/extensions/openstack/runtime/src/main/java/org/apache/camel/quarkus/component/openstack/graal/OSBadBooleanDeserializerSubstitutions.java new file mode 100644 index 00..7d7ef1ba62 --- /dev/null +++ b/extensions/openstack/runtime/src/main/java/org/apache/camel/quarkus/component/openstack/graal/OSBadBooleanDeserializerSubstitutions.java @@ -0,0 +1,87 @@ +/* + * 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.openstack.graal; + +import java.io.IOException; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.util.ClassUtil; +import com.oracle.svm.core.annotate.Alias; +import com.oracle.svm.core.annotate.Substitute; +import com.oracle.svm.core.annotate.TargetClass; +import org.openstack4j.core.transport.internal.OSBadBooleanDeserializer; + +/** + * TODO: Remove this https://github.com/apache/camel-quarkus/issues/5604 + * + * Mostly a replica of the original OSBadBooleanDeserializer.deserialize but with references to + * deprecated & removed Jackson methods replaced. + */ +@TargetClass(OSBadBooleanDeserializer.class) +final class OSBadBooleanDeserializerSubstitutions { + +@Substitute +public Boolean deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { +JsonToken t = jp.getCurrentToken(); +if (t == JsonToken.VALUE_TRUE) { +return Boolean.TRUE; +} +if (t == JsonToken.VALUE_FALSE) { +return Boolean.FALSE; +} +// [JACKSON-78]: should accept ints too, (0 == false, otherwise true) +if (t == JsonToken.VALUE_NUMBER_INT) { +// 11-Jan-2012, tatus: May be outside of int... +if (jp.getNumberType() == JsonParser.NumberType.INT) { +return (jp.getIntValue() == 0) ? Boolean.FALSE : Boolean.TRUE; +} +return Boolean.valueOf(_parseBooleanFromNumber(jp, ctxt)); +} +if (t == JsonToken.VALUE_NULL) { +return null; +} +// And finally, let's allow Strings to be converted too +if (t == JsonToken.VALUE_STRING) { +String text = jp.getText().trim(); +if ("true".equalsIgnoreCase(text)) { +return Boolean.TRUE; +} +if ("false".equalsIgnoreCase(text)) { +return Boolean.FALSE; +} +if (text.length() == 0) { +return null; +} +throw ctxt.weirdStringException(text, Boolean.class, "only \"true\" or \"false\" recognized"); +} + +ctxt.handleUnexpectedToken(Boolean.class, ctxt.getParser()); +// Otherwise, no can do: +throw JsonMappingException.from(ctxt.ge
(camel-quarkus) 02/02: Workaround openstack4j incompatibility with Jackson 2.16.x #5604
This is an automated email from the ASF dual-hosted git repository. jamesnetherton pushed a commit to branch quarkus-main in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git commit 09071af1c6e1ffb6f71fcf68e1814fa5ae666320 Author: James Netherton AuthorDate: Mon Dec 11 08:53:29 2023 + Workaround openstack4j incompatibility with Jackson 2.16.x #5604 --- extensions/openstack/runtime/pom.xml | 11 +++ .../OSBadBooleanDeserializerSubstitutions.java | 87 ++ 2 files changed, 98 insertions(+) diff --git a/extensions/openstack/runtime/pom.xml b/extensions/openstack/runtime/pom.xml index f8f4521943..4d3411bfd6 100644 --- a/extensions/openstack/runtime/pom.xml +++ b/extensions/openstack/runtime/pom.xml @@ -52,6 +52,17 @@ io.quarkus quarkus-jackson + + +com.fasterxml.jackson.core +jackson-databind +provided + + +org.graalvm.sdk +graal-sdk +provided + diff --git a/extensions/openstack/runtime/src/main/java/org/apache/camel/quarkus/component/openstack/graal/OSBadBooleanDeserializerSubstitutions.java b/extensions/openstack/runtime/src/main/java/org/apache/camel/quarkus/component/openstack/graal/OSBadBooleanDeserializerSubstitutions.java new file mode 100644 index 00..7d7ef1ba62 --- /dev/null +++ b/extensions/openstack/runtime/src/main/java/org/apache/camel/quarkus/component/openstack/graal/OSBadBooleanDeserializerSubstitutions.java @@ -0,0 +1,87 @@ +/* + * 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.openstack.graal; + +import java.io.IOException; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.util.ClassUtil; +import com.oracle.svm.core.annotate.Alias; +import com.oracle.svm.core.annotate.Substitute; +import com.oracle.svm.core.annotate.TargetClass; +import org.openstack4j.core.transport.internal.OSBadBooleanDeserializer; + +/** + * TODO: Remove this https://github.com/apache/camel-quarkus/issues/5604 + * + * Mostly a replica of the original OSBadBooleanDeserializer.deserialize but with references to + * deprecated & removed Jackson methods replaced. + */ +@TargetClass(OSBadBooleanDeserializer.class) +final class OSBadBooleanDeserializerSubstitutions { + +@Substitute +public Boolean deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { +JsonToken t = jp.getCurrentToken(); +if (t == JsonToken.VALUE_TRUE) { +return Boolean.TRUE; +} +if (t == JsonToken.VALUE_FALSE) { +return Boolean.FALSE; +} +// [JACKSON-78]: should accept ints too, (0 == false, otherwise true) +if (t == JsonToken.VALUE_NUMBER_INT) { +// 11-Jan-2012, tatus: May be outside of int... +if (jp.getNumberType() == JsonParser.NumberType.INT) { +return (jp.getIntValue() == 0) ? Boolean.FALSE : Boolean.TRUE; +} +return Boolean.valueOf(_parseBooleanFromNumber(jp, ctxt)); +} +if (t == JsonToken.VALUE_NULL) { +return null; +} +// And finally, let's allow Strings to be converted too +if (t == JsonToken.VALUE_STRING) { +String text = jp.getText().trim(); +if ("true".equalsIgnoreCase(text)) { +return Boolean.TRUE; +} +if ("false".equalsIgnoreCase(text)) { +return Boolean.FALSE; +} +if (text.length() == 0) { +return null; +} +throw ctxt.weirdStringException(text, Boolean.class, "only \"true\" or \"false\" recognized"); +} + +ctxt.handleUnexpectedToken(Boolean.class, ctxt.getParser()); +// Otherwise, no can do: +throw JsonMappingException.from(ctxt.ge