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

Upgrade Camel to 4.3.0 #5607

Merged
merged 2 commits into from
Jan 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/antora.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ asciidoc:
requires: "'util=camel-website-util,quarkus=xref:js/quarkus.js'"

# Project versions
camel-version: 4.2.0 # replace ${camel.version}
camel-version: 4.3.0 # replace ${camel.version}
camel-docs-version: 4.0.x
camel-quarkus-version: 3.7.0 # replace ${camel-quarkus.version}
quarkus-version: 3.6.4 # replace ${quarkus.version}
Expand Down
13 changes: 13 additions & 0 deletions docs/modules/ROOT/examples/components/kubernetes-cronjob.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Do not edit directly!
# This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page
cqArtifactId: camel-quarkus-kubernetes
cqArtifactIdBase: kubernetes
cqNativeSupported: true
cqStatus: Stable
cqDeprecated: false
cqJvmSince: 1.0.0
cqNativeSince: 1.0.0
cqCamelPartName: kubernetes-cronjob
cqCamelPartTitle: Kubernetes Cronjob
cqCamelPartDescription: Perform operations on Kubernetes CronJob.
cqExtensionPageTitle: Kubernetes
13 changes: 13 additions & 0 deletions docs/modules/ROOT/examples/languages/java.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Do not edit directly!
# This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page
cqArtifactId: camel-quarkus-joor
cqArtifactIdBase: joor
cqNativeSupported: true
cqStatus: Stable
cqDeprecated: true
cqJvmSince: 2.0.0
cqNativeSince: 3.2.0
cqCamelPartName: java
cqCamelPartTitle: Java
cqCamelPartDescription: Evaluates a Java (Java compiled once at runtime) expression.
cqExtensionPageTitle: jOOR
2 changes: 1 addition & 1 deletion docs/modules/ROOT/examples/languages/joor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ cqArtifactId: camel-quarkus-joor
cqArtifactIdBase: joor
cqNativeSupported: true
cqStatus: Stable
cqDeprecated: false
cqDeprecated: true
cqJvmSince: 2.0.0
cqNativeSince: 3.2.0
cqCamelPartName: joor
Expand Down
2 changes: 1 addition & 1 deletion docs/modules/ROOT/examples/others/aws-xray.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ cqJvmSince: 1.2.0
cqNativeSince: n/a
cqCamelPartName: aws-xray
cqCamelPartTitle: AWS XRay
cqCamelPartDescription: Distributed tracing using AWS XRay
cqCamelPartDescription: Enable Distributed tracing using AWS XRay
cqExtensionPageTitle: AWS XRay
6 changes: 0 additions & 6 deletions docs/modules/ROOT/pages/reference/extensions/jolt.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,6 @@ ifeval::[{doc-show-user-guide-link} == true]
Check the xref:user-guide/index.adoc[User guide] for more information about writing Camel Quarkus applications.
endif::[]

[id="extensions-jolt-allowcontextmapall-option-in-native-mode"]
== allowContextMapAll option in native mode

The `allowContextMapAll` option is not supported in native mode as it requires reflective access to security sensitive camel core classes such as
`CamelContext` & `Exchange`. This is considered a security risk and thus access to the feature is not provided by default.

[id="extensions-jolt-additional-camel-quarkus-configuration"]
== Additional Camel Quarkus configuration

Expand Down
9 changes: 5 additions & 4 deletions docs/modules/ROOT/pages/reference/extensions/joor.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,26 @@
:cq-artifact-id: camel-quarkus-joor
:cq-native-supported: true
:cq-status: Stable
:cq-status-deprecation: Stable
:cq-status-deprecation: Stable Deprecated
:cq-description: Evaluate a jOOR (Java compiled once at runtime) expression language.
:cq-deprecated: false
:cq-deprecated: true
:cq-jvm-since: 2.0.0
:cq-native-since: 3.2.0

