From 125925b108ffe5e21a8f2c4f3b2b9c6797d5be17 Mon Sep 17 00:00:00 2001 From: Ryan Emerson Date: Tue, 25 Oct 2022 11:48:27 +0100 Subject: [PATCH] Fix JGroups DNS_PING #116 --- .../src/main/resources/application.properties | 1 + .../server/runtime/graal/SubstituteDnsLookup.java | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/server-runner/src/main/resources/application.properties b/server-runner/src/main/resources/application.properties index 1b8ade3a..08134d82 100644 --- a/server-runner/src/main/resources/application.properties +++ b/server-runner/src/main/resources/application.properties @@ -1 +1,2 @@ quarkus.banner.enabled=false +quarkus.naming.enable-jndi=true diff --git a/server/runtime/src/main/java/org/infinispan/quarkus/server/runtime/graal/SubstituteDnsLookup.java b/server/runtime/src/main/java/org/infinispan/quarkus/server/runtime/graal/SubstituteDnsLookup.java index 7d3bb861..1560abf1 100644 --- a/server/runtime/src/main/java/org/infinispan/quarkus/server/runtime/graal/SubstituteDnsLookup.java +++ b/server/runtime/src/main/java/org/infinispan/quarkus/server/runtime/graal/SubstituteDnsLookup.java @@ -6,6 +6,7 @@ import javax.naming.Context; import javax.naming.NamingException; import javax.naming.spi.InitialContextFactory; +import javax.naming.spi.NamingManager; import org.infinispan.server.context.ServerInitialContextFactory; import org.infinispan.server.context.ServerInitialContextFactoryBuilder; @@ -39,4 +40,15 @@ public InitialContextFactory createInitialContextFactory(Hashtable environ throw new NamingException("Native Infinispan Server does not support " + className + " as an InitialContextFactory"); } } -} \ No newline at end of file +} + +@TargetClass(NamingManager.class) +final class Target_NamingManager{ + @Substitute + private static InitialContextFactory getFactory(String className) { + if ("com.sun.jndi.dns.DnsContextFactory".equals(className)) { + return new DnsContextFactory(); + } + throw new IllegalArgumentException("Native Infinispan Server does not support " + className + " as an InitialContextFactory"); + } +}