classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cp-patches] jar connection


From: Mark Wielaard
Subject: [cp-patches] jar connection
Date: Sun, 30 Jan 2005 00:09:50 +0100

Hi,

This solves a bug I was seeing in Mauve and that Timo Lindfors reported
on irc while trying to use gcjappletviewer. The jar Connection uses a
mechanism to detect whether it is already trying to open a connection to
a jar file. The problem with that was that it would then just return
null which immediately would cause a NullPointerException inside the
Connection class itself.

2005-01-29  Mark Wielaard  <address@hidden>

       * gnu/java/net/protocol/jar/Connection.java (is_trying): Removed
       field.
       (get): Don't use or set is_trying.

I cannot see how/if this ever worked and against what it was actually
guarding. Since it fixes some mauve tests and makes Timo his applet run
I would like to commit it though. Comments?

Cheers,

Mark
Index: gnu/java/net/protocol/jar/Connection.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/gnu/java/net/protocol/jar/Connection.java,v
retrieving revision 1.4
diff -u -r1.4 Connection.java
--- gnu/java/net/protocol/jar/Connection.java   4 Jan 2004 21:10:42 -0000       
1.4
+++ gnu/java/net/protocol/jar/Connection.java   29 Jan 2005 23:08:35 -0000
@@ -1,5 +1,5 @@
 /* Connection - jar url connection for java.net
-   Copyright (C) 1999, 2002, 2003 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2002, 2003, 2005 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -68,7 +68,6 @@
   {
     private static Hashtable cache = new Hashtable();
     private static final int READBUFSIZE = 4*1024;
-    private static boolean is_trying = false;
     
     public static synchronized JarFile get (URL url) throws IOException
     {
@@ -77,45 +76,33 @@
       if (jf != null)
         return jf;
       
-      if (is_trying)
-        return null;
-      
-      try
-        {
-          is_trying = true;
-
-          if ("file".equals (url.getProtocol()))
-            {
-              File f = new File (url.getFile());
-              jf = new JarFile (f, true, ZipFile.OPEN_READ);
-            }
-          else
-            {
-              URLConnection urlconn = url.openConnection();
-              InputStream is = urlconn.getInputStream();
-              byte[] buf = new byte [READBUFSIZE];
-              File f = File.createTempFile ("cache", "jar");
-              FileOutputStream fos = new FileOutputStream (f); 
-              int len = 0;
-              
-              while ((len = is.read (buf)) != -1)
-                {
-                  fos.write (buf, 0, len);
-                }
-              
-              fos.close();
-              // Always verify the Manifest, open read only and delete when 
done.
-              // XXX ZipFile.OPEN_DELETE not yet implemented.
-              // jf = new JarFile (f, true, ZipFile.OPEN_READ | 
ZipFile.OPEN_DELETE);
-              jf = new JarFile (f, true, ZipFile.OPEN_READ);
-            }
+      if ("file".equals (url.getProtocol()))
+       {
+         File f = new File (url.getFile());
+         jf = new JarFile (f, true, ZipFile.OPEN_READ);
+       }
+      else
+       {
+         URLConnection urlconn = url.openConnection();
+         InputStream is = urlconn.getInputStream();
+         byte[] buf = new byte [READBUFSIZE];
+         File f = File.createTempFile ("cache", "jar");
+         FileOutputStream fos = new FileOutputStream (f); 
+         int len = 0;
+         
+         while ((len = is.read (buf)) != -1)
+           {
+             fos.write (buf, 0, len);
+           }
+         
+         fos.close();
+         // Always verify the Manifest, open read only and delete when done.
+         // XXX ZipFile.OPEN_DELETE not yet implemented.
+         // jf = new JarFile (f, true, ZipFile.OPEN_READ | 
ZipFile.OPEN_DELETE);
+         jf = new JarFile (f, true, ZipFile.OPEN_READ);
+       }
           
-          cache.put (url, jf);
-        }
-      finally
-        {
-          is_trying = false;
-        }
+      cache.put (url, jf);
       
       return jf;
     }

Attachment: signature.asc
Description: This is a digitally signed message part


reply via email to

[Prev in Thread] Current Thread [Next in Thread]