ifeval::[{doc-show-badges} == true]
[.badges]
[.badge-key]##JVM since##[.badge-supported]##2.0.0## [.badge-key]##Native since##[.badge-supported]##3.2.0##
[.badge-key]##JVM since##[.badge-supported]##2.0.0## [.badge-key]##Native since##[.badge-supported]##3.2.0## [.badge-key]##⚠️##[.badge-unsupported]##Deprecated##
endif::[]

Evaluate a jOOR (Java compiled once at runtime) expression language.

[id="extensions-joor-whats-inside"]
== What's inside

* xref:{cq-camel-components}:languages:java-language.adoc[Java language]
* xref:{cq-camel-components}:languages:joor-language.adoc[jOOR language]

Please refer to the above link for usage and configuration details.
Please refer to the above links for usage and configuration details.

[id="extensions-joor-maven-coordinates"]
== Maven coordinates
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Perform operations against Kubernetes API
== What's inside

* xref:{cq-camel-components}::kubernetes-config-maps-component.adoc[Kubernetes ConfigMap component], URI syntax: `kubernetes-config-maps:masterUrl`
* xref:{cq-camel-components}::kubernetes-cronjob-component.adoc[Kubernetes Cronjob component], URI syntax: `kubernetes-cronjob:masterUrl`
* xref:{cq-camel-components}::kubernetes-custom-resources-component.adoc[Kubernetes Custom Resources component], URI syntax: `kubernetes-custom-resources:masterUrl`
* xref:{cq-camel-components}::kubernetes-deployments-component.adoc[Kubernetes Deployments component], URI syntax: `kubernetes-deployments:masterUrl`
* xref:{cq-camel-components}::kubernetes-events-component.adoc[Kubernetes Event component], URI syntax: `kubernetes-events:masterUrl`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ void generateKotlinReflectClasses(
createClass(generatedClass, "kotlin.reflect.KParameter", Object.class.getName(), true);
createClass(generatedClass, "kotlin.reflect.KCallable", Object.class.getName(), false);
createClass(generatedClass, "kotlin.reflect.KFunction", "kotlin.reflect.KCallable", false);
createClass(generatedClass, "kotlin.reflect.KAnnotatedElement", Object.class.getName(), false);
createClass(generatedClass, "kotlin.reflect.KClass", "kotlin.reflect.KAnnotatedElement", false);
createClass(generatedClass, "kotlin.text.Regex", Object.class.getName(), false);
createClass(generatedClass, "kotlin.coroutines.CoroutineContext$Key", Object.class.getName(), false);
createClass(generatedClass, "kotlinx.coroutines.Job$Key", "kotlin.coroutines.CoroutineContext$Key", false);
}

private boolean isKotlinStdlibAvailable(ApplicationModel applicationModel) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Type;
import java.util.function.BooleanSupplier;

import com.oracle.svm.core.annotate.Delete;
import com.oracle.svm.core.annotate.Substitute;
Expand All @@ -46,6 +47,11 @@ public static boolean isKotlinReflectPresent() {
public static boolean isKotlinType(Class<?> clazz) {
return false;
}

@Substitute
public static boolean isSuspendingFunction(Method method) {
return false;
}
}

@TargetClass(className = "org.springframework.core.KotlinReflectionParameterNameDiscoverer")
Expand Down Expand Up @@ -84,3 +90,23 @@ private static Class<?> getReturnType(Method method) {
throw new UnsupportedOperationException("Kotlin is not supported");
}
}

@TargetClass(className = "org.springframework.aop.support.AopUtils$KotlinDelegate", onlyWith = SpringAopPresent.class)
final class SubstituteAopUtilsKotlinDelegate {
@Substitute
public static Object invokeSuspendingFunction(Method method, Object target, Object... args) {
throw new UnsupportedOperationException("Kotlin is not supported");
}
}

final class SpringAopPresent implements BooleanSupplier {
@Override
public boolean getAsBoolean() {
try {
Thread.currentThread().getContextClassLoader().loadClass("org.springframework.aop.support.AopUtils");
return true;
} catch (ClassNotFoundException e) {
return false;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,6 @@ public SubstituteDefaultParameterNameDiscoverer() {
final class SubstituteStandardReflectionParameterNameDiscoverer {
}

@TargetClass(className = "org.springframework.core.LocalVariableTableParameterNameDiscoverer")
@Delete
final class SubstituteLocalVariableTableParameterNameDiscoverer {
}

@TargetClass(className = "org.springframework.core.io.VfsUtils")
@Delete
final class SubstituteVfsUtils {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
import static org.apache.camel.quarkus.component.fhir.deployment.FhirUtil.getResourceDefinitions;

public class FhirR4Processor {
private static final String FHIR_VERSION_PROPERTIES = "org/hl7/fhir/r4/model/fhirversion.properties";
private static final String FHIR_VERSION_PROPERTIES = "org/hl7/fhir/r4/hapi/model/fhirversion.properties";

@BuildStep(onlyIf = FhirFlags.R4Enabled.class)
R4PropertiesBuildItem fhirProperties() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@
import org.apache.camel.dsl.java.joor.CompilationUnit;
import org.apache.camel.dsl.java.joor.MultiCompile;
import org.apache.camel.impl.DefaultCamelContext;
import org.apache.camel.language.joor.JavaLanguage;
import org.apache.camel.language.joor.JoorCompiler;
import org.apache.camel.language.joor.JoorExpression;
import org.apache.camel.language.joor.JoorLanguage;
import org.apache.camel.language.joor.JoorScriptingCompiler;
import org.apache.camel.quarkus.component.joor.runtime.JoorExpressionCompiler;
import org.apache.camel.quarkus.component.joor.runtime.JoorExpressionConfig;
Expand Down Expand Up @@ -76,17 +76,17 @@ void collectExpressions(JoorExpressionConfig config,
BuildProducer<JoorExpressionSourceBuildItem> producer) throws Exception {
if (result.isSuccess()) {
List<ExpressionBuildItem> joorExpressions = expressions.stream()
.filter(exp -> "joor".equals(exp.getLanguage()))
.filter(exp -> "java".equals(exp.getLanguage()))
.collect(Collectors.toList());
List<ScriptBuildItem> joorScripts = scripts.stream()
.filter(exp -> "joor".equals(exp.getLanguage()))
.filter(exp -> "java".equals(exp.getLanguage()))
.collect(Collectors.toList());
if (joorExpressions.isEmpty() && joorScripts.isEmpty()) {
return;
}
// Don't close it as it won't be started and some log entries are added on close/stop
CamelContext ctx = new DefaultCamelContext();
try (JoorLanguage language = new JoorLanguage()) {
try (JavaLanguage language = new JavaLanguage()) {
language.setCamelContext(ctx);
language.setSingleQuotes(config.singleQuotes);
config.configResource.ifPresent(language::setConfigResource);
Expand Down Expand Up @@ -183,7 +183,7 @@ CamelBeanBuildItem configureLanguage(
source.getClassName());
}
}
final RuntimeValue<JoorLanguage> language = recorder.languageNewInstance(config, expressionCompilerBuilder,
final RuntimeValue<JavaLanguage> language = recorder.languageNewInstance(config, expressionCompilerBuilder,
expressionScriptingCompilerBuilder);

if (config.resultType.isPresent()) {
Expand All @@ -192,7 +192,7 @@ CamelBeanBuildItem configureLanguage(
config.resultType.get());
}

return new CamelBeanBuildItem("joor", JoorLanguage.class.getName(), language);
return new CamelBeanBuildItem("java", JavaLanguage.class.getName(), language);
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,24 @@
import io.quarkus.runtime.RuntimeValue;
import io.quarkus.runtime.annotations.Recorder;
import org.apache.camel.CamelContext;
import org.apache.camel.language.joor.JoorLanguage;
import org.apache.camel.language.joor.JavaLanguage;
import org.apache.camel.language.joor.JoorMethod;
import org.apache.camel.language.joor.JoorScriptingMethod;

@Recorder
public class JoorExpressionRecorder {

public RuntimeValue<JoorLanguage> languageNewInstance(JoorExpressionConfig config,
public RuntimeValue<JavaLanguage> languageNewInstance(JoorExpressionConfig config,
RuntimeValue<JoorExpressionCompiler.Builder> compilerBuilder,
RuntimeValue<JoorExpressionScriptingCompiler.Builder> scriptingCompilerBuilder) {
RuntimeValue<JoorLanguage> language = new RuntimeValue<>(
new JoorLanguage(compilerBuilder.getValue().build(), scriptingCompilerBuilder.getValue().build()));
RuntimeValue<JavaLanguage> language = new RuntimeValue<>(
new JavaLanguage(compilerBuilder.getValue().build(), scriptingCompilerBuilder.getValue().build()));
language.getValue().setSingleQuotes(config.singleQuotes);
config.configResource.ifPresent(language.getValue()::setConfigResource);
return language;
}

public void setResultType(RuntimeValue<JoorLanguage> language, String className) {
public void setResultType(RuntimeValue<JavaLanguage> language, String className) {
try {
language.getValue().setResultType(Class.forName(className, true, Thread.currentThread().getContextClassLoader()));
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public void filterOpenAPI(OpenAPI openAPI) {
mapper.enable(SerializationFeature.INDENT_OUTPUT);
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);

String jsonContent = RestOpenApiSupport.getJsonFromOpenAPI(openApi, bc);
String jsonContent = RestOpenApiSupport.getJsonFromOpenAPIAsString(openApi, bc);
final JsonNode node = mapper.readTree(jsonContent);

OpenAPI oai = new OpenAPIImpl();
Expand Down
5 changes: 5 additions & 0 deletions integration-test-groups/foundation/eip/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<profiles>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,34 @@ public class EipResource {
@Inject
CamelContext context;

@Path("/routeAsync/{route}")
@POST
@Consumes(MediaType.TEXT_PLAIN)
@Produces(MediaType.TEXT_PLAIN)
public Response routeAsync(String statement, @PathParam("route") String route, @Context UriInfo uriInfo) {
return route(statement, route, uriInfo, true);
}

@Path("/route/{route}")
@POST
@Consumes(MediaType.TEXT_PLAIN)
@Produces(MediaType.TEXT_PLAIN)
public Response route(String statement, @PathParam("route") String route, @Context UriInfo uriInfo) {
public Response routeSync(String statement, @PathParam("route") String route, @Context UriInfo uriInfo) {
return route(statement, route, uriInfo, false);
}

public Response route(String statement, String route, @Context UriInfo uriInfo, boolean async) {
final Map<String, Object> headers = uriInfo.getQueryParameters().entrySet().stream()
.map(e -> new AbstractMap.SimpleImmutableEntry<String, Object>(e.getKey(), e.getValue().get(0)))
.collect(Collectors.toMap(Entry::getKey, Entry::getValue));
try {
if (async) {
producerTemplate.asyncRequestBodyAndHeaders("direct:" + route, statement, headers, String.class);
return Response.ok().build();
}

String result = producerTemplate.requestBodyAndHeaders("direct:" + route, statement, headers, String.class);
System.out.println("---- result for " + statement + " is " + result);
return Response.ok(result).build();
} catch (CamelExecutionException e) {
return Response.serverError().entity(e.getMessage()).build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
@ApplicationScoped
public class EipRoutes extends RouteBuilder {

public static final int THROTTLE_PERIOD = 500;
public static final int THROTTLE_TIMEOUT = 5000;
public static final int THROTTLE_MAXIMUM_REQUEST_COUNT = 2;
public static final int WEIGHTED_1 = 2;
public static final int WEIGHTED_2 = 1;
Expand Down Expand Up @@ -124,7 +124,8 @@ public void configure() {
.setBody(e -> "Hello from thread " + Thread.currentThread().getName());

from("direct:throttle")
.throttle(THROTTLE_MAXIMUM_REQUEST_COUNT).timePeriodMillis(THROTTLE_PERIOD).rejectExecution(true)
.throttle(THROTTLE_MAXIMUM_REQUEST_COUNT).rejectExecution(true).delay(THROTTLE_TIMEOUT)
.log("Sending '${body}' to mock throttle.")
.to("mock:throttle");

from("direct:tryCatchFinally")
Expand Down
Loading
Loading