From: <otm...@us...> - 2007-09-25 23:03:56
|
Revision: 3544 http://jython.svn.sourceforge.net/jython/?rev=3544&view=rev Author: otmarhumbel Date: 2007-09-25 16:03:55 -0700 (Tue, 25 Sep 2007) Log Message: ----------- Merged revisions 3543 via svnmerge from https://jython.svn.sourceforge.net/svnroot/jython/trunk ........ r3543 | otmarhumbel | 2007-09-25 23:56:32 +0200 (Di, 25 Sep 2007) | 1 line Added patch from bug #1801802, which makes JavaImportHelper thread safe ........ Modified Paths: -------------- branches/Release_2_2maint/jython/src/org/python/core/JavaImportHelper.java Modified: branches/Release_2_2maint/jython/src/org/python/core/JavaImportHelper.java =================================================================== --- branches/Release_2_2maint/jython/src/org/python/core/JavaImportHelper.java 2007-09-25 21:56:32 UTC (rev 3543) +++ branches/Release_2_2maint/jython/src/org/python/core/JavaImportHelper.java 2007-09-25 23:03:55 UTC (rev 3544) @@ -190,28 +190,29 @@ * @return <code>true</code> if something was really added, <code>false</code> otherwise */ private static boolean addPackage(String packageName, boolean packageAdded) { - boolean added = false; - PyObject module = Py.getSystemState().modules.__finditem__(packageName.intern()); + PyObject modules = Py.getSystemState().modules; + String internedPackageName = packageName.intern(); + PyObject module = modules.__finditem__(internedPackageName); + // a previously failed import could have created a Py.None entry in sys.modules if (module == null || module == Py.None) { - PyObject modules = Py.getSystemState().modules; - int dotPos; + int dotPos = 0; do { - String internedPackageName = packageName.intern(); - if (modules.__finditem__(internedPackageName) == Py.None) { - // a previously failed import could have created a Py.None entry in sys.modules - modules.__delitem__(internedPackageName); + PyJavaPackage p = PySystemState.add_package(packageName); + if(dotPos == 0) { + modules.__setitem__(internedPackageName, p); + } else { + module = modules.__finditem__(internedPackageName); + if (module == null || module == Py.None) { + modules.__setitem__(internedPackageName, p); + } } - PyJavaPackage p = PySystemState.add_package(packageName); - Py.getSystemState().modules.__setitem__(internedPackageName, p); - added = true; dotPos = packageName.lastIndexOf(DOT); if (dotPos > 0) { packageName = packageName.substring(0, dotPos); + internedPackageName = packageName.intern(); } - } while (dotPos > 0); - } - // make sure not to turn off the packageAdded flag - if (added && !packageAdded) { + } while(dotPos > 0); + // make sure not to turn off the packageAdded flag packageAdded = true; } return packageAdded; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |