Hello, I'm working on fixing the issue "java.lang.OutOfMemoryError: Metaspace" in the time of redeploy where running an web application on Tomcat.
I have acquired a heap dump and found a weird Root GC reference which is connected to org.postgresql.jdbc2.AbstractJdbc2ResultSet. The heap dump shows that it saves a (intentionally constructed) NumberFormatException in a private static final field FAST_NUMBER_FAILED and that field has backtrace field which references a Servlet class that loaded by WebappClassLoader.
I think AbstractJdbc2ResultSet should stop saving a intentionally constructed Exception in a static field because it creates a strong reference to a class which invoked the database operation at the first time regardless if it's loaded by WebappClassLoader. It will be a cause of class loader leak.
[Steps to reproduce]
1. Put postgresql-9.3-1100.jdbc41.jar to $TOMCAT_HOME/lib 2. Put following element to $TOMCAT_HOME/conf/context.xml