8160119: Utils.tryFindJvmPid sometimes find incorrect pid
authorbmoloden
Wed, 20 Jul 2016 14:47:53 +0300
changeset 39990 75246d451c39
parent 39989 7356538f8c3f
child 39991 d89a486fa0d2
8160119: Utils.tryFindJvmPid sometimes find incorrect pid Summary: Fixed pattern Reviewed-by: iignatyev, dholmes
hotspot/test/testlibrary/jdk/test/lib/Utils.java
--- a/hotspot/test/testlibrary/jdk/test/lib/Utils.java	Tue Jul 19 22:14:22 2016 +0200
+++ b/hotspot/test/testlibrary/jdk/test/lib/Utils.java	Wed Jul 20 14:47:53 2016 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2016, 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
@@ -317,8 +317,8 @@
             output = ProcessTools.executeProcess(jcmdLauncher.getCommand());
             output.shouldHaveExitValue(0);
 
-            // Search for a line starting with numbers (pid), follwed by the key.
-            Pattern pattern = Pattern.compile("([0-9]+)\\s.*(" + key + ").*\\r?\\n");
+            // Search for a line starting with numbers (pid), followed by the key.
+            Pattern pattern = Pattern.compile("^([0-9]+)\\s.*(" + key + ")", Pattern.MULTILINE);
             Matcher matcher = pattern.matcher(output.getStdout());
 
             int pid = -1;