changeset 47670:3937719e6371

8180310: TestSocketFactory null pointer when updating match bytes Reviewed-by: dfuchs
author rriggs
date Sun, 29 Oct 2017 18:31:55 -0400
parents 304ef03403b1
children 5d798d729fec
files test/jdk/java/rmi/testlibrary/TestSocketFactory.java
diffstat 1 files changed, 8 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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;
         }