rlalfo / google-http-java-client

Automatically exported from code.google.com/p/google-http-java-client
0 stars 0 forks source link

Possible classloader memory leak in com.google.api.client.util.escape.Platform #195

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Version of google-http-java-client (e.g. 1.5.0-beta)?

1.13.1-beta

Java environment (e.g. Java 6, Android 2.3, App Engine)?

Any environment with custom classloaders.

Describe the problem.

com.google.api.client.util.escape.Platform uses a custom ThreadLocal class to 
implement the initialValue() method. Unfortunately this can lead to a 
classloader leak in servlet and OSGI environments, since the thread refers to 
the ThreadLocal.ThreadLocalMap, each entry in the map refers to the 
ThreadLocal, and the custom ThreadLocal refers to the ClassLoader. There is 
some more about this at:

http://wiki.apache.org/tomcat/MemoryLeakProtection#customThreadLocal

How would you expect it to be fixed?

Don't extend the ThreadLocal with a custom class, and implement the initial 
value support by checking for null from get(). This prevents the ClassLoader 
leak, since the ThreadLocal class and the char[] array are both loaded from the 
system classloader.

Original issue reported on code.google.com by ca...@carey.geek.nz on 28 Jan 2013 at 9:50

GoogleCodeExporter commented 9 years ago

Original comment by ngmic...@google.com on 20 Feb 2013 at 3:39

GoogleCodeExporter commented 9 years ago

Original comment by yan...@google.com on 9 Apr 2013 at 2:05