maguro      2005/04/17 13:11:01

  Modified:    modules/core/src/java/org/openejb/corba/util
                        OpenORBStubClassLoader.java
  Log:

  Check for collisions.
  
  Revision  Changes    Path
  1.8       +8 -4      
openejb/modules/core/src/java/org/openejb/corba/util/OpenORBStubClassLoader.java
  
  Index: OpenORBStubClassLoader.java
  ===================================================================
  RCS file: 
/home/projects/openejb/scm/openejb/modules/core/src/java/org/openejb/corba/util/OpenORBStubClassLoader.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- OpenORBStubClassLoader.java       31 Mar 2005 07:47:32 -0000      1.7
  +++ OpenORBStubClassLoader.java       17 Apr 2005 17:11:01 -0000      1.8
  @@ -51,6 +51,7 @@
   import java.util.Collections;
   import java.util.HashMap;
   import java.util.Map;
  +import java.util.Random;
   
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
  @@ -81,7 +82,7 @@
       private final File cacheDir;
       private final Map parentToNameToLoaderMap = new HashMap();
       private final Map nameToClassMap = new HashMap();
  -    private static long jarId = 0;
  +    private static Random random = new Random(System.currentTimeMillis());
   
       public OpenORBStubClassLoader(ServerInfo serverInfo, StubGenerator 
stubGenerator, String cacheDir) {
           this.stubGenerator = stubGenerator;
  @@ -120,7 +121,10 @@
                   URL url = (URL) nameToClassMap.get(name);
                   if (url == null) {
                       try {
  -                        File file = new File(cacheDir, "STUB_" + (jarId++) + 
".jar");
  +                        File file = new File(cacheDir, "STUB_" + 
(random.nextLong()) + ".jar");
  +                        while (file.exists()) {
  +                            file = new File(cacheDir, "STUB_" + 
(random.nextLong()) + ".jar");
  +                        }
   
                           if (log.isDebugEnabled()) log.debug("Generating 
stubs in " + file.toString());
   
  
  
  

Reply via email to