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

Support underscores in request ids. #176

Merged
merged 1 commit into from
Mar 1, 2017
Merged

Conversation

archolewa
Copy link
Contributor

--Some clients want to have underscores in their unique request ids.
Since it's kind of arbitrary what characters we allow or don't allow in
the request header, we've added it.

Copy link
Collaborator

@cdeszaq cdeszaq left a comment

Choose a reason for hiding this comment

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

Could we get a changelog entry for this, and hopefully a test case?

@michael-mclawhorn
Copy link
Contributor

I agree with Rick's comment.

Copy link
Member

@aklish aklish left a comment

Choose a reason for hiding this comment

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

Approved - but also agree changelog at a minimum and test case would be nice.

@archolewa archolewa force-pushed the add-dashes-headers branch 2 times, most recently from 5d73f39 to c0c45d6 Compare February 28, 2017 20:20
@Unroll
def "The BardLoggingFilter does not add a malformed requestId '#requestId' to MDC"() {
given: "A ContainerRequestContext with the specified malformed requestId"
MultivaluedHashMap<String, String> fakeHeaders = new MultivaluedHashMap<>()
Copy link
Collaborator

Choose a reason for hiding this comment

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

This shadows the class-level fakeHeaders map. Do we need this declaration in this test?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could catch. It should be using the class level fakeHeaders

filter.filter(requestContext)

then:
!MDC.get(RequestLog.ID_KEY) || !MDC.get(RequestLog.ID_KEY).startsWith(requestId)
Copy link
Collaborator

Choose a reason for hiding this comment

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

You could simplify this by using the null-safe coalescence operator:

!MDC.get(RequestLog.ID_KEY)?.startsWith(requestId)

If MDC.get(RequestLog.ID_KEY) comes back null, it returns false and doesn't call .startsWith(...), preventing the NPE.

@cdeszaq
Copy link
Collaborator

cdeszaq commented Mar 1, 2017

Just the issue with shadowing. Once that's addressed, merge away.

--Some clients want to have underscores in their unique request ids.
Since it's kind of arbitrary what characters we allow or don't allow in
the request header, we've added it.
@archolewa archolewa merged commit ddd2ba8 into master Mar 1, 2017
@archolewa archolewa deleted the add-dashes-headers branch March 1, 2017 16:00
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.

None yet

4 participants