Skip to content

Conversation

@mwinter69
Copy link

Use FastDateFormat from apache which is thread safe

Avoid possible NPE in Node detection
Avoid possible NPE in result (previous logic already avoided it but findbugs still claimed it to be a problem)

Node detection is same for pipeline and freestyle so move it to initData method

properly get displayname of node (jenkinsci#38)
Use FastDateFormat from apache which is thread safe

Avoid possible NPE in Node detection
Avoid possible NPE in result (previous logic already avoided it but findbugs
still claimed it to be a problem)

Node detection is same for pipeline and freestyle so move it to initData
method
@mwinter69 mwinter69 changed the title Build data findbugs: fix issues in Build data Dec 29, 2017
@mwinter69 mwinter69 changed the title findbugs: fix issues in Build data findbugs: fix issues in BuildData Dec 29, 2017
public class BuildData {
// ISO 8601 date format
public transient static final DateFormat DATE_FORMATTER = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
public transient static final FastDateFormat DATE_FORMATTER = FastDateFormat.getInstance("yyyy-MM-dd'T'HH:mm:ss.SSSZ");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure.. the addition of milliseconds can be a breaking change if somebody is parsing the date with a strict parser. I'd suggest extracting the format to configuration if you need the milis part

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, I will leave the format as is for now. Making this configurable could be done with the refactoring of configuration

public class BuildData {
// ISO 8601 date format
public transient static final DateFormat DATE_FORMATTER = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
public transient static final FastDateFormat DATE_FORMATTER = FastDateFormat.getInstance("yyyy-MM-dd'T'HH:mm:ss.SSSZ");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While we'r at it can you restrict it's visibility? The formatter has been made private in #40

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to keep changes in this PR to the findbugs issues. providing a method to access the formatter should be done in a separate PR.

we will make this configurable later
@jakub-bochenski jakub-bochenski merged commit ca7a386 into jenkinsci:master Dec 29, 2017
@mwinter69 mwinter69 deleted the buildData branch December 30, 2017 01:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants