Index: src/com/ibatis/sqlmap/engine/execution/SqlExecutor.java =================================================================== RCS file: /data/cvs/src/AtlasIBatisDbl/src/com/ibatis/sqlmap/engine/execution/SqlExecutor.java,v retrieving revision 1.1 diff -u -r1.1 SqlExecutor.java --- src/com/ibatis/sqlmap/engine/execution/SqlExecutor.java 2 Oct 2008 11:39:53 -0000 1.1 +++ src/com/ibatis/sqlmap/engine/execution/SqlExecutor.java 3 Oct 2008 08:15:36 -0000 @@ -80,6 +80,7 @@ ps.execute(); rows = ps.getUpdateCount(); } finally { + cleanupResultObjectFactory(); closeStatement(statementScope.getSession(), ps); } return rows; @@ -189,6 +190,7 @@ rs = handleMultipleResults(ps, statementScope, skipResults, maxResults, callback); // End ResultSet Handling } finally { + cleanupResultObjectFactory(); try { closeResultSet(rs); } finally { @@ -231,6 +233,7 @@ errorContext.setMoreInfo("Check the output parameters (retrieval of output parameters failed)."); retrieveOutputParameters(statementScope, cs, mappings, parameters, null); } finally { + cleanupResultObjectFactory(); closeStatement(statementScope.getSession(), cs); } return rows; @@ -285,6 +288,7 @@ retrieveOutputParameters(statementScope, cs, mappings, parameters, callback); } finally { + cleanupResultObjectFactory(); try { closeResultSet(rs); } finally { @@ -679,4 +683,8 @@ ResultObjectFactoryUtil.setResultObjectFactory(client.getResultObjectFactory()); ResultObjectFactoryUtil.setStatementId(statementScope.getStatement().getId()); } + + private void cleanupResultObjectFactory() { + ResultObjectFactoryUtil.cleanupThreadLocal(); + } } Index: src/com/ibatis/sqlmap/engine/mapping/result/ResultObjectFactoryUtil.java =================================================================== RCS file: /data/cvs/src/AtlasIBatisDbl/src/com/ibatis/sqlmap/engine/mapping/result/ResultObjectFactoryUtil.java,v retrieving revision 1.1 diff -u -r1.1 ResultObjectFactoryUtil.java --- src/com/ibatis/sqlmap/engine/mapping/result/ResultObjectFactoryUtil.java 2 Oct 2008 11:39:54 -0000 1.1 +++ src/com/ibatis/sqlmap/engine/mapping/result/ResultObjectFactoryUtil.java 3 Oct 2008 08:15:36 -0000 @@ -132,6 +132,13 @@ getFactorySettings().setStatementId(statementId); } + /** + * Removes the FactorySettings bound to the current thread to avoid classloader leak issues. + */ + public static void cleanupThreadLocal(){ + factorySettings.remove(); + } + private static FactorySettings getFactorySettings() { FactorySettings fs = (FactorySettings) factorySettings.get(); if (fs == null) {