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

Post Camel 3.2.0 upgrade fixes #1063

Merged
merged 16 commits into from
Apr 9, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/pr-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,10 @@ jobs:
servicenow
slack
- category: SQL
# TODO: re-add mongodb
test-modules: >
couchdb
jdbc
mongodb
sql
- category: Social
test-modules: >
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem;
import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;
import io.quarkus.deployment.builditem.nativeimage.ReflectiveMethodBuildItem;
import io.quarkus.deployment.builditem.nativeimage.RuntimeReinitializedClassBuildItem;
import org.apache.camel.CamelContext;
import org.apache.camel.Component;
import org.apache.camel.Consumer;
Expand Down Expand Up @@ -86,7 +85,7 @@ public static class Core {
PropertiesComponent.class,
DataFormat.class);

// @BuildStep
@BuildStep
void reflectiveItems(
CombinedIndexBuildItem combinedIndex,
BuildProducer<ReflectiveClassBuildItem> reflectiveClass,
Expand Down Expand Up @@ -139,7 +138,7 @@ void reflectiveItems(

}

// @BuildStep
@BuildStep
void camelServices(
List<CamelServiceBuildItem> camelServices,
BuildProducer<ReflectiveClassBuildItem> reflectiveClass) {
Expand Down Expand Up @@ -293,7 +292,9 @@ void process(
//
camelRoutesBuilders.forEach(camelRoutesBuilderClassBuildItem -> {
reflectiveClass.produce(
new ReflectiveClassBuildItem(false, false, camelRoutesBuilderClassBuildItem.getDotName().toString()));
// Register fields and methods as they may be used by the bean post processor to
// properly support @BindToRegistry
new ReflectiveClassBuildItem(true, true, camelRoutesBuilderClassBuildItem.getDotName().toString()));
});

// reflectiveClass.produce(new ReflectiveClassBuildItem(
Expand All @@ -315,17 +316,4 @@ void process(
org.apache.camel.spi.RestConfiguration.class));
}
}

@BuildStep
void process(BuildProducer<RuntimeReinitializedClassBuildItem> reinitialized) {
for (String s : Arrays.asList(
"sun.security.jca.JCAUtil",
"sun.security.jca.JCAUtil$CachedSecureRandomHolder",
"sun.security.provider.SecureRandom$SeederHolder",
"sun.security.provider.SeedGenerator",
"java.security.SecureRandom",
"java.net.DefaultDatagramSocketImplFactory")) {
reinitialized.produce(new RuntimeReinitializedClassBuildItem(s));
}
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* 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.avro;

import io.quarkus.runtime.RuntimeValue;
Expand Down
2 changes: 1 addition & 1 deletion extensions-jvm/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
<module>aws2-translate</module>
<module>cassandraql</module>
<module>couchbase</module>
<module>debezium-mongodb</module>
<!--module>debezium-mongodb</module-->
lburgazzoli marked this conversation as resolved.
Show resolved Hide resolved
<module>debezium-mysql</module>
<module>debezium-postgres</module>
<module>debezium-sqlserver</module>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,48 @@
import io.quarkus.deployment.builditem.GeneratedClassBuildItem;
import io.quarkus.deployment.pkg.steps.NativeBuild;
import io.quarkus.gizmo.ClassCreator;
import io.quarkus.gizmo.ClassOutput;

public class SpringProcessor {

@BuildStep(onlyIf = NativeBuild.class)
void generateKParameterClass(BuildProducer<GeneratedClassBuildItem> generatedClass) {
// TODO: Investigate removing this. See https://github.com/apache/camel-quarkus/issues/534
// The native image build fails with a NoClassDefFoundError without this. Possibly similar to https://github.com/oracle/graal/issues/656.
ClassOutput classOutput = new GeneratedClassGizmoAdaptor(generatedClass, false);
ClassCreator.builder()
.className("kotlin.reflect.KParameter")
.classOutput(classOutput)
.setFinal(true)
.superClass(Object.class)
.build()
.close();

try {
Class.forName("kotlin.reflect.KParameter");
} catch (ClassNotFoundException e) {
ClassCreator.builder()
.className("kotlin.reflect.KParameter")
.classOutput(new GeneratedClassGizmoAdaptor(generatedClass, false))
.setFinal(true)
.superClass(Object.class)
.build()
.close();
}

try {
Class.forName("kotlin.reflect.KCallable");
} catch (ClassNotFoundException e) {
ClassCreator.builder()
.className("kotlin.reflect.KCallable")
.classOutput(new GeneratedClassGizmoAdaptor(generatedClass, false))
.setFinal(false)
.superClass(Object.class)
.build()
.close();
}

try {
Class.forName("kotlin.reflect.KFunction");
} catch (ClassNotFoundException e) {
ClassCreator.builder()
.className("kotlin.reflect.KFunction")
.classOutput(new GeneratedClassGizmoAdaptor(generatedClass, false))
.setFinal(false)
.superClass("kotlin.reflect.KCallable")
.build()
.close();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import com.oracle.svm.core.annotate.Delete;
import com.oracle.svm.core.annotate.Substitute;
import com.oracle.svm.core.annotate.TargetClass;
import org.springframework.core.KotlinDetector;
import org.springframework.core.MethodParameter;
import org.springframework.core.io.Resource;
import org.springframework.util.PathMatcher;
Expand All @@ -45,6 +46,25 @@ public SubstituteDefaultParameterNameDiscoverer() {
}
}

@TargetClass(KotlinDetector.class)
@Substitute
final class SubstituteKotlinDetector {
@Substitute
public static boolean isKotlinPresent() {
return false;
}

@Substitute
public static boolean isKotlinReflectPresent() {
return false;
}

@Substitute
public static boolean isKotlinType(Class<?> clazz) {
return false;
}
}

@TargetClass(className = "org.springframework.core.KotlinReflectionParameterNameDiscoverer")
@Delete
final class SubstituteKotlinReflectionParameterNameDiscoverer {
Expand Down
8 changes: 8 additions & 0 deletions extensions/activemq/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-activemq</artifactId>
<!-- remove broker as it brings some classes that brak native compilation -->
<!-- we should investigate how to substitue JMX on ActiveMQ -->
<exclusions>
<exclusion>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-broker</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.graalvm.nativeimage</groupId>
Expand Down
3 changes: 1 addition & 2 deletions extensions/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@
<module>mail</module>
<module>microprofile-health</module>
<module>microprofile-metrics</module>
<!-- Disable MongoDB until quarkus uses mongbd 4.x -->
<!-- <module>mongodb</module>-->
<!-- <module>mongodb</module>-->
lburgazzoli marked this conversation as resolved.
Show resolved Hide resolved
<module>mustache</module>
<module>netty</module>
<module>netty-http</module>
Expand Down
7 changes: 1 addition & 6 deletions integration-tests/activemq/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,7 @@
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-integration-test-support</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-kahadb-store</artifactId>
<artifactId>camel-quarkus-integration-testcontainers-support</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,67 +17,53 @@

package org.apache.camel.quarkus.component.activemq.it;

import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Collections;
import java.util.Comparator;
import java.util.Map;

import io.quarkus.test.common.QuarkusTestResourceLifecycleManager;
import org.apache.activemq.broker.BrokerService;
import org.apache.activemq.broker.TransportConnector;
import org.apache.camel.quarkus.test.AvailablePortFinder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.output.Slf4jLogConsumer;
import org.testcontainers.containers.wait.strategy.Wait;
import org.testcontainers.utility.TestcontainersConfiguration;

public class ActiveMQTestResource implements QuarkusTestResourceLifecycleManager {
private static final Logger LOGGER = LoggerFactory.getLogger(ActiveMQTestResource.class);
private BrokerService broker;

private static final String ACTIVEMQ_IMAGE = "rmohr/activemq:5.15.9-alpine";
private static final int TCP_PORT = 61616;

private GenericContainer<?> container;

@Override
public Map<String, String> start() {
try {
final int port = AvailablePortFinder.getNextAvailable();
final String brokerUrl = String.format("tcp://127.0.0.1:%d", port);
final File dataDirectory = Files.createTempDirectory("activemq-data-").toFile();
LOGGER.info(TestcontainersConfiguration.getInstance().toString());

TransportConnector connector = new TransportConnector();
connector.setUri(new URI(brokerUrl));
try {
container = new GenericContainer<>(ACTIVEMQ_IMAGE)
.withExposedPorts(TCP_PORT)
.withLogConsumer(new Slf4jLogConsumer(LOGGER))
.waitingFor(Wait.forListeningPort());

broker = new BrokerService();
broker.addConnector(connector);
broker.setDataDirectoryFile(dataDirectory);
broker.start();
container.start();

return Collections.singletonMap("camel.component.activemq.brokerUrl", brokerUrl);
return Collections.singletonMap(
"camel.component.activemq.brokerUrl",
String.format("tcp://%s:%d", container.getContainerIpAddress(), container.getMappedPort(TCP_PORT)));
} catch (Exception e) {
LOGGER.error("Starting the ActiveMQ broker with exception.", e);
throw new RuntimeException("Starting the ActiveMQ broker with exception.", e);
throw new RuntimeException(e);
}
}

@Override
public void stop() {
try {
if (broker != null) {
broker.stop();
if (container != null) {
container.stop();
}
} catch (Exception e) {
LOGGER.error("Stopping the ActiveMQ broker with exception.", e);
}

try {
if (broker != null) {
Files.walk(broker.getDataDirectoryFile().toPath())
.sorted(Comparator.reverseOrder())
.map(Path::toFile)
.forEach(File::delete);
}
} catch (IOException e) {
LOGGER.error("Error cleaning up ActiveMQ data directory", e);
// ignored
}
}
}
46 changes: 0 additions & 46 deletions integration-tests/infinispan/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -101,52 +101,6 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>groovy-maven-plugin</artifactId>
<executions>
<execution>
<id>sanity-checks</id>
<goals>
<goal>execute</goal>
</goals>
<!--
temporary disable version checking as we need to force jackson version here

TODO: remove
-->
<phase />
</execution>
</executions>
</plugin>
<!--
temporary disable enforcer as otherwise the build fails for dependency convergence like:

+-org.apache.camel.quarkus:camel-quarkus-integration-test-infinispan:0.4.1-SNAPSHOT
+-io.quarkus:quarkus-resteasy:1.0.0.CR2
+-io.quarkus:quarkus-vertx-http:1.0.0.CR2
+-io.quarkus:quarkus-vertx-core:1.0.0.CR2
+-io.vertx:vertx-core:3.8.3
+-com.fasterxml.jackson.core:jackson-core:2.9.10
and
+-org.apache.camel.quarkus:camel-quarkus-integration-test-infinispan:0.4.1-SNAPSHOT
+-org.infinispan:infinispan-server-hotrod:10.0.0.Final
+-org.infinispan:infinispan-server-core:10.0.0.Final
+-com.fasterxml.jackson.core:jackson-core:2.9.10
and
+-org.apache.camel.quarkus:camel-quarkus-integration-test-infinispan:0.4.1-SNAPSHOT
+-com.fasterxml.jackson.core:jackson-core:2.10.0


TODO: remove
-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>

Expand Down
3 changes: 1 addition & 2 deletions integration-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@
<module>mail</module>
<module>messaging</module>
<module>microprofile</module>
<!-- Disable MongoDB until quarkus uses mongbd 4.x -->
<!-- <module>mongodb</module>-->
<!-- <module>mongodb</module>-->
<module>mustache</module>
<module>netty</module>
<module>olingo4</module>
Expand Down