Skip to content

Commit

Permalink
[JENKINS-49176/JENKINS-49185] - Do not cache the SimpleDateFormat for…
Browse files Browse the repository at this point in the history
…mat (JEP-200 & concurrency)
  • Loading branch information
oleg-nenashev committed Jan 26, 2018
1 parent 60842ea commit cf4f17f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
Expand Up @@ -80,8 +80,6 @@ public class LastChangesPublisher extends Recorder implements SimpleBuildStep {

private static final short RECURSION_DEPTH = 50;

private static final DateFormat DATE_FORMAT = DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.DEFAULT);

private String specificRevision; //revision id to crete the diff

private String specificBuild; // create the diff with the revision of an specific build
Expand Down Expand Up @@ -322,7 +320,8 @@ private List<CommitChanges> commitChanges(List<CommitInfo> commitInfoList, Strin
@Override
public int compare(CommitInfo c1, CommitInfo c2) {
try {
return DATE_FORMAT.parse(c1.getCommitDate()).compareTo(DATE_FORMAT.parse(c2.getCommitDate()));
DateFormat format = DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.DEFAULT);
return format.parse(c1.getCommitDate()).compareTo(format.parse(c2.getCommitDate()));
} catch (ParseException e) {
LOG.severe(String.format("Could not parse commit dates %s and %s ", c1.getCommitDate(), c2.getCommitDate()));
return 0;
Expand Down
Expand Up @@ -19,7 +19,6 @@ public class CommitInfo implements Serializable {
private String committerName;
private String committerEmail;
private String commitDate;
private DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.DEFAULT);

@Whitelisted
public String getCommitterName() {
Expand Down Expand Up @@ -66,6 +65,7 @@ public String getCommitMessage() {


public String format(Date date, TimeZone tz) {
DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.DEFAULT);
dateFormat.setTimeZone(tz);
return dateFormat.format(date);
}
Expand Down

0 comments on commit cf4f17f

Please sign in to comment.