This is an automated email from the ASF dual-hosted git repository. acosentino pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
The following commit(s) were added to refs/heads/master by this push: new f675b1b Fix #1314 Make Kudu native test runnable on Quarkus Platform on Java 8 and 11 new 929a7a3 Merge pull request #1318 from ppalaga/i1314 f675b1b is described below commit f675b1b2f843aab591e3ef46c59ccea12c055660 Author: Peter Palaga <ppal...@redhat.com> AuthorDate: Mon Jun 8 15:14:32 2020 +0200 Fix #1314 Make Kudu native test runnable on Quarkus Platform on Java 8 and 11 --- integration-tests/kudu/pom.xml | 18 ----------- .../kudu/it/KuduInfrastructureTestHelper.java | 35 +++++++++++++--------- .../src/main/resources/reflection-config-jdk8.json | 10 ------- .../resources/reflection-config-jdk9-onward.json | 6 ---- .../camel/quarkus/component/kudu/it/KuduIT.java | 5 ---- .../camel/quarkus/component/kudu/it/KuduTest.java | 5 ---- 6 files changed, 21 insertions(+), 58 deletions(-) diff --git a/integration-tests/kudu/pom.xml b/integration-tests/kudu/pom.xml index 822d23d..00cae31 100644 --- a/integration-tests/kudu/pom.xml +++ b/integration-tests/kudu/pom.xml @@ -124,23 +124,5 @@ </plugins> </build> </profile> - <profile> - <id>kudu-native-java9-onward</id> - <activation> - <jdk>[9,)</jdk> - </activation> - <properties> - <quarkus.native.additional-build-args>-H:ReflectionConfigurationFiles=reflection-config-jdk9-onward.json</quarkus.native.additional-build-args> - </properties> - </profile> - <profile> - <id>kudu-native-java8</id> - <activation> - <jdk>1.8</jdk> - </activation> - <properties> - <quarkus.native.additional-build-args>-H:ReflectionConfigurationFiles=reflection-config-jdk8.json</quarkus.native.additional-build-args> - </properties> - </profile> </profiles> </project> diff --git a/integration-tests/kudu/src/main/java/org/apache/camel/quarkus/component/kudu/it/KuduInfrastructureTestHelper.java b/integration-tests/kudu/src/main/java/org/apache/camel/quarkus/component/kudu/it/KuduInfrastructureTestHelper.java index 1551e1f..0e3308c 100644 --- a/integration-tests/kudu/src/main/java/org/apache/camel/quarkus/component/kudu/it/KuduInfrastructureTestHelper.java +++ b/integration-tests/kudu/src/main/java/org/apache/camel/quarkus/component/kudu/it/KuduInfrastructureTestHelper.java @@ -19,6 +19,7 @@ package org.apache.camel.quarkus.component.kudu.it; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.net.InetAddress; +import java.util.concurrent.ConcurrentHashMap; import javax.enterprise.context.ApplicationScoped; import javax.enterprise.event.Observes; @@ -74,20 +75,26 @@ public class KuduInfrastructureTestHelper { public static void overrideTabletServerHostnameResolution() { try { - // Warm up the InetAddress cache - InetAddress.getByName("localhost"); - Field cacheField = InetAddress.class.getDeclaredField("cache"); - cacheField.setAccessible(true); - Object cache = cacheField.get(null); - - Method get = cache.getClass().getMethod("get", Object.class); - Object localHostCachedAddresses = get.invoke(cache, "localhost"); - - Method put = cache.getClass().getMethod("put", Object.class, Object.class); - put.invoke(cache, KUDU_TABLET_SERVER_HOSTNAME, localHostCachedAddresses); - } catch (Exception ex) { - final String msg = "An issue occurred while attempting the Open JDK9+ override of the kudu tablet server hostname resolution"; - LOG.warn(msg, ex); + if (System.getProperty("java.version").startsWith("1.8")) { + /* Warm up the InetAddress cache and get localhost addresses */ + final InetAddress[] localHostCachedAddresses = InetAddress.getAllByName("localhost"); + final Method cacheAddressesMethod = InetAddress.class.getDeclaredMethod("cacheAddresses", String.class, + InetAddress[].class, boolean.class); + cacheAddressesMethod.setAccessible(true); + cacheAddressesMethod.invoke(null, KUDU_TABLET_SERVER_HOSTNAME, localHostCachedAddresses, true); + } else { + // Warm up the InetAddress cache + InetAddress.getByName("localhost"); + final Field cacheField = InetAddress.class.getDeclaredField("cache"); + cacheField.setAccessible(true); + final Object cache = cacheField.get(null); + final Method get = ConcurrentHashMap.class.getMethod("get", Object.class); + final Object localHostCachedAddresses = get.invoke(cache, "localhost"); + final Method put = ConcurrentHashMap.class.getMethod("put", Object.class, Object.class); + put.invoke(cache, KUDU_TABLET_SERVER_HOSTNAME, localHostCachedAddresses); + } + } catch (Exception e) { + throw new IllegalStateException("Could not hack the kudu tablet server hostname resolution", e); } } } diff --git a/integration-tests/kudu/src/main/resources/reflection-config-jdk8.json b/integration-tests/kudu/src/main/resources/reflection-config-jdk8.json deleted file mode 100644 index 7281bba..0000000 --- a/integration-tests/kudu/src/main/resources/reflection-config-jdk8.json +++ /dev/null @@ -1,10 +0,0 @@ -[ - { - "name" : "java.net.InetAddress", - "allDeclaredFields" : true - }, - { - "name" : "java.net.InetAddress$Cache", - "allDeclaredMethods" : true - } -] \ No newline at end of file diff --git a/integration-tests/kudu/src/main/resources/reflection-config-jdk9-onward.json b/integration-tests/kudu/src/main/resources/reflection-config-jdk9-onward.json deleted file mode 100644 index 63d1df7..0000000 --- a/integration-tests/kudu/src/main/resources/reflection-config-jdk9-onward.json +++ /dev/null @@ -1,6 +0,0 @@ -[ - { - "name" : "java.util.concurrent.ConcurrentHashMap", - "allDeclaredMethods" : true - } -] \ No newline at end of file diff --git a/integration-tests/kudu/src/test/java/org/apache/camel/quarkus/component/kudu/it/KuduIT.java b/integration-tests/kudu/src/test/java/org/apache/camel/quarkus/component/kudu/it/KuduIT.java index 8bf9fad..2a6eda3 100644 --- a/integration-tests/kudu/src/test/java/org/apache/camel/quarkus/component/kudu/it/KuduIT.java +++ b/integration-tests/kudu/src/test/java/org/apache/camel/quarkus/component/kudu/it/KuduIT.java @@ -17,13 +17,8 @@ package org.apache.camel.quarkus.component.kudu.it; import io.quarkus.test.junit.NativeImageTest; -import org.junit.jupiter.api.condition.DisabledOnJre; -import org.junit.jupiter.api.condition.EnabledIfSystemProperty; -import org.junit.jupiter.api.condition.JRE; @NativeImageTest -@EnabledIfSystemProperty(named = "java.runtime.name", matches = ".*OpenJDK.*") -@DisabledOnJre(JRE.JAVA_8) class KuduIT extends KuduTest { } diff --git a/integration-tests/kudu/src/test/java/org/apache/camel/quarkus/component/kudu/it/KuduTest.java b/integration-tests/kudu/src/test/java/org/apache/camel/quarkus/component/kudu/it/KuduTest.java index 068d39a..ea5b2db 100644 --- a/integration-tests/kudu/src/test/java/org/apache/camel/quarkus/component/kudu/it/KuduTest.java +++ b/integration-tests/kudu/src/test/java/org/apache/camel/quarkus/component/kudu/it/KuduTest.java @@ -32,9 +32,6 @@ import org.junit.jupiter.api.MethodOrderer.OrderAnnotation; import org.junit.jupiter.api.Order; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestMethodOrder; -import org.junit.jupiter.api.condition.DisabledOnJre; -import org.junit.jupiter.api.condition.EnabledIfSystemProperty; -import org.junit.jupiter.api.condition.JRE; import static org.apache.camel.quarkus.component.kudu.it.KuduInfrastructureTestHelper.KUDU_AUTHORITY_CONFIG_KEY; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -43,8 +40,6 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; @QuarkusTestResource(KuduTestResource.class) @QuarkusTest @TestMethodOrder(OrderAnnotation.class) -@EnabledIfSystemProperty(named = "java.runtime.name", matches = ".*OpenJDK.*") -@DisabledOnJre(JRE.JAVA_8) class KuduTest { private static final Logger LOG = Logger.getLogger(KuduTest.class);