|
27 | 27 | * 5026830 5023243 5070673 4052517 4811767 6192449 6397034 6413313 |
28 | 28 | * 6464154 6523983 6206031 4960438 6631352 6631966 6850957 6850958 |
29 | 29 | * 4947220 7018606 7034570 4244896 5049299 8003488 8054494 8058464 |
30 | | - * 8067796 8224905 8263729 8265173 8282219 |
| 30 | + * 8067796 8224905 8263729 8265173 8282219 8368192 |
31 | 31 | * @key intermittent |
32 | 32 | * @summary Basic tests for Process and Environment Variable code |
33 | 33 | * @modules java.base/java.lang:open |
@@ -759,30 +759,29 @@ private static boolean matches(String str, String regex) { |
759 | 759 | return Pattern.compile(regex).matcher(str).find(); |
760 | 760 | } |
761 | 761 |
|
762 | | - private static String matchAndExtract(String str, String regex) { |
763 | | - Matcher matcher = Pattern.compile(regex).matcher(str); |
764 | | - if (matcher.find()) { |
765 | | - return matcher.group(); |
766 | | - } else { |
767 | | - return ""; |
768 | | - } |
| 762 | + // Return the string with the matching regex removed |
| 763 | + private static String matchAndRemove(String str, String regex) { |
| 764 | + return Pattern.compile(regex) |
| 765 | + .matcher(str) |
| 766 | + .replaceAll(""); |
769 | 767 | } |
770 | 768 |
|
771 | 769 | /* Only used for Mac OS X -- |
772 | | - * Mac OS X (may) add the variable __CF_USER_TEXT_ENCODING to an empty |
773 | | - * environment. The environment variable JAVA_MAIN_CLASS_<pid> may also |
774 | | - * be set in Mac OS X. |
775 | | - * Remove them both from the list of env variables |
| 770 | + * Mac OS X (may) add the variables: __CF_USER_TEXT_ENCODING, JAVA_MAIN_CLASS_<pid>, |
| 771 | + * and TMPDIR. |
| 772 | + * Remove them from the list of env variables |
776 | 773 | */ |
777 | 774 | private static String removeMacExpectedVars(String vars) { |
778 | 775 | // Check for __CF_USER_TEXT_ENCODING |
779 | | - String cleanedVars = vars.replace("__CF_USER_TEXT_ENCODING=" |
780 | | - +cfUserTextEncoding+",",""); |
| 776 | + String cleanedVars = matchAndRemove(vars, |
| 777 | + "__CF_USER_TEXT_ENCODING=" + cfUserTextEncoding + ","); |
781 | 778 | // Check for JAVA_MAIN_CLASS_<pid> |
782 | | - String javaMainClassStr |
783 | | - = matchAndExtract(cleanedVars, |
784 | | - "JAVA_MAIN_CLASS_\\d+=Basic.JavaChild,"); |
785 | | - return cleanedVars.replace(javaMainClassStr,""); |
| 779 | + cleanedVars = matchAndRemove(cleanedVars, |
| 780 | + "JAVA_MAIN_CLASS_\\d+=Basic.JavaChild,"); |
| 781 | + // Check and remove TMPDIR |
| 782 | + cleanedVars = matchAndRemove(cleanedVars, |
| 783 | + "TMPDIR=[^,]*,"); |
| 784 | + return cleanedVars; |
786 | 785 | } |
787 | 786 |
|
788 | 787 | /* Only used for AIX -- |
|
0 commit comments