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-61161] Avoid infamous UI connection strategy warning #538

Merged
merged 1 commit into from
Nov 25, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/java/hudson/plugins/ec2/SlaveTemplate.java
Original file line number Diff line number Diff line change
Expand Up @@ -2040,7 +2040,7 @@ public ListBoxModel doFillConnectionStrategyItems(@QueryParameter String connect

public FormValidation doCheckConnectionStrategy(@QueryParameter String connectionStrategy) {
return Stream.of(ConnectionStrategy.values())
.filter(v -> v.equalsName(connectionStrategy))
.filter(v -> v.name().equals(connectionStrategy))
Copy link
Contributor Author

@MRamonLeon MRamonLeon Nov 24, 2020

Choose a reason for hiding this comment

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

  • Previously: Public_IP == PUBLIC_IP ??
  • Now: PUBLIC_IP == PUBLIC_IP ??

See:

Copy link
Member

Choose a reason for hiding this comment

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

is it not the same? why is it fixing the error?

public boolean equalsName(String other) {
return this.name.equals(other);
}

Copy link
Contributor

Choose a reason for hiding this comment

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

I too am interested in Francisco's point

Copy link
Contributor Author

@MRamonLeon MRamonLeon Nov 25, 2020

Choose a reason for hiding this comment

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

equalsName is comparing the text added in the constructor (Public IP lowercase) as you can see above, but the connectionStrategy variable contains the declared name of the enum (PUBLIC IP uppercase), so they were never equals. With name() we use the declared name.

Copy link
Member

Choose a reason for hiding this comment

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

Oh! I see now! Really good point Ramon

Copy link
Contributor

@res0nance res0nance Nov 25, 2020

Choose a reason for hiding this comment

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

Interesting, then shouldn't equals() also produce the desired behaviour?
Edit: Forgot the the other object is simply a string, LGTM. thanks for the explaination

.findFirst()
.map(s -> FormValidation.ok())
.orElse(FormValidation.error("Could not find selected connection strategy"));
Expand Down