changeset 5580:2281f5670cc5

6563318: RMI data sanitization Reviewed-by: ahgross, hawtin, mchung, smarks
author dmocek
date Mon, 19 Nov 2012 13:52:08 -0800
parents e605d17466e4
children 49a37df9e80f
files src/share/classes/sun/rmi/transport/proxy/CGIHandler.java test/java/rmi/testlibrary/JavaVM.java
diffstat 2 files changed, 42 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/sun/rmi/transport/proxy/CGIHandler.java	Tue Nov 27 21:51:23 2012 +0100
+++ b/src/share/classes/sun/rmi/transport/proxy/CGIHandler.java	Mon Nov 19 13:52:08 2012 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -150,7 +150,7 @@
                     returnServerError(e.getMessage());
                 }
             else
-                returnClientError("invalid command: " + command);
+                returnClientError("invalid command.");
         } catch (Exception e) {
             returnServerError("internal error: " + e.getMessage());
         }
@@ -217,7 +217,7 @@
         try {
             port = Integer.parseInt(param);
         } catch (NumberFormatException e) {
-            throw new CGIClientException("invalid port number: " + param);
+            throw new CGIClientException("invalid port number.");
         }
         if (port <= 0 || port > 0xFFFF)
             throw new CGIClientException("invalid port: " + port);
--- a/test/java/rmi/testlibrary/JavaVM.java	Tue Nov 27 21:51:23 2012 +0100
+++ b/test/java/rmi/testlibrary/JavaVM.java	Mon Nov 19 13:52:08 2012 -0800
@@ -109,6 +109,14 @@
         return TestLibrary.getExtraProperty("jcov.options","");
     }
 
+    public void start(Runnable runnable) throws IOException {
+        if (runnable == null) {
+            throw new NullPointerException("Runnable cannot be null.");
+        }
+
+        start();
+        new JavaVMCallbackHandler(runnable).start();
+    }
 
     /**
      * Exec the VM as specified in this object's constructor.
@@ -171,4 +179,35 @@
     protected Process getVM() {
         return vm;
     }
+
+    /**
+     * Handles calling the callback.
+     */
+    private class JavaVMCallbackHandler extends Thread {
+        Runnable runnable;
+
+        JavaVMCallbackHandler(Runnable runnable) {
+            this.runnable = runnable;
+        }
+
+
+        /**
+         * Wait for the Process to terminate and notify the callback.
+         */
+        @Override
+        public void run() {
+            if (vm != null) {
+                try {
+                    vm.waitFor();
+                } catch(InterruptedException ie) {
+                    // Restore the interrupted status
+                    Thread.currentThread().interrupt();
+                }
+            }
+
+            if (runnable != null) {
+                runnable.run();
+            }
+        }
+    }
 }