jdk/test/java/net/URLClassLoader/HttpTest.java
changeset 5165 5693cc1e95c6
parent 2 90ce3da70b43
child 5506 202f599c92aa
--- a/jdk/test/java/net/URLClassLoader/HttpTest.java	Thu Mar 25 12:07:42 2010 +0800
+++ b/jdk/test/java/net/URLClassLoader/HttpTest.java	Thu Mar 25 09:38:56 2010 +0000
@@ -56,9 +56,9 @@
             }
 
             public void run() {
+                InputStream in = null;
                 try {
-
-                    InputStream in = s.getInputStream();
+                    in = s.getInputStream();
                     for (;;) {
 
                         // read entire request from client
@@ -111,6 +111,9 @@
                     } // for
 
                 } catch (Exception e) {
+                    unexpected(e);
+                } finally {
+                    if (in != null) { try {in.close(); } catch(IOException e) {unexpected(e);} }
                 }
             }
         }
@@ -131,6 +134,11 @@
             }
         }
 
+        void unexpected(Exception e) {
+            System.out.println(e);
+            e.printStackTrace();
+        }
+
         public static HttpServer create() throws Exception {
             if (svr != null)
                 return svr;
@@ -211,6 +219,7 @@
         //          one GET request
         svr.counters().reset();
         InputStream in = cl.getResourceAsStream("foo2.gif");
+        in.close();
         System.out.println(svr.counters());
         if (svr.counters().getCount() > 1) {
             failed = true;