-
Notifications
You must be signed in to change notification settings - Fork 16
GRPC authority header seems to not have host component sometimes. #87
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -153,29 +153,29 @@ private Optional<String> getGrpcAuthority(Event event) { | |
|
|
||
| private Optional<String> getSanitizedHostValue(String value) { | ||
| if (StringUtils.isNotBlank(value)) { | ||
| String host = sanitizeHostValue(value); | ||
| if (!LOCALHOST.equalsIgnoreCase(host)) { | ||
| return Optional.of(host); | ||
| Optional<String> host = sanitizeHostValue(value); | ||
| if (host.isPresent() && !LOCALHOST.equalsIgnoreCase(host.get())) { | ||
| return host; | ||
| } | ||
| } | ||
| return Optional.empty(); | ||
| } | ||
|
|
||
| private String sanitizeHostValue(String host) { | ||
| private Optional<String> sanitizeHostValue(String host) { | ||
| if (host.contains(COLON) && !host.startsWith(COLON)) { | ||
| return COLON_SPLITTER.splitToList(host).get(0); | ||
| return Optional.ofNullable(COLON_SPLITTER.splitToList(host).get(0)); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If |
||
| } | ||
|
|
||
| // the value is a URL, just return the authority part of it. | ||
| try { | ||
| URI uri = new URI(host); | ||
| if (uri.getScheme() != null) { | ||
| return uri.getHost(); | ||
| return Optional.ofNullable(uri.getHost()); | ||
| } | ||
| return host; | ||
| return Optional.of(host); | ||
| } catch (URISyntaxException ignore) { | ||
| // ignore | ||
| return host; | ||
| return Optional.empty(); | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,6 +12,6 @@ sourceSets { | |
| } | ||
|
|
||
| dependencies { | ||
| api( "org.apache.avro:avro:1.9.2") | ||
| api( "org.apache.avro:avro:1.10.1") | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need conditon -
StringUtils.isEmpty(host.get())- for case where host is notnullbut an empty""string?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
equalsIgnoreCase()will take care of those.