From 28f45efcda41c26deb0ad849c5ce7b507ce5485d Mon Sep 17 00:00:00 2001 From: Alain Lavoie Date: Fri, 2 Oct 2026 13:00:33 -0400 Subject: [PATCH] Fixed issue with serialier to avoid conflicts --- connectors/http-connector/pom.xml | 2 +- connectors/httpclient/pom.xml | 2 +- connectors/jersey2-jakarta/pom.xml | 2 +- .../openstack4j/connectors/jersey2/ClientFactory.java | 8 ++++++-- .../connectors/jersey2/HttpExecutorServiceImpl.java | 9 +++++++++ connectors/jersey2/pom.xml | 2 +- connectors/okhttp/pom.xml | 2 +- connectors/pom.xml | 2 +- connectors/resteasy/pom.xml | 2 +- core-integration-test/it-httpclient/pom.xml | 2 +- core-integration-test/it-jersey2-jakarta/pom.xml | 2 +- core-integration-test/it-jersey2/pom.xml | 2 +- core-integration-test/it-okhttp/pom.xml | 2 +- core-integration-test/it-resteasy/pom.xml | 2 +- core-integration-test/pom.xml | 2 +- core-test/pom.xml | 2 +- core/pom.xml | 2 +- distribution/pom.xml | 2 +- pom.xml | 2 +- 19 files changed, 32 insertions(+), 19 deletions(-) diff --git a/connectors/http-connector/pom.xml b/connectors/http-connector/pom.xml index 7dc2af2d4..fc5e5273e 100644 --- a/connectors/http-connector/pom.xml +++ b/connectors/http-connector/pom.xml @@ -4,7 +4,7 @@ com.github.openstack4j.core.connectors openstack4j-connectors - co-3.12.4 + co-3.12.5 OpenStack4j HttpURL Connector openstack4j-http-connector diff --git a/connectors/httpclient/pom.xml b/connectors/httpclient/pom.xml index c620d898d..766031338 100644 --- a/connectors/httpclient/pom.xml +++ b/connectors/httpclient/pom.xml @@ -2,7 +2,7 @@ com.github.openstack4j.core.connectors openstack4j-connectors - co-3.12.4 + co-3.12.5 4.0.0 openstack4j-httpclient diff --git a/connectors/jersey2-jakarta/pom.xml b/connectors/jersey2-jakarta/pom.xml index 19450cf63..1f2eb5146 100644 --- a/connectors/jersey2-jakarta/pom.xml +++ b/connectors/jersey2-jakarta/pom.xml @@ -2,7 +2,7 @@ com.github.openstack4j.core.connectors openstack4j-connectors - co-3.12.4 + co-3.12.5 4.0.0 openstack4j-jersey2-jakarta diff --git a/connectors/jersey2-jakarta/src/main/java/org/openstack4j/connectors/jersey2/ClientFactory.java b/connectors/jersey2-jakarta/src/main/java/org/openstack4j/connectors/jersey2/ClientFactory.java index e3e1cf9f1..335adb158 100644 --- a/connectors/jersey2-jakarta/src/main/java/org/openstack4j/connectors/jersey2/ClientFactory.java +++ b/connectors/jersey2-jakarta/src/main/java/org/openstack4j/connectors/jersey2/ClientFactory.java @@ -22,6 +22,7 @@ import org.glassfish.jersey.client.ClientProperties; import org.glassfish.jersey.client.HttpUrlConnectorProvider; import org.glassfish.jersey.client.HttpUrlConnectorProvider.ConnectionFactory; +import org.glassfish.jersey.client.JerseyClientBuilder; import org.glassfish.jersey.jackson.JacksonFeature; import org.openstack4j.api.exceptions.ConnectionException; import org.openstack4j.core.transport.ClientConstants; @@ -66,8 +67,11 @@ private static Client buildClientFromConfig(Config config) { if (config.getProxy() != null) { addProxy(clientConfig, config); } - - ClientBuilder cb = ClientBuilder.newBuilder() + // Instantiate Jersey directly instead of ClientBuilder.newBuilder(): the JAX-RS lookup + // goes through the thread context classloader, which, when this connector runs inside an + // isolated plugin classloader, can resolve another Jersey/Jackson copy that ignores the + // Jackson annotations on our model classes (e.g. KeystoneAuth sent without its "auth" root). + ClientBuilder cb = new JerseyClientBuilder() .withConfig(clientConfig) .property(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION, "true") .register(JacksonFeature.class) diff --git a/connectors/jersey2-jakarta/src/main/java/org/openstack4j/connectors/jersey2/HttpExecutorServiceImpl.java b/connectors/jersey2-jakarta/src/main/java/org/openstack4j/connectors/jersey2/HttpExecutorServiceImpl.java index 328a97eaf..a40b169d4 100644 --- a/connectors/jersey2-jakarta/src/main/java/org/openstack4j/connectors/jersey2/HttpExecutorServiceImpl.java +++ b/connectors/jersey2-jakarta/src/main/java/org/openstack4j/connectors/jersey2/HttpExecutorServiceImpl.java @@ -29,12 +29,21 @@ public class HttpExecutorServiceImpl implements HttpExecutorService { */ @Override public HttpResponse execute(HttpRequest request) { + // Jersey discovers providers and initializes its client runtime lazily, using the thread + // context classloader. Pin it to this connector's classloader so that, when loaded from an + // isolated (child-first) plugin classloader, Jersey and Jackson resolve from the same copy + // as the openstack4j model classes, whatever thread makes the call. + Thread thread = Thread.currentThread(); + ClassLoader previous = thread.getContextClassLoader(); + thread.setContextClassLoader(HttpExecutorServiceImpl.class.getClassLoader()); try { return invoke(request); } catch (ResponseException re) { throw re; } catch (Exception e) { throw new ConnectionException("Error during execution: " + e, 0, e); + } finally { + thread.setContextClassLoader(previous); } } diff --git a/connectors/jersey2/pom.xml b/connectors/jersey2/pom.xml index 24948140a..1b16595f6 100644 --- a/connectors/jersey2/pom.xml +++ b/connectors/jersey2/pom.xml @@ -2,7 +2,7 @@ com.github.openstack4j.core.connectors openstack4j-connectors - co-3.12.4 + co-3.12.5 4.0.0 openstack4j-jersey2 diff --git a/connectors/okhttp/pom.xml b/connectors/okhttp/pom.xml index fc3c11c24..cfbd06493 100644 --- a/connectors/okhttp/pom.xml +++ b/connectors/okhttp/pom.xml @@ -2,7 +2,7 @@ com.github.openstack4j.core.connectors openstack4j-connectors - co-3.12.4 + co-3.12.5 4.0.0 openstack4j-okhttp diff --git a/connectors/pom.xml b/connectors/pom.xml index a2f2a573c..1572bf118 100644 --- a/connectors/pom.xml +++ b/connectors/pom.xml @@ -2,7 +2,7 @@ com.github.openstack4j.core openstack4j-parent - co-3.12.4 + co-3.12.5 4.0.0 com.github.openstack4j.core.connectors diff --git a/connectors/resteasy/pom.xml b/connectors/resteasy/pom.xml index 8ccb92439..d22237091 100644 --- a/connectors/resteasy/pom.xml +++ b/connectors/resteasy/pom.xml @@ -2,7 +2,7 @@ com.github.openstack4j.core.connectors openstack4j-connectors - co-3.12.4 + co-3.12.5 4.0.0 openstack4j-resteasy diff --git a/core-integration-test/it-httpclient/pom.xml b/core-integration-test/it-httpclient/pom.xml index 389428b92..70b6786c6 100644 --- a/core-integration-test/it-httpclient/pom.xml +++ b/core-integration-test/it-httpclient/pom.xml @@ -3,7 +3,7 @@ com.github.openstack4j.core openstack4j-core-integration-test - co-3.12.4 + co-3.12.5 it-httpclient OpenStack4j IntegrationTest Apache HttpClient diff --git a/core-integration-test/it-jersey2-jakarta/pom.xml b/core-integration-test/it-jersey2-jakarta/pom.xml index 0a500bf16..8a3940836 100644 --- a/core-integration-test/it-jersey2-jakarta/pom.xml +++ b/core-integration-test/it-jersey2-jakarta/pom.xml @@ -3,7 +3,7 @@ com.github.openstack4j.core openstack4j-core-integration-test - co-3.12.4 + co-3.12.5 it-jersey2-jakarta OpenStack4j IntegrationTest Jersey2 Jakarta Connector diff --git a/core-integration-test/it-jersey2/pom.xml b/core-integration-test/it-jersey2/pom.xml index 730e57f53..3c3b6774e 100644 --- a/core-integration-test/it-jersey2/pom.xml +++ b/core-integration-test/it-jersey2/pom.xml @@ -3,7 +3,7 @@ com.github.openstack4j.core openstack4j-core-integration-test - co-3.12.4 + co-3.12.5 it-jersey2 OpenStack4j IntegrationTest Jersey2 Connector diff --git a/core-integration-test/it-okhttp/pom.xml b/core-integration-test/it-okhttp/pom.xml index ae6f65204..21c99135c 100644 --- a/core-integration-test/it-okhttp/pom.xml +++ b/core-integration-test/it-okhttp/pom.xml @@ -3,7 +3,7 @@ com.github.openstack4j.core openstack4j-core-integration-test - co-3.12.4 + co-3.12.5 it-okhttp OpenStack4j IntegrationTest OKHttp Connector diff --git a/core-integration-test/it-resteasy/pom.xml b/core-integration-test/it-resteasy/pom.xml index c4f072956..283f02a0e 100644 --- a/core-integration-test/it-resteasy/pom.xml +++ b/core-integration-test/it-resteasy/pom.xml @@ -3,7 +3,7 @@ com.github.openstack4j.core openstack4j-core-integration-test - co-3.12.4 + co-3.12.5 it-resteasy OpenStack4j IntegrationTest RestEasy Connector diff --git a/core-integration-test/pom.xml b/core-integration-test/pom.xml index d709f6f42..b6dae68f9 100644 --- a/core-integration-test/pom.xml +++ b/core-integration-test/pom.xml @@ -2,7 +2,7 @@ com.github.openstack4j.core openstack4j-parent - co-3.12.4 + co-3.12.5 4.0.0 openstack4j-core-integration-test diff --git a/core-test/pom.xml b/core-test/pom.xml index 62b8384dc..9d75604f4 100644 --- a/core-test/pom.xml +++ b/core-test/pom.xml @@ -2,7 +2,7 @@ com.github.openstack4j.core openstack4j-parent - co-3.12.4 + co-3.12.5 4.0.0 openstack4j-core-test diff --git a/core/pom.xml b/core/pom.xml index f2fae0d91..868e9ef0a 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -2,7 +2,7 @@ com.github.openstack4j.core openstack4j-parent - co-3.12.4 + co-3.12.5 4.0.0 openstack4j-core diff --git a/distribution/pom.xml b/distribution/pom.xml index f9bb3a922..6802d03e1 100644 --- a/distribution/pom.xml +++ b/distribution/pom.xml @@ -2,7 +2,7 @@ com.github.openstack4j.core openstack4j-parent - co-3.12.4 + co-3.12.5 4.0.0 openstack4j diff --git a/pom.xml b/pom.xml index e3fe30eed..e6c4d5d06 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.github.openstack4j.core openstack4j-parent - co-3.12.4 + co-3.12.5 OpenStack4j Parent OpenStack Java API https://github.com/openstack4j/openstack4j/