diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2015-03-20 16:25:10 +0100 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2015-03-20 16:25:10 +0100 |
commit | 66de27e8ad72f9f7c236d545d7c75f2c9c8399e6 (patch) | |
tree | 2bde85ed241b951a67922c94d17604ef234ceb6d | |
parent | 8ad05540591fbb6fcbdad4924888dbe645a839db (diff) | |
download | sonarqube-66de27e8ad72f9f7c236d545d7c75f2c9c8399e6.tar.gz sonarqube-66de27e8ad72f9f7c236d545d7c75f2c9c8399e6.zip |
Thread-safe JsonComparison
-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; |