Skip to content

Commit 519b63f

Browse files
committed
ci: fix Language auto-config ClassCastException
Not all Language implementations extend LanguageSupport/CamelContextAware (e.g. ExchangePropertyLanguage). Use instanceof check with pattern matching instead of an unsafe cast or ObjectProvider (which triggers the circular dependency during camelContext.build()).
1 parent dd7d79b commit 519b63f

31 files changed

Lines changed: 94 additions & 40 deletions

File tree

catalog/camel-catalog-provider-springboot/src/main/resources/org/apache/camel/springboot/catalog/dataformats/avroJackson.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
"title": "Avro Jackson",
66
"description": "Marshal POJOs to Avro and back using Jackson.",
77
"deprecated": false,
8-
"firstVersion": "4.19.0",
8+
"firstVersion": "3.10.0",
99
"label": "dataformat,transformation",
10-
"javaType": "org.apache.camel.component.jackson3.avro.JacksonAvroDataFormat",
11-
"supportLevel": "Preview",
10+
"javaType": "org.apache.camel.component.jackson.avro.JacksonAvroDataFormat",
11+
"supportLevel": "Stable",
1212
"groupId": "org.apache.camel.springboot",
13-
"artifactId": "camel-jackson3-avro-starter",
13+
"artifactId": "camel-jackson-avro-starter",
1414
"version": "4.21.0-SNAPSHOT",
1515
"modelName": "avro",
1616
"modelJavaType": "org.apache.camel.model.dataformat.AvroDataFormat"
@@ -25,10 +25,10 @@
2525
"allowJmsType": { "index": 6, "kind": "attribute", "displayName": "Allow Jms Type", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Used for JMS users to allow the JMSType header from the JMS spec to specify a FQN classname to use to unmarshal to." },
2626
"collectionType": { "index": 7, "kind": "attribute", "displayName": "Collection Type", "group": "advanced", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Refers to a custom collection type to lookup in the registry to use. This option should rarely be used, but allows to use different collection types than java.util.Collection based as default." },
2727
"useList": { "index": 8, "kind": "attribute", "displayName": "Use List", "group": "common", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "To unmarshal to a List of Map or a List of Pojo." },
28-
"moduleClassNames": { "index": 9, "kind": "attribute", "displayName": "Module Class Names", "group": "advanced", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "To use custom Jackson modules tools.jackson.databind.JacksonModule specified as a String with FQN class names. Multiple classes can be separated by comma." },
28+
"moduleClassNames": { "index": 9, "kind": "attribute", "displayName": "Module Class Names", "group": "advanced", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "To use custom Jackson modules com.fasterxml.jackson.databind.Module specified as a String with FQN class names. Multiple classes can be separated by comma." },
2929
"moduleRefs": { "index": 10, "kind": "attribute", "displayName": "Module Refs", "group": "advanced", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "To use custom Jackson modules referred from the Camel registry. Multiple modules can be separated by comma." },
30-
"enableFeatures": { "index": 11, "kind": "attribute", "displayName": "Enable Features", "group": "common", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Set of features to enable on the Jackson tools.jackson.databind.ObjectMapper. The features should be a name that matches a enum from tools.jackson.databind.SerializationFeature, tools.jackson.databind.DeserializationFeature, or tools.jackson.databind.MapperFeature Multiple features can be separated by comma" },
31-
"disableFeatures": { "index": 12, "kind": "attribute", "displayName": "Disable Features", "group": "common", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Set of features to disable on the Jackson tools.jackson.databind.ObjectMapper. The features should be a name that matches a enum from tools.jackson.databind.SerializationFeature, tools.jackson.databind.DeserializationFeature, or tools.jackson.databind.MapperFeature Multiple features can be separated by comma" },
30+
"enableFeatures": { "index": 11, "kind": "attribute", "displayName": "Enable Features", "group": "common", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Set of features to enable on the Jackson com.fasterxml.jackson.databind.ObjectMapper. The features should be a name that matches a enum from com.fasterxml.jackson.databind.SerializationFeature, com.fasterxml.jackson.databind.DeserializationFeature, or com.fasterxml.jackson.databind.MapperFeature Multiple features can be separated by comma" },
31+
"disableFeatures": { "index": 12, "kind": "attribute", "displayName": "Disable Features", "group": "common", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Set of features to disable on the Jackson com.fasterxml.jackson.databind.ObjectMapper. The features should be a name that matches a enum from com.fasterxml.jackson.databind.SerializationFeature, com.fasterxml.jackson.databind.DeserializationFeature, or com.fasterxml.jackson.databind.MapperFeature Multiple features can be separated by comma" },
3232
"allowUnmarshallType": { "index": 13, "kind": "attribute", "displayName": "Allow Unmarshall Type", "group": "common", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "If enabled then Jackson is allowed to attempt to use the CamelJacksonUnmarshalType header during the unmarshalling. This should only be enabled when desired to be used." },
3333
"timezone": { "index": 14, "kind": "attribute", "displayName": "Timezone", "group": "advanced", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "If set then Jackson will use the Timezone when marshalling\/unmarshalling." },
3434
"autoDiscoverObjectMapper": { "index": 15, "kind": "attribute", "displayName": "Auto Discover Object Mapper", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "If set to true then Jackson will lookup for an objectMapper into the registry" },

catalog/camel-catalog-provider-springboot/src/main/resources/org/apache/camel/springboot/catalog/transformers/avro-binary.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
"title": "Avro Binary",
66
"description": "Transforms from JSon to binary (byte array) using Jackson Avro (supports Avro schema)",
77
"deprecated": false,
8-
"javaType": "org.apache.camel.component.jackson3.avro.transform.AvroBinaryDataTypeTransformer",
8+
"javaType": "org.apache.camel.component.jackson.avro.transform.AvroBinaryDataTypeTransformer",
99
"groupId": "org.apache.camel.springboot",
10-
"artifactId": "camel-jackson3-avro-starter",
10+
"artifactId": "camel-jackson-avro-starter",
1111
"version": "4.21.0-SNAPSHOT"
1212
}
1313
}

catalog/camel-catalog-provider-springboot/src/main/resources/org/apache/camel/springboot/catalog/transformers/avro-x-java-object.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
"title": "Avro X Java Object",
66
"description": "Transforms from JSon to Java object using Jackson Avro (supports content schema)",
77
"deprecated": false,
8-
"javaType": "org.apache.camel.component.jackson3.avro.transform.AvroPojoDataTypeTransformer",
8+
"javaType": "org.apache.camel.component.jackson.avro.transform.AvroPojoDataTypeTransformer",
99
"groupId": "org.apache.camel.springboot",
10-
"artifactId": "camel-jackson3-avro-starter",
10+
"artifactId": "camel-jackson-avro-starter",
1111
"version": "4.21.0-SNAPSHOT"
1212
}
1313
}

catalog/camel-catalog-provider-springboot/src/main/resources/org/apache/camel/springboot/catalog/transformers/avro-x-struct.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
"title": "Avro X Struct",
66
"description": "Transforms to generic JSonNode using Jackson Avro (supports content schema)",
77
"deprecated": false,
8-
"javaType": "org.apache.camel.component.jackson3.avro.transform.AvroStructDataTypeTransformer",
8+
"javaType": "org.apache.camel.component.jackson.avro.transform.AvroStructDataTypeTransformer",
99
"groupId": "org.apache.camel.springboot",
10-
"artifactId": "camel-jackson3-avro-starter",
10+
"artifactId": "camel-jackson-avro-starter",
1111
"version": "4.21.0-SNAPSHOT"
1212
}
1313
}

