http-client-branch: minor bug fixes http-client-branch
authorchegar
Fri, 09 Feb 2018 18:50:31 +0000
branchhttp-client-branch
changeset 56101 983e338eeb50
parent 56100 4a0ad0602b99
child 56102 34f5fa24fdfb
http-client-branch: minor bug fixes
src/java.net.http/share/classes/jdk/internal/net/http/CookieFilter.java
src/java.net.http/share/classes/jdk/internal/net/http/LineSubscriberAdapter.java
src/java.net.http/share/classes/jdk/internal/net/http/PlainHttpConnection.java
src/java.net.http/share/classes/jdk/internal/net/http/SSLDelegate.java
src/java.net.http/share/classes/jdk/internal/net/http/WindowController.java
src/java.net.http/share/classes/jdk/internal/net/http/common/Log.java
src/java.net.http/share/classes/jdk/internal/net/http/common/SSLFlowDelegate.java
src/java.net.http/share/classes/jdk/internal/net/http/hpack/HeaderTable.java
--- a/src/java.net.http/share/classes/jdk/internal/net/http/CookieFilter.java	Fri Feb 09 15:22:31 2018 +0000
+++ b/src/java.net.http/share/classes/jdk/internal/net/http/CookieFilter.java	Fri Feb 09 18:50:31 2018 +0000
@@ -57,9 +57,9 @@
                 Log.logTrace("Request: adding cookies for {0}",
                              r.uri());
             }
-            for (String hdrname : cookies.keySet()) {
-                List<String> vals = cookies.get(hdrname);
-                for (String val : vals) {
+            for (Map.Entry<String,List<String>> entry : cookies.entrySet()) {
+                final String hdrname = entry.getKey();
+                for (String val : entry.getValue()) {
                     systemHeaders.addHeader(hdrname, val);
                 }
             }
--- a/src/java.net.http/share/classes/jdk/internal/net/http/LineSubscriberAdapter.java	Fri Feb 09 15:22:31 2018 +0000
+++ b/src/java.net.http/share/classes/jdk/internal/net/http/LineSubscriberAdapter.java	Fri Feb 09 18:50:31 2018 +0000
@@ -141,7 +141,6 @@
         private final ByteBuffer leftover = ByteBuffer.wrap(new byte[64]);
         private final CharBuffer buffer = CharBuffer.wrap(chars);
         private final StringBuilder builder = new StringBuilder();
-        private int lineCount;
         private String nextLine;
 
         private LineSubscription(Flow.Subscription s,
--- a/src/java.net.http/share/classes/jdk/internal/net/http/PlainHttpConnection.java	Fri Feb 09 15:22:31 2018 +0000
+++ b/src/java.net.http/share/classes/jdk/internal/net/http/PlainHttpConnection.java	Fri Feb 09 18:50:31 2018 +0000
@@ -187,7 +187,9 @@
         try {
             Log.logTrace("Closing: " + toString());
             chan.close();
-        } catch (IOException e) {}
+        } catch (IOException e) {
+            Log.logTrace("Closing resulted in " + e);
+        }
     }
 
     @Override
--- a/src/java.net.http/share/classes/jdk/internal/net/http/SSLDelegate.java	Fri Feb 09 15:22:31 2018 +0000
+++ b/src/java.net.http/share/classes/jdk/internal/net/http/SSLDelegate.java	Fri Feb 09 18:50:31 2018 +0000
@@ -437,7 +437,9 @@
                         assert tmp.position() == 0;
                         break;
                 }
