diff --git a/common/src/main/java/org/keycloak/common/util/Resteasy.java b/common/src/main/java/org/keycloak/common/util/Resteasy.java
index 754b25dbb3..1dfa0fbd41 100644
--- a/common/src/main/java/org/keycloak/common/util/Resteasy.java
+++ b/common/src/main/java/org/keycloak/common/util/Resteasy.java
@@ -17,16 +17,13 @@
package org.keycloak.common.util;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
import java.util.ServiceLoader;
/**
- *
Provides a layer of indirection to abstract invocations to Resteasy internal APIs. Making also possible to use different
- * versions of Resteasy (e.g.: v3 and v4) depending on the stack that the server is running.
- *
- *
The methods herein provided are basically related with accessing context data from Resteasy, which changed in latest versions of Resteasy.
- *
- *
It is important to use this class when access to context data is necessary in order to avoid incompatibilities with future
- * versions of Resteasy.
+ *
Provides a layer of indirection to abstract invocations to Resteasy internal APIs for obtaining the KeycloakSession
*
* @author Pedro Igor
*/
@@ -35,38 +32,55 @@ public final class Resteasy {
private static ResteasyProvider provider;
static {
- provider = ServiceLoader.load(ResteasyProvider.class, Resteasy.class.getClassLoader()).iterator().next();
+ Iterator iter = ServiceLoader.load(ResteasyProvider.class, Resteasy.class.getClassLoader()).iterator();
+ if (iter.hasNext()) {
+ provider = iter.next();
+ }
}
+ private static final ThreadLocal