提交 191c71c7 编写于 作者: B bmoloden

8160119: Utils.tryFindJvmPid sometimes find incorrect pid

Summary: Fixed pattern
Reviewed-by: iignatyev, dholmes
上级 12e31f08
/* /*
* Copyright (c) 2013, 2014, 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -260,8 +260,8 @@ public final class Utils { ...@@ -260,8 +260,8 @@ public final class Utils {
output = ProcessTools.executeProcess(jcmdLauncher.getCommand()); output = ProcessTools.executeProcess(jcmdLauncher.getCommand());
output.shouldHaveExitValue(0); output.shouldHaveExitValue(0);
// Search for a line starting with numbers (pid), follwed by the key. // Search for a line starting with numbers (pid), followed by the key.
Pattern pattern = Pattern.compile("([0-9]+)\\s.*(" + key + ").*\\r?\\n"); Pattern pattern = Pattern.compile("^([0-9]+)\\s.*(" + key + ")", Pattern.MULTILINE);
Matcher matcher = pattern.matcher(output.getStdout()); Matcher matcher = pattern.matcher(output.getStdout());
int pid = -1; int pid = -1;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册