openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jgras...@apache.org
Subject svn commit: r1166880 - in /openjpa/trunk/openjpa-lib/src/main: java/org/apache/openjpa/lib/meta/XMLMetaDataParser.java resources/org/apache/openjpa/lib/meta/localizer.properties
Date Thu, 08 Sep 2011 20:07:16 GMT
Author: jgrassel
Date: Thu Sep  8 20:07:16 2011
New Revision: 1166880

URL: http://svn.apache.org/viewvc?rev=1166880&view=rev
Log:
OPENJPA-1993: Deadlock Potential with ORM XML Processing

Modified:
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/XMLMetaDataParser.java
    openjpa/trunk/openjpa-lib/src/main/resources/org/apache/openjpa/lib/meta/localizer.properties

Modified: openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/XMLMetaDataParser.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/XMLMetaDataParser.java?rev=1166880&r1=1166879&r2=1166880&view=diff
==============================================================================
--- openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/XMLMetaDataParser.java
(original)
+++ openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/XMLMetaDataParser.java
Thu Sep  8 20:07:16 2011
@@ -378,14 +378,20 @@ public abstract class XMLMetaDataParser 
             _sourceName = sourceName;
             
             SAXParser parser = null;
+            boolean overrideCL = _overrideContextClassloader;
             ClassLoader oldLoader = null;
+            ClassLoader newLoader = null;           
             
             try {
-                if (_overrideContextClassloader == true) {
-                    oldLoader = (ClassLoader) AccessController.doPrivileged(
-                        J2DoPrivHelper.getContextClassLoaderAction());
-                    AccessController.doPrivileged(J2DoPrivHelper.setContextClassLoaderAction(
-                        XMLMetaDataParser.class.getClassLoader()));
+                if (overrideCL == true) {
+                    oldLoader =
+                        (ClassLoader) AccessController.doPrivileged(J2DoPrivHelper.getContextClassLoaderAction());
+                    newLoader = XMLMetaDataParser.class.getClassLoader();
+                    AccessController.doPrivileged(J2DoPrivHelper.setContextClassLoaderAction(newLoader));
+                    
+                    if (_log != null && _log.isTraceEnabled()) {
+                        _log.trace(_loc.get("override-contextclassloader-begin", oldLoader,
newLoader));
+                    }                   
                 }
                 
                 parser = XMLFactory.getSAXParser(validating, true);
@@ -419,13 +425,16 @@ public abstract class XMLMetaDataParser 
                 ioe.initCause(se);
                 throw ioe;
             } finally {
-                if (_overrideContextClassloader == true && oldLoader != null) {
+                if (overrideCL == true) {
                     // Restore the old ContextClassloader
                     try {
+                        if (_log != null && _log.isTraceEnabled()) {
+                            _log.trace(_loc.get("override-contextclassloader-end", newLoader,
oldLoader));
+                        }
                         AccessController.doPrivileged(J2DoPrivHelper.setContextClassLoaderAction(oldLoader));
                     } catch (Throwable t) {
-                        if (_log != null && _log.isTraceEnabled()) {
-                            _log.trace(_loc.get("restore-contextclassloader-failed"));
+                        if (_log != null && _log.isWarnEnabled()) {
+                            _log.warn(_loc.get("restore-contextclassloader-failed"));
                         }
                     }
                 }

Modified: openjpa/trunk/openjpa-lib/src/main/resources/org/apache/openjpa/lib/meta/localizer.properties
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/resources/org/apache/openjpa/lib/meta/localizer.properties?rev=1166880&r1=1166879&r2=1166880&view=diff
==============================================================================
--- openjpa/trunk/openjpa-lib/src/main/resources/org/apache/openjpa/lib/meta/localizer.properties
(original)
+++ openjpa/trunk/openjpa-lib/src/main/resources/org/apache/openjpa/lib/meta/localizer.properties
Thu Sep  8 20:07:16 2011
@@ -25,6 +25,10 @@ cant-diff-elems: Unable to differentiate
 	elements for class arg parsing.  No element can be a complete prefix of \
 	another.
 class-arg: Error extracting class information from "{0}".
+override-contextclassloader-begin: Overriding thread context classloader \
+    from "{0}" to "{1}".
+override-contextclassloader-end: Restoring thread context classloader \
+    from "{0}" to "{1}".
 restore-contextclassloader-failed: An error occurred restoring the Thread's \
     context classloader.
 parse-error: An error was encountered while parsing element "{0}".  Make sure \



Mime
View raw message