datastax/java-driver — pull request #195 by olim7t (2014-07-07 06:40:02+00:00)
Title: Avoid classloader leak in Tomcat (JAVA-343).

We use ThreadLocals in two places, to cache objects that we don't want to re-instantiate on each call.

One obvious workaround is to forego that optimization and create a new object each time.

This commit takes another approach: wrap the object in a weak reference so that it can be garbage collected on redeployment. Tomcat no longer complains and I've checked with JVisualVM that the class loader is correctly garbage-collected.