Skip to content

Commit 218e82c

Browse files
author
Roger Riggs
committed
8368192: Test java/lang/ProcessBuilder/Basic.java#id0 fails with Exception: Stack trace
Reviewed-by: jpai, stuefe
1 parent 82bdef1 commit 218e82c

File tree

2 files changed

+17
-19
lines changed

2 files changed

+17
-19
lines changed

test/jdk/ProblemList.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,6 @@ java/lang/invoke/LFCaching/LFMultiThreadCachingTest.java 8151492 generic-
529529
java/lang/invoke/LFCaching/LFGarbageCollectedTest.java 8078602 generic-all
530530
java/lang/invoke/lambda/LambdaFileEncodingSerialization.java 8249079 linux-all
531531
java/lang/invoke/RicochetTest.java 8251969 generic-all
532-
java/lang/ProcessBuilder/Basic.java#id0 8368192 macosx-all
533532

534533
############################################################################
535534

test/jdk/java/lang/ProcessBuilder/Basic.java

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
* 6464154 6523983 6206031 4960438 6631352 6631966 6850957 6850958
2929
* 4947220 7018606 7034570 4244896 5049299 8003488 8054494 8058464
3030
* 8067796 8224905 8263729 8265173 8272600 8231297 8282219 8285517
31-
* 8352533
31+
* 8352533 8368192
3232
* @key intermittent
3333
* @summary Basic tests for Process and Environment Variable code
3434
* @modules java.base/java.lang:open
@@ -777,30 +777,29 @@ private static boolean matches(String str, String regex) {
777777
return Pattern.compile(regex).matcher(str).find();
778778
}
779779

780-
private static String matchAndExtract(String str, String regex) {
781-
Matcher matcher = Pattern.compile(regex).matcher(str);
782-
if (matcher.find()) {
783-
return matcher.group();
784-
} else {
785-
return "";
786-
}
780+
// Return the string with the matching regex removed
781+
private static String matchAndRemove(String str, String regex) {
782+
return Pattern.compile(regex)
783+
.matcher(str)
784+
.replaceAll("");
787785
}
788786

789787
/* Only used for Mac OS X --
790-
* Mac OS X (may) add the variable __CF_USER_TEXT_ENCODING to an empty
791-
* environment. The environment variable JAVA_MAIN_CLASS_<pid> may also
792-
* be set in Mac OS X.
793-
* Remove them both from the list of env variables
788+
* Mac OS X (may) add the variables: __CF_USER_TEXT_ENCODING, JAVA_MAIN_CLASS_<pid>,
789+
* and TMPDIR.
790+
* Remove them from the list of env variables
794791
*/
795792
private static String removeMacExpectedVars(String vars) {
796793
// Check for __CF_USER_TEXT_ENCODING
797-
String cleanedVars = vars.replace("__CF_USER_TEXT_ENCODING="
798-
+cfUserTextEncoding+",","");
794+
String cleanedVars = matchAndRemove(vars,
795+
"__CF_USER_TEXT_ENCODING=" + cfUserTextEncoding + ",");
799796
// Check for JAVA_MAIN_CLASS_<pid>
800-
String javaMainClassStr
801-
= matchAndExtract(cleanedVars,
802-
"JAVA_MAIN_CLASS_\\d+=Basic.JavaChild,");
803-
return cleanedVars.replace(javaMainClassStr,"");
797+
cleanedVars = matchAndRemove(cleanedVars,
798+
"JAVA_MAIN_CLASS_\\d+=Basic.JavaChild,");
799+
// Check and remove TMPDIR
800+
cleanedVars = matchAndRemove(cleanedVars,
801+
"TMPDIR=[^,]*,");
802+
return cleanedVars;
804803
}
805804

806805
/* Only used for AIX --

0 commit comments

Comments
 (0)