|
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 8272600 8231297 8282219 |
| 30 | + * 8067796 8224905 8263729 8265173 8272600 8231297 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 |
@@ -762,30 +762,29 @@ private static boolean matches(String str, String regex) { |
762 | 762 | return Pattern.compile(regex).matcher(str).find(); |
763 | 763 | } |
764 | 764 |
|
765 | | - private static String matchAndExtract(String str, String regex) { |
766 | | - Matcher matcher = Pattern.compile(regex).matcher(str); |
767 | | - if (matcher.find()) { |
768 | | - return matcher.group(); |
769 | | - } else { |
770 | | - return ""; |
771 | | - } |
| 765 | + // Return the string with the matching regex removed |
| 766 | + private static String matchAndRemove(String str, String regex) { |
| 767 | + return Pattern.compile(regex) |
| 768 | + .matcher(str) |
| 769 | + .replaceAll(""); |
772 | 770 | } |
773 | 771 |
|
774 | 772 | /* Only used for Mac OS X -- |
775 | | - * Mac OS X (may) add the variable __CF_USER_TEXT_ENCODING to an empty |
776 | | - * environment. The environment variable JAVA_MAIN_CLASS_<pid> may also |
777 | | - * be set in Mac OS X. |
778 | | - * Remove them both from the list of env variables |
| 773 | + * Mac OS X (may) add the variables: __CF_USER_TEXT_ENCODING, JAVA_MAIN_CLASS_<pid>, |
| 774 | + * and TMPDIR. |
| 775 | + * Remove them from the list of env variables |
779 | 776 | */ |
780 | 777 | private static String removeMacExpectedVars(String vars) { |
781 | 778 | // Check for __CF_USER_TEXT_ENCODING |
782 | | - String cleanedVars = vars.replace("__CF_USER_TEXT_ENCODING=" |
783 | | - +cfUserTextEncoding+",",""); |
| 779 | + String cleanedVars = matchAndRemove(vars, |
| 780 | + "__CF_USER_TEXT_ENCODING=" + cfUserTextEncoding + ","); |
784 | 781 | // Check for JAVA_MAIN_CLASS_<pid> |
785 | | - String javaMainClassStr |
786 | | - = matchAndExtract(cleanedVars, |
787 | | - "JAVA_MAIN_CLASS_\\d+=Basic.JavaChild,"); |
788 | | - return cleanedVars.replace(javaMainClassStr,""); |
| 782 | + cleanedVars = matchAndRemove(cleanedVars, |
| 783 | + "JAVA_MAIN_CLASS_\\d+=Basic.JavaChild,"); |
| 784 | + // Check and remove TMPDIR |
| 785 | + cleanedVars = matchAndRemove(cleanedVars, |
| 786 | + "TMPDIR=[^,]*,"); |
| 787 | + return cleanedVars; |
789 | 788 | } |
790 | 789 |
|
791 | 790 | /* Only used for AIX -- |
|
0 commit comments