Skip to content

Commit

Permalink
8316540: StoreReproducibilityTest fails on some locales
Browse files Browse the repository at this point in the history
Reviewed-by: joehw, jlu, jpai, alanb
  • Loading branch information
naotoj committed Sep 22, 2023
1 parent b66ded9 commit f7578e8
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions test/jdk/java/util/Properties/StoreReproducibilityTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -44,7 +44,7 @@
/*
* @test
* @summary Tests that the Properties.store() APIs generate output that is reproducible
* @bug 8231640 8282023
* @bug 8231640 8282023 8316540
* @library /test/lib
* @run driver StoreReproducibilityTest
*/
Expand Down Expand Up @@ -92,7 +92,7 @@ private static void testWithoutSecurityManager() throws Exception {
for (int i = 0; i < 5; i++) {
final Path tmpFile = Files.createTempFile("8231640", ".props");
storedFiles.add(tmpFile);
final ProcessBuilder processBuilder = ProcessTools.createJavaProcessBuilder(
final ProcessBuilder processBuilder = ProcessTools.createTestJvm(
"-D" + SYS_PROP_JAVA_PROPERTIES_DATE + "=" + sysPropVal,
StoreTest.class.getName(),
tmpFile.toString(),
Expand Down Expand Up @@ -134,10 +134,10 @@ private static void testWithSecMgrExplicitPermission() throws Exception {
for (int i = 0; i < 5; i++) {
final Path tmpFile = Files.createTempFile("8231640", ".props");
storedFiles.add(tmpFile);
final ProcessBuilder processBuilder = ProcessTools.createJavaProcessBuilder(
final ProcessBuilder processBuilder = ProcessTools.createTestJvm(
"-D" + SYS_PROP_JAVA_PROPERTIES_DATE + "=" + sysPropVal,
"-Djava.security.manager",
"-Djava.security.policy=" + policyFile.toString(),
"-Djava.security.policy=" + policyFile,
StoreTest.class.getName(),
tmpFile.toString(),
i % 2 == 0 ? "--use-outputstream" : "--use-writer");
Expand Down Expand Up @@ -178,10 +178,10 @@ private static void testWithSecMgrNoSpecificPermission() throws Exception {
for (int i = 0; i < 5; i++) {
final Path tmpFile = Files.createTempFile("8231640", ".props");
storedFiles.add(tmpFile);
final ProcessBuilder processBuilder = ProcessTools.createJavaProcessBuilder(
final ProcessBuilder processBuilder = ProcessTools.createTestJvm(
"-D" + SYS_PROP_JAVA_PROPERTIES_DATE + "=" + sysPropVal,
"-Djava.security.manager",
"-Djava.security.policy=" + policyFile.toString(),
"-Djava.security.policy=" + policyFile,
StoreTest.class.getName(),
tmpFile.toString(),
i % 2 == 0 ? "--use-outputstream" : "--use-writer");
Expand All @@ -208,7 +208,7 @@ private static void testBlankSysPropValue() throws Exception {
for (int i = 0; i < 2; i++) {
final Path tmpFile = Files.createTempFile("8231640", ".props");
storedFiles.add(tmpFile);
final ProcessBuilder processBuilder = ProcessTools.createJavaProcessBuilder(
final ProcessBuilder processBuilder = ProcessTools.createTestJvm(
"-D" + SYS_PROP_JAVA_PROPERTIES_DATE + "=" + sysPropVal,
StoreTest.class.getName(),
tmpFile.toString(),
Expand Down Expand Up @@ -240,8 +240,9 @@ private static void testBlankSysPropValue() throws Exception {
private static void testEmptySysPropValue() throws Exception {
for (int i = 0; i < 2; i++) {
final Path tmpFile = Files.createTempFile("8231640", ".props");
final ProcessBuilder processBuilder = ProcessTools.createJavaProcessBuilder(
"-D" + SYS_PROP_JAVA_PROPERTIES_DATE + "=" + "",
final ProcessBuilder processBuilder = ProcessTools.createTestJvm(
"-D" + SYS_PROP_JAVA_PROPERTIES_DATE + "=",
"-Duser.timezone=UTC",
StoreTest.class.getName(),
tmpFile.toString(),
i % 2 == 0 ? "--use-outputstream" : "--use-writer");
Expand Down Expand Up @@ -271,7 +272,7 @@ private static void testNonDateSysPropValue() throws Exception {
for (int i = 0; i < 2; i++) {
final Path tmpFile = Files.createTempFile("8231640", ".props");
storedFiles.add(tmpFile);
final ProcessBuilder processBuilder = ProcessTools.createJavaProcessBuilder(
final ProcessBuilder processBuilder = ProcessTools.createTestJvm(
"-D" + SYS_PROP_JAVA_PROPERTIES_DATE + "=" + sysPropVal,
StoreTest.class.getName(),
tmpFile.toString(),
Expand Down Expand Up @@ -300,7 +301,7 @@ private static void testMultiLineSysPropValue() throws Exception {
for (int i = 0; i < 2; i++) {
final Path tmpFile = Files.createTempFile("8231640", ".props");
storedFiles.add(tmpFile);
final ProcessBuilder processBuilder = ProcessTools.createJavaProcessBuilder(
final ProcessBuilder processBuilder = ProcessTools.createTestJvm(
"-D" + SYS_PROP_JAVA_PROPERTIES_DATE + "=" + sysPropVal,
StoreTest.class.getName(),
tmpFile.toString(),
Expand Down Expand Up @@ -342,7 +343,7 @@ private static void testBackSlashInSysPropValue() throws Exception {
for (int i = 0; i < 2; i++) {
final Path tmpFile = Files.createTempFile("8231640", ".props");
storedFiles.add(tmpFile);
final ProcessBuilder processBuilder = ProcessTools.createJavaProcessBuilder(
final ProcessBuilder processBuilder = ProcessTools.createTestJvm(
"-D" + SYS_PROP_JAVA_PROPERTIES_DATE + "=" + sysPropVal,
StoreTest.class.getName(),
tmpFile.toString(),
Expand Down Expand Up @@ -416,6 +417,9 @@ private static void assertExpectedComment(final Path destFile,
* Verifies that the date comment in the {@code destFile} can be parsed using the
* "EEE MMM dd HH:mm:ss zzz uuuu" format and the time represented by it is {@link Date#after(Date) after}
* the passed {@code date}
* The JVM runtime to invoke this method should set the time zone to UTC, i.e, specify
* "-Duser.timezone=UTC" at the command line. Otherwise, it will fail with some time
* zones that have ambiguous short names, such as "IST"
*/
private static void assertCurrentDate(final Path destFile, final Date date) throws Exception {
final String dateComment = findNthComment(destFile, 2);
Expand All @@ -440,7 +444,7 @@ private static void assertCurrentDate(final Path destFile, final Date date) thro
private static String findNthComment(Path file, int commentIndex) throws IOException {
List<String> comments = new ArrayList<>();
try (final BufferedReader reader = Files.newBufferedReader(file)) {
String line = null;
String line;
while ((line = reader.readLine()) != null) {
if (line.startsWith("#")) {
comments.add(line.substring(1));
Expand Down

3 comments on commit f7578e8

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zzambers
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/backport jdk21u

@openjdk
Copy link

@openjdk openjdk bot commented on f7578e8 Sep 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zzambers the backport was successfully created on the branch zzambers-backport-f7578e80 in my personal fork of openjdk/jdk21u. To create a pull request with this backport targeting openjdk/jdk21u:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit f7578e80 from the openjdk/jdk repository.

The commit being backported was authored by Naoto Sato on 22 Sep 2023 and was reviewed by Joe Wang, Justin Lu, Jaikiran Pai and Alan Bateman.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk21u:

$ git fetch https://github.com/openjdk-bots/jdk21u.git zzambers-backport-f7578e80:zzambers-backport-f7578e80
$ git checkout zzambers-backport-f7578e80
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk21u.git zzambers-backport-f7578e80

Please sign in to comment.