diff options
-rw-r--r-- | sonar-testing-harness/src/main/java/org/sonar/test/JsonComparison.java | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/sonar-testing-harness/src/main/java/org/sonar/test/JsonComparison.java b/sonar-testing-harness/src/main/java/org/sonar/test/JsonComparison.java index ca5693d494f..8626253000d 100644 --- a/sonar-testing-harness/src/main/java/org/sonar/test/JsonComparison.java +++ b/sonar-testing-harness/src/main/java/org/sonar/test/JsonComparison.java @@ -25,8 +25,8 @@ import org.json.simple.parser.JSONParser; import javax.annotation.CheckForNull; import javax.annotation.Nullable; +import javax.annotation.concurrent.ThreadSafe; -import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -35,13 +35,9 @@ import java.util.List; import java.util.Map; import java.util.Set; -/** - * Not thread-safe because of field datetimeFormat which is SimpleDateFormat. - */ +@ThreadSafe class JsonComparison { - private static final DateFormat DATETIME_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ"); - private boolean strictTimezone = false; private boolean strictArrayOrder = false; @@ -194,7 +190,7 @@ class JsonComparison { @CheckForNull static Date tryParseDate(String s) { try { - return DATETIME_FORMAT.parse(s); + return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ").parse(s); } catch (ParseException ignored) { // not a datetime return null; |