http-client-branch: fixing sloppy merge in HPACK http-client-branch
authorprappo
Mon, 06 Nov 2017 21:31:00 +0300
branchhttp-client-branch
changeset 55769 4ecfe77d0c24
parent 55766 2136ad3694e4
child 55770 a7fbe5d26f3c
http-client-branch: fixing sloppy merge in HPACK
src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/hpack/HPACK.java
src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/hpack/HeaderTable.java
test/jdk/java/net/httpclient/http2/jdk.incubator.httpclient/jdk/incubator/http/internal/hpack/HeaderTableTest.java
--- a/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/hpack/HPACK.java	Mon Nov 06 13:06:34 2017 +0000
+++ b/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/hpack/HPACK.java	Mon Nov 06 21:31:00 2017 +0300
@@ -61,11 +61,11 @@
             Level l = logLevels.get(upperCasedValue);
             if (l == null) {
                 LOGGER = new RootLogger(NONE);
-                LOGGER.log(() -> format("%s value '%s' is not recognized (use %s), logging is disabled",
+                LOGGER.log(() -> format("%s value '%s' not recognized (use %s); logging disabled",
                                         PROPERTY, value, logLevels.keySet().stream().collect(joining(", "))));
             } else {
                 LOGGER = new RootLogger(l);
-                LOGGER.log(() -> format("logging level is %s", l));
+                LOGGER.log(() -> format("logging level %s", l));
             }
         }
     }
@@ -151,6 +151,8 @@
     private static final class RootLogger extends Logger {
 
         private final Level level;
+        @Stable
+        private final Logger[] path = { this };
 
         protected RootLogger(Level level) {
             super(new Logger[]{ }, "hpack");
@@ -163,20 +165,29 @@
         }
 
         @Override
+        public void log(Level level, Supplier<? extends CharSequence> s) {
+            log(path, level, s);
+        }
+
+        @Override
         protected void log(Logger[] path,
                            Level level,
                            Supplier<? extends CharSequence> s) {
             if (this.level.implies(level)) {
-                StringBuilder b = new StringBuilder();
-                for (Logger p : path) {
-                    b.append('/').append(p.getName());
-                }
-                System.out.println(b.toString() + ' ' + s.get());
+                log(path, s);
             }
         }
 
         public void log(Supplier<? extends CharSequence> s) {
-            System.out.println(getName() + ' ' + s.get());
+            log(path, s);
+        }
+
+        private void log(Logger[] path, Supplier<? extends CharSequence> s) {
+            StringBuilder b = new StringBuilder();
+            for (Logger p : path) {
+                b.append('/').append(p.getName());
+            }
+            System.out.println(b.toString() + ' ' + s.get());
         }
     }
 }
--- a/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/hpack/HeaderTable.java	Mon Nov 06 13:06:34 2017 +0000
+++ b/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/hpack/HeaderTable.java	Mon Nov 06 21:31:00 2017 +0300
@@ -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));
--- a/test/jdk/java/net/httpclient/http2/jdk.incubator.httpclient/jdk/incubator/http/internal/hpack/HeaderTableTest.java	Mon Nov 06 13:06:34 2017 +0000
+++ b/test/jdk/java/net/httpclient/http2/jdk.incubator.httpclient/jdk/incubator/http/internal/hpack/HeaderTableTest.java	Mon Nov 06 21:31:00 2017 +0300
@@ -326,10 +326,15 @@
 
     @Test
     public void testToStringDifferentLocale() {
+        Locale locale = Locale.getDefault();
         Locale.setDefault(Locale.FRENCH);
-        String s = format("%.1f", 3.1);
-        assertEquals("3,1", s); // assumption of the test, otherwise the test is useless
-        testToString0();
+        try {
+            String s = format("%.1f", 3.1);
+            assertEquals("3,1", s); // assumption of the test, otherwise the test is useless
+            testToString0();
+        } finally {
+            Locale.setDefault(locale);
+        }
     }
 
     private void testToString0() {