Commit 083ccced authored by Matija Obreza's avatar Matija Obreza
Browse files

FindBugs: DateFormats are not thread safe, string-string comparison

parent ce99f729
......@@ -37,7 +37,7 @@ public class StringSimilarity {
if (s == null || t == null)
return 0;
// Quick check to catch identical objects:
if (s == t)
if (s.equals(t))
return 1;
// avoid exception for single character searches
if (s.length() < 2 || t.length() < 2)
......
......@@ -36,7 +36,12 @@ import org.genesys2.gringlobal.taxonomy.model.SpeciesRow;
public class TaxonomyReader {
/** The Constant sdf. */
private static final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
private static final ThreadLocal<SimpleDateFormat> grinDateFormat = new ThreadLocal<SimpleDateFormat>() {
@Override
protected SimpleDateFormat initialValue() {
return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
}
};
/**
* Returns a {@link CSVReader} that properly handles GRIN-Global taxonomy files in CSV format. It converts \N to <code>null</code> in each row.
......@@ -175,7 +180,7 @@ public class TaxonomyReader {
if (string == null) {
return null;
}
return sdf.parse(string);
return grinDateFormat.get().parse(string);
}
/**
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment