|
28 | 28 | * 6464154 6523983 6206031 4960438 6631352 6631966 6850957 6850958 |
29 | 29 | * 4947220 7018606 7034570 4244896 5049299 8003488 8054494 8058464 |
30 | 30 | * 8067796 8224905 8263729 8265173 8272600 8231297 8282219 8285517 |
31 | | - * 8352533 |
| 31 | + * 8352533 8368192 |
32 | 32 | * @key intermittent |
33 | 33 | * @summary Basic tests for Process and Environment Variable code |
34 | 34 | * @modules java.base/java.lang:open |
@@ -777,30 +777,29 @@ private static boolean matches(String str, String regex) { |
777 | 777 | return Pattern.compile(regex).matcher(str).find(); |
778 | 778 | } |
779 | 779 |
|
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(""); |
787 | 785 | } |
788 | 786 |
|
789 | 787 | /* 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 |
794 | 791 | */ |
795 | 792 | private static String removeMacExpectedVars(String vars) { |
796 | 793 | // 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 + ","); |
799 | 796 | // 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; |
804 | 803 | } |
805 | 804 |
|
806 | 805 | /* Only used for AIX -- |
|
0 commit comments