Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JENKINS-29034] - Modify filename to include date and time #38

Merged
merged 2 commits into from Jun 25, 2015

Conversation

recena
Copy link

@recena recena commented Jun 23, 2015

@recena recena closed this Jun 23, 2015
@recena recena reopened this Jun 23, 2015
@recena
Copy link
Author

recena commented Jun 23, 2015

@reviewbybees Could you review this?, specially @stephenc @aheritier @ndeloof and others from Support Engineering Team.

Read this to get more information https://github.com/cloudbees/cloudbees-support-plugin/pull/5

// let the provider name it
filename = supportProvider.getName();
filename = supportProvider.getName() + "_" + dateFormat.format(new Date());
Copy link
Member

Choose a reason for hiding this comment

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

You need the date always, not just for those coming from the supportProvider. Do the date injection in the addHeader line not here

@jenkinsadmin
Copy link
Member

Thank you for a pull request! Please check this document for how the Jenkins project handles pull requests

@christ66 christ66 changed the title Related to [JENKINS-29034] - Modify filename to include date and time [JENKINS-29034] - Modify filename to include date and time Jun 23, 2015
@@ -146,8 +152,10 @@ public void doDownload(StaplerRequest req, StaplerResponse rsp) throws ServletEx
if (supportPlugin != null) {
SupportProvider supportProvider = supportPlugin.getSupportProvider();
if (supportProvider != null) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd_HH.mm.ss");
Copy link
Member

Choose a reason for hiding this comment

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

Creating a new SimpleDateFormat can be an expensive operation especially every time the doDownload link is clicked. I would recommend using a static final field since the format for the date/time never changes.

Copy link
Contributor

Choose a reason for hiding this comment

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

but SimpleDateFormat is not thread safe, so general recommendation is to have one and clone it for use. Anyway, as this isn't an intensively used URL all this would be premature optimization imho

Copy link
Member

Choose a reason for hiding this comment

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

Agree with @ndeloof

  1. This action is not heavily used, we can incur the cost of creating a new date format every time it is invoked. Users typically only access this link once or twice when they have an issue... and they are not performance sensitive compared to the time they will spend downloading the bundle
  2. The instance is not thread safe and is advertised as not thread safe, so if used form a static field you would need to add locking and synchronization which could potentially interfere with the issue the customer is encountering and prevent the generation of a bundle.

Copy link
Author

Choose a reason for hiding this comment

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

@christ66 This part of the plugin is executed periodically and we use SimpleDateFormat.

@recena
Copy link
Author

recena commented Jun 24, 2015

@stephenc Could you review my last commit? Thanks.

@christ66
Copy link
Member

👍

1 similar comment
@stephenc
Copy link
Member

👍

@recena
Copy link
Author

recena commented Jun 25, 2015

@stephenc @christ66 Thanks so much for your feedback.

@stephenc Could you merge it? Thanks in advance.

christ66 added a commit that referenced this pull request Jun 25, 2015
[JENKINS-29034] - Modify filename to include date and time
@christ66 christ66 merged commit fc49e8e into jenkinsci:master Jun 25, 2015
@recena
Copy link
Author

recena commented Jun 25, 2015

@christ66 Thanks so much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants