Skip to content

Commit

Permalink
Access default value through a static variable for cleaner access, an…
Browse files Browse the repository at this point in the history
…d removing the need to initialise unnecessary class instances
  • Loading branch information
Nathan Dines committed Feb 24, 2019
1 parent 21bdeb9 commit 44bf265
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,12 @@ public String getIamMfaSerialNumber() {

@NonNull
public Integer getStsTokenDuration() {
DescriptorImpl descriptor = new DescriptorImpl();
return stsTokenDuration == null ? descriptor.defaultStsTokenDuration() : stsTokenDuration;
return stsTokenDuration == null ? DescriptorImpl.defaultStsTokenDuration : stsTokenDuration;
}

@DataBoundSetter
public void setStsTokenDuration(@NonNull Integer stsTokenDuration) {
DescriptorImpl descriptor = new DescriptorImpl();
this.stsTokenDuration = stsTokenDuration.equals(descriptor.defaultStsTokenDuration()) ? null : stsTokenDuration;
this.stsTokenDuration = stsTokenDuration.equals(DescriptorImpl.defaultStsTokenDuration) ? null : stsTokenDuration;
}

public boolean requiresToken() {
Expand Down Expand Up @@ -192,9 +190,7 @@ public String getDisplayName() {
return Messages.AWSCredentialsImpl_DisplayName();
}

public Integer defaultStsTokenDuration() {
return STS_CREDENTIALS_DURATION_SECONDS;
}
public static final Integer defaultStsTokenDuration = STS_CREDENTIALS_DURATION_SECONDS;

public FormValidation doCheckSecretKey(@QueryParameter("accessKey") final String accessKey,
@QueryParameter("iamRoleArn") final String iamRoleArn,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
<f:textbox/>
</f:entry>
<f:entry title="${%STS Token Duration (sec)}" field="stsTokenDuration">
<f:textbox default="${descriptor.defaultStsTokenDuration()}"/>
<f:textbox default="${descriptor.defaultStsTokenDuration}"/>
</f:entry>
</f:advanced>
</f:section>
Expand Down

0 comments on commit 44bf265

Please sign in to comment.