http-client-branch: use UTF-8 for all convertions to String http-client-branch
authorchegar
Mon, 05 Feb 2018 19:01:54 +0000
branchhttp-client-branch
changeset 56072 96c1f6e984eb
parent 56071 3353cb42b1b4
child 56073 38d25d0eeae8
http-client-branch: use UTF-8 for all convertions to String
src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/Http2Connection.java
src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/frame/FramesDecoder.java
src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/frame/GoAwayFrame.java
--- a/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/Http2Connection.java	Mon Feb 05 17:18:26 2018 +0000
+++ b/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/Http2Connection.java	Mon Feb 05 19:01:54 2018 +0000
@@ -73,7 +73,7 @@
 import jdk.incubator.http.internal.hpack.Encoder;
 import jdk.incubator.http.internal.hpack.Decoder;
 import jdk.incubator.http.internal.hpack.DecodingCallback;
-
+import static java.nio.charset.StandardCharsets.UTF_8;
 import static jdk.incubator.http.internal.frame.SettingsFrame.*;
 
 
@@ -487,7 +487,9 @@
 
     void close() {
         Log.logTrace("Closing HTTP/2 connection: to {0}", connection.address());
-        GoAwayFrame f = new GoAwayFrame(0, ErrorFrame.NO_ERROR, "Requested by user".getBytes());
+        GoAwayFrame f = new GoAwayFrame(0,
+                                        ErrorFrame.NO_ERROR,
+                                        "Requested by user".getBytes(UTF_8));
         // TODO: set last stream. For now zero ok.
         sendFrame(f);
     }
--- a/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/frame/FramesDecoder.java	Mon Feb 05 17:18:26 2018 +0000
+++ b/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/frame/FramesDecoder.java	Mon Feb 05 19:01:54 2018 +0000
@@ -25,16 +25,15 @@
 
 package jdk.incubator.http.internal.frame;
 
-import jdk.incubator.http.internal.common.Log;
-import jdk.incubator.http.internal.common.Utils;
-
 import java.io.IOException;
 import java.lang.System.Logger.Level;
 import java.nio.ByteBuffer;
 import java.util.ArrayDeque;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Queue;
+import jdk.incubator.http.internal.common.Log;
+import jdk.incubator.http.internal.common.Utils;
+import static java.nio.charset.StandardCharsets.UTF_8;
 
 /**
  * Frames Decoder
@@ -520,7 +519,7 @@
         int errorCode = getInt();
         byte[] debugData = getBytes(frameLength - 8);
         if (debugData.length > 0) {
-            Log.logError("GoAway debugData " + new String(debugData));
+            Log.logError("GoAway debugData " + new String(debugData, UTF_8));
         }
         return new GoAwayFrame(lastStream, errorCode, debugData);
     }
--- a/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/frame/GoAwayFrame.java	Mon Feb 05 17:18:26 2018 +0000
+++ b/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/frame/GoAwayFrame.java	Mon Feb 05 19:01:54 2018 +0000
@@ -25,6 +25,8 @@
 
 package jdk.incubator.http.internal.frame;
 
+import static java.nio.charset.StandardCharsets.UTF_8;
+
 public class GoAwayFrame extends ErrorFrame {
 
     private final int lastStream;
@@ -55,7 +57,7 @@
 
     @Override
     public String toString() {
-        return super.toString() + " Debugdata: " + new String(debugData);
+        return super.toString() + " Debugdata: " + new String(debugData, UTF_8);
     }
 
     public int getLastStream() {