Skip to content

Commit

Permalink
Merge pull request #115 from testmycode/safe-deadline
Browse files Browse the repository at this point in the history
Make parsing exercise deadlines thread safe
  • Loading branch information
nygrenh authored Oct 14, 2016
2 parents 233303c + 6f85e5e commit 784fe8d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/main/java/fi/helsinki/cs/tmc/core/domain/Exercise.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
public class Exercise implements Serializable {

private static final Logger logger = LoggerFactory.getLogger(Exercise.class);
private static final DateFormat DATE_FORMAT =
new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSX");
private static final String DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSSX";

private int id;
private String name;
Expand Down Expand Up @@ -138,8 +137,9 @@ public Date getDeadlineDate() {
if (Strings.isNullOrEmpty(this.getDeadline())) {
return null;
}
final SimpleDateFormat dateFormatter = new SimpleDateFormat(DATE_FORMAT);
try {
return DATE_FORMAT.parse(this.getDeadline());
return dateFormatter.parse(this.getDeadline());
} catch (ParseException ex) {
logger.warn("Failed to parse date {}", this.getDeadline(), ex);
return null;
Expand Down

0 comments on commit 784fe8d

Please sign in to comment.