-                hs_status = r.result.getHandshakeStatus();
+                if (r != null) {
+                    hs_status = r.result.getHandshakeStatus();
+                }
             }
             Log.logSSL(getSessionInfo());
             if (!wasBlocking) {
--- a/src/java.net.http/share/classes/jdk/internal/net/http/WindowController.java	Fri Feb 09 15:22:31 2018 +0000
+++ b/src/java.net.http/share/classes/jdk/internal/net/http/WindowController.java	Fri Feb 09 18:50:31 2018 +0000
@@ -102,7 +102,7 @@
             // Odd stream numbers (client streams) should have been registered.
             // Even stream numbers (server streams - aka Push Streams) should
             // not be registered
-            final boolean isClientStream = (streamid % 2) == 1;
+            final boolean isClientStream = (streamid & 0x1) == 1;
             if (old == null && isClientStream) {
                 throw new InternalError("Expected entry for streamid: " + streamid);
             } else if (old != null && !isClientStream) {
--- a/src/java.net.http/share/classes/jdk/internal/net/http/common/Log.java	Fri Feb 09 15:22:31 2018 +0000
+++ b/src/java.net.http/share/classes/jdk/internal/net/http/common/Log.java	Fri Feb 09 18:50:31 2018 +0000
@@ -105,6 +105,8 @@
                     case "all":
                         logging |= CONTENT|HEADERS|REQUESTS|FRAMES|ERRORS|TRACE|SSL;
                         break;
+                    default:
+                        // ignore bad values
                 }
                 if (val.startsWith("frames")) {
                     logging |= FRAMES;
@@ -126,6 +128,8 @@
                                 case "all":
                                     frametypes = ALL;
                                     break;
+                                default:
+                                    // ignore bad values
                             }
                         }
                     }
--- a/src/java.net.http/share/classes/jdk/internal/net/http/common/SSLFlowDelegate.java	Fri Feb 09 15:22:31 2018 +0000
+++ b/src/java.net.http/share/classes/jdk/internal/net/http/common/SSLFlowDelegate.java	Fri Feb 09 18:50:31 2018 +0000
@@ -171,10 +171,8 @@
         sb.append("SSL: HS state: " + states(handshakeState));
         sb.append(" Engine state: " + engine.getHandshakeStatus().toString());
         sb.append(" LL : ");
-        synchronized(stateList) {
-            for (String s: stateList) {
-                sb.append(s).append(" ");
-            }
+        for (String s: stateList) {
+            sb.append(s).append(" ");
         }
         sb.append("\r\n");
         sb.append("Reader:: ").append(reader.toString());
@@ -411,16 +409,19 @@
         @Override
         public void run() {
             System.out.println("Monitor starting");
-            while (true) {
-                try {Thread.sleep(20*1000); } catch (Exception e) {}
-                synchronized (list) {
-                    for (Monitorable o : list) {
-                        System.out.println(o.getInfo());
-                        System.out.println("-------------------------");
+            try {
+                while (true) {
+                    Thread.sleep(20 * 1000);
+                    synchronized (list) {
+                        for (Monitorable o : list) {
+                            System.out.println(o.getInfo());
+                            System.out.println("-------------------------");
+                        }
                     }
+                    System.out.println("--o-o-o-o-o-o-o-o-o-o-o-o-o-o-");
                 }
-                System.out.println("--o-o-o-o-o-o-o-o-o-o-o-o-o-o-");
-
+            } catch (InterruptedException e) {
+                System.out.println("Monitor exiting with " + e);
             }
         }
     }
--- a/src/java.net.http/share/classes/jdk/internal/net/http/hpack/HeaderTable.java	Fri Feb 09 15:22:31 2018 +0000
+++ b/src/java.net.http/share/classes/jdk/internal/net/http/hpack/HeaderTable.java	Fri Feb 09 18:50:31 2018 +0000
@@ -304,7 +304,7 @@
         StringBuilder b = new StringBuilder();
         for (int i = 1, size = dynamicTable.size(); i <= size; i++) {
             HeaderField e = dynamicTable.get(i);
-            b.append(format("[%3d] (s = %3d) %s: %s\n", i,
+            b.append(format("[%3d] (s = %3d) %s: %s%n", i,
                     sizeOf(e), e.name, e.value));
         }
         b.append(format("      Table size:%4s", this.size));