Skip to content

Commit

Permalink
RESTEASY-1623:GZIPDecodingInterceptor may be registered twice when us…
Browse files Browse the repository at this point in the history
…ing JAX-RS and REsteasy client on the same application
  • Loading branch information
jimma committed Mar 13, 2017
1 parent 13fc71d commit 65c4c98
Showing 1 changed file with 11 additions and 4 deletions.
@@ -1,5 +1,6 @@
package org.jboss.resteasy.plugins.providers;

import org.jboss.resteasy.core.ThreadLocalResteasyProviderFactory;
import org.jboss.resteasy.resteasy_jaxrs.i18n.LogMessages;
import org.jboss.resteasy.spi.ResteasyProviderFactory;

Expand All @@ -24,9 +25,13 @@ public class RegisterBuiltin

public static void register(ResteasyProviderFactory factory)
{
synchronized (factory)
final ResteasyProviderFactory monitor = (factory instanceof ThreadLocalResteasyProviderFactory)
? ((ThreadLocalResteasyProviderFactory) factory).getDelegate()
: factory;
synchronized (monitor)
{
if (factory.isBuiltinsRegistered() || !factory.isRegisterBuiltins()) return;
if (factory.isBuiltinsRegistered() || !factory.isRegisterBuiltins())
return;
try
{
registerProviders(factory);
Expand All @@ -41,7 +46,8 @@ public static void register(ResteasyProviderFactory factory)

public static void registerProviders(ResteasyProviderFactory factory) throws Exception
{
Enumeration<URL> en = Thread.currentThread().getContextClassLoader().getResources("META-INF/services/" + Providers.class.getName());
Enumeration<URL> en = Thread.currentThread().getContextClassLoader()
.getResources("META-INF/services/" + Providers.class.getName());
Map<String, URL> origins = new HashMap<String, URL>();
while (en.hasMoreElements())
{
Expand All @@ -54,7 +60,8 @@ public static void registerProviders(ResteasyProviderFactory factory) throws Exc
while ((line = reader.readLine()) != null)
{
line = line.trim();
if (line.equals("")) continue;
if (line.equals(""))
continue;
origins.put(line, url);
}
}
Expand Down

0 comments on commit 65c4c98

Please sign in to comment.