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

Use InvalidEndpointRequestException for MetricsEndpoint.metric() #14291

Closed
wants to merge 1 commit into from

Conversation

izeye
Copy link
Contributor

@izeye izeye commented Sep 3, 2018

This PR changes to use InvalidEndpointRequestException for MetricsEndpoint.metric() instead of Assert as the Assert will end up with responding with 500 for invalid requests, not 400.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Sep 3, 2018
Copy link
Member

@snicoll snicoll left a comment

Choose a reason for hiding this comment

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

Well spotted again. I've added a suggestion.

@@ -80,8 +80,12 @@ private String getName(Meter meter) {
@ReadOperation
public MetricResponse metric(@Selector String requiredMetricName,
@Nullable List<String> tag) {
Assert.isTrue(tag == null || tag.stream().allMatch((t) -> t.contains(":")),
"Each tag parameter must be in the form key:value");
if (tag != null && tag.stream().anyMatch((t) -> !t.contains(":"))) {
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps we should move that to the parseTag method and add a test for it? the existing code that checks there is : in the String is a bit weak as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@snicoll Thanks for the quick feedback! I updated as you suggested.

@snicoll snicoll added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Sep 4, 2018
@snicoll snicoll self-assigned this Sep 4, 2018
@snicoll snicoll added this to the 2.0.5 milestone Sep 4, 2018
@snicoll
Copy link
Member

snicoll commented Sep 4, 2018

Looks good @izeye, thanks again!

snicoll added a commit that referenced this pull request Sep 4, 2018
* pr/14291:
  Use InvalidEndpointRequestException for MetricsEndpoint
@snicoll snicoll closed this in 3eef927 Sep 4, 2018
@izeye izeye deleted the metrics-endpoint-metric branch September 4, 2018 06:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants