You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by zb...@apache.org on 2021/11/17 16:02:05 UTC
[camel-quarkus] 01/03: Enable Atlasmap tests and fix loading URL resources in native mode fixes #3189
This is an automated email from the ASF dual-hosted git repository.
zbendhiba pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
commit 1a7f50be8f1cd30425d64589cf3f7c5c5cb2bb14
Author: Zineb Bendhiba <be...@gmail.com>
AuthorDate: Sat Nov 13 20:23:48 2021 +0100
Enable Atlasmap tests and fix loading URL resources in native mode
fixes #3189
---
.../component/atlasmap/graalvm/Substitutions.java | 34 +++++++++++++++++++++-
.../quarkus/component/atlasmap/it/AtlasmapIT.java | 3 +-
2 files changed, 34 insertions(+), 3 deletions(-)
diff --git a/extensions/atlasmap/runtime/src/main/java/org/apache/camel/quarkus/component/atlasmap/graalvm/Substitutions.java b/extensions/atlasmap/runtime/src/main/java/org/apache/camel/quarkus/component/atlasmap/graalvm/Substitutions.java
index 571c7cc..bd71095 100644
--- a/extensions/atlasmap/runtime/src/main/java/org/apache/camel/quarkus/component/atlasmap/graalvm/Substitutions.java
+++ b/extensions/atlasmap/runtime/src/main/java/org/apache/camel/quarkus/component/atlasmap/graalvm/Substitutions.java
@@ -16,22 +16,54 @@
*/
package org.apache.camel.quarkus.component.atlasmap.graalvm;
+import java.net.URL;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.LinkedList;
+import java.util.List;
import java.util.Set;
import com.oracle.svm.core.annotate.Alias;
+import com.oracle.svm.core.annotate.RecomputeFieldValue;
import com.oracle.svm.core.annotate.Substitute;
import com.oracle.svm.core.annotate.TargetClass;
+import org.slf4j.Logger;
+
+import static com.oracle.svm.core.annotate.RecomputeFieldValue.Kind.Reset;
public class Substitutions {
}
@TargetClass(className = "io.atlasmap.core.DefaultAtlasCompoundClassLoader")
final class DefaultAtlasCompoundClassLoader_Substitute {
+
+ @Alias
+ @RecomputeFieldValue(kind = Reset)
+ private static Logger LOG = null;
+
@Alias
private Set<ClassLoader> delegates;
@Substitute
+ public Enumeration<URL> getResources(String name) {
+ List<URL> answer = new LinkedList<>();
+ for (ClassLoader cl : delegates) {
+ try {
+ Enumeration<URL> urls = cl.getResources(name);
+ while (urls != null && urls.hasMoreElements()) {
+ answer.add(urls.nextElement());
+ }
+ } catch (Exception e) {
+ LOG.debug("I/O error while looking for a resource '{}' with ClassLoader '{}': {}", name, cl);
+ LOG.debug(e.getMessage(), e);
+ }
+ }
+ return Collections.enumeration(answer);
+ }
+
+ @Substitute
public synchronized void addAlternativeLoader(ClassLoader cl) {
delegates.add(Thread.currentThread().getContextClassLoader());
}
-}
+
+}
\ No newline at end of file
diff --git a/integration-tests/atlasmap/src/test/java/org/apache/camel/quarkus/component/atlasmap/it/AtlasmapIT.java b/integration-tests/atlasmap/src/test/java/org/apache/camel/quarkus/component/atlasmap/it/AtlasmapIT.java
index 7e21243..e52f423 100644
--- a/integration-tests/atlasmap/src/test/java/org/apache/camel/quarkus/component/atlasmap/it/AtlasmapIT.java
+++ b/integration-tests/atlasmap/src/test/java/org/apache/camel/quarkus/component/atlasmap/it/AtlasmapIT.java
@@ -16,10 +16,9 @@
*/
package org.apache.camel.quarkus.component.atlasmap.it;
-import io.quarkus.test.junit.DisabledOnNativeImage;
import io.quarkus.test.junit.NativeImageTest;
-@DisabledOnNativeImage("https://github.com/apache/camel-quarkus/issues/3189")
+//@DisabledOnNativeImage("https://github.com/apache/camel-quarkus/issues/3189")
@NativeImageTest
class AtlasmapIT extends AtlasmapTest {