8180310: TestSocketFactory null pointer when updating match bytes
authorrriggs
Sun, 29 Oct 2017 18:31:55 -0400
changeset 47472 3937719e6371
parent 47471 304ef03403b1
child 47473 5d798d729fec
8180310: TestSocketFactory null pointer when updating match bytes Reviewed-by: dfuchs
test/jdk/java/rmi/testlibrary/TestSocketFactory.java
--- a/test/jdk/java/rmi/testlibrary/TestSocketFactory.java	Sun Oct 29 18:20:53 2017 -0400
+++ b/test/jdk/java/rmi/testlibrary/TestSocketFactory.java	Sun Oct 29 18:31:55 2017 -0400
@@ -249,18 +249,22 @@
         /**
          * Set the trigger, match, and replacement bytes.
          * The trigger, match, and replacements are propagated to the
-         * MatchReplaceOutputStream.
+         * MatchReplaceOutputStream, if it has been created.
          *
          * @param triggerBytes array of bytes to use as a trigger, may be zero length
          * @param matchBytes bytes to match after the trigger has been seen
          * @param replaceBytes bytes to replace the matched bytes
          */
-        public void setMatchReplaceBytes(byte[] triggerBytes, byte[] matchBytes,
+        public synchronized void setMatchReplaceBytes(byte[] triggerBytes, byte[] matchBytes,
                                          byte[] replaceBytes) {
             this.triggerBytes = triggerBytes;
             this.matchBytes = matchBytes;
             this.replaceBytes = replaceBytes;
-            out.setMatchReplaceBytes(triggerBytes, matchBytes, replaceBytes);
+            if (out != null) {
+                out.setMatchReplaceBytes(triggerBytes, matchBytes, replaceBytes);
+            } else {
+                DEBUG("InterposeSocket.setMatchReplaceBytes with out == null%n");
+            }
         }
 
         @Override
@@ -360,7 +364,7 @@
                 String name = Thread.currentThread().getName() + ": "
                         + socket.getLocalPort() + " <  " + socket.getPort();
                 in = new LoggingInputStream(in, name, inLogStream);
-                DEBUG("Created new InterposeInputStream: %s%n", name);
+                DEBUG("Created new LoggingInputStream: %s%n", name);
             }
             return in;
         }