changeset 11269:b13201daee59

8068275: Some tests failed after JDK-8063104 Reviewed-by: azvegint, yan
author serb
date Thu, 25 Dec 2014 22:48:13 +0300
parents fa40ff9d941b
children d5cb5fb925a9
files test/java/awt/regtesthelpers/Util.java
diffstat 1 files changed, 10 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/test/java/awt/regtesthelpers/Util.java	Thu Dec 25 14:54:32 2014 +0300
+++ b/test/java/awt/regtesthelpers/Util.java	Thu Dec 25 22:48:13 2014 +0300
@@ -76,12 +76,17 @@
 public final class Util {
     private Util() {} // this is a helper class with static methods :)
 
+    private volatile static Robot robot;
+
     /*
      * @throws RuntimeException when creation failed
      */
     public static Robot createRobot() {
         try {
-            return new Robot();
+            if (robot == null) {
+                robot = new Robot();
+            }
+            return robot;
         } catch (AWTException e) {
             throw new RuntimeException("Error: unable to create robot", e);
         }
@@ -200,7 +205,10 @@
         return false;
     }
 
-    public static void waitForIdle(final Robot robot) {
+    public static void waitForIdle(Robot robot) {
+        if (robot == null) {
+            robot = createRobot();
+        }
         robot.waitForIdle();
     }