components-starter/camel-bean-starter/src/main/java/org/apache/camel/language/bean/springboot/BeanLanguageAutoConfiguration.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ public org.apache.camel.spi.LanguageCustomizer configureBeanLanguage() {
6060
return new LanguageCustomizer() {
6161
@Override
6262
public void configure(String name, Language target) {
63-
CamelPropertiesHelper.copyProperties(((org.apache.camel.CamelContextAware) target).getCamelContext(), configuration, target);
63+
if (target instanceof CamelContextAware cca && cca.getCamelContext() != null) {
64+
CamelPropertiesHelper.copyProperties(cca.getCamelContext(), configuration, target);
65+
}
6466
}
6567
@Override
6668
public boolean isEnabled(String name, Language target) {

components-starter/camel-core-starter/src/main/java/org/apache/camel/language/constant/springboot/ConstantLanguageAutoConfiguration.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ public org.apache.camel.spi.LanguageCustomizer configureConstantLanguage() {
6060
return new LanguageCustomizer() {
6161
@Override
6262
public void configure(String name, Language target) {
63-
CamelPropertiesHelper.copyProperties(((org.apache.camel.CamelContextAware) target).getCamelContext(), configuration, target);
63+
if (target instanceof CamelContextAware cca && cca.getCamelContext() != null) {
64+
CamelPropertiesHelper.copyProperties(cca.getCamelContext(), configuration, target);
65+
}
6466
}
6567
@Override
6668
public boolean isEnabled(String name, Language target) {

components-starter/camel-core-starter/src/main/java/org/apache/camel/language/csimple/springboot/CSimpleLanguageAutoConfiguration.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ public org.apache.camel.spi.LanguageCustomizer configureCSimpleLanguage() {
6060
return new LanguageCustomizer() {
6161
@Override
6262
public void configure(String name, Language target) {
63-
CamelPropertiesHelper.copyProperties(((org.apache.camel.CamelContextAware) target).getCamelContext(), configuration, target);
63+
if (target instanceof CamelContextAware cca && cca.getCamelContext() != null) {
64+
CamelPropertiesHelper.copyProperties(cca.getCamelContext(), configuration, target);
65+
}
6466
}
6567
@Override
6668
public boolean isEnabled(String name, Language target) {

components-starter/camel-core-starter/src/main/java/org/apache/camel/language/header/springboot/HeaderLanguageAutoConfiguration.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ public org.apache.camel.spi.LanguageCustomizer configureHeaderLanguage() {
6060
return new LanguageCustomizer() {
6161
@Override
6262
public void configure(String name, Language target) {
63-
CamelPropertiesHelper.copyProperties(((org.apache.camel.CamelContextAware) target).getCamelContext(), configuration, target);
63+
if (target instanceof CamelContextAware cca && cca.getCamelContext() != null) {
64+
CamelPropertiesHelper.copyProperties(cca.getCamelContext(), configuration, target);
65+
}
6466
}
6567
@Override
6668
public boolean isEnabled(String name, Language target) {

components-starter/camel-core-starter/src/main/java/org/apache/camel/language/property/springboot/ExchangePropertyLanguageAutoConfiguration.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ public org.apache.camel.spi.LanguageCustomizer configureExchangePropertyLanguage
6060
return new LanguageCustomizer() {
6161
@Override
6262
public void configure(String name, Language target) {
63-
CamelPropertiesHelper.copyProperties(((org.apache.camel.CamelContextAware) target).getCamelContext(), configuration, target);
63+
if (target instanceof CamelContextAware cca && cca.getCamelContext() != null) {
64+
CamelPropertiesHelper.copyProperties(cca.getCamelContext(), configuration, target);
65+
}
6466
}
6567
@Override
6668
public boolean isEnabled(String name, Language target) {

components-starter/camel-core-starter/src/main/java/org/apache/camel/language/ref/springboot/RefLanguageAutoConfiguration.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ public org.apache.camel.spi.LanguageCustomizer configureRefLanguage() {
6060
return new LanguageCustomizer() {
6161
@Override
6262
public void configure(String name, Language target) {
63-
CamelPropertiesHelper.copyProperties(((org.apache.camel.CamelContextAware) target).getCamelContext(), configuration, target);
63+
if (target instanceof CamelContextAware cca && cca.getCamelContext() != null) {
64+
CamelPropertiesHelper.copyProperties(cca.getCamelContext(), configuration, target);
65+
}
6466
}
6567
@Override
6668
public boolean isEnabled(String name, Language target) {

0 commit comments

Comments
 (0)