Skip to content

MINOR: Remove Deadcode in NioTransport CORS#34324

Merged
original-brownbear merged 3 commits intoelastic:masterfrom
original-brownbear:deadcode-nio-http
Oct 27, 2018
Merged

MINOR: Remove Deadcode in NioTransport CORS#34324
original-brownbear merged 3 commits intoelastic:masterfrom
original-brownbear:deadcode-nio-http

Conversation

@original-brownbear
Copy link
Copy Markdown
Contributor

* Same as #34134 but for nio transport
@elasticmachine
Copy link
Copy Markdown
Collaborator

Pinging @elastic/es-distributed

Copy link
Copy Markdown
Member

@danielmitterdorfer danielmitterdorfer left a comment

Choose a reason for hiding this comment

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

I left comments around the removal of null origins.

private boolean setOrigin(final HttpResponse response) {
final String origin = request.headers().get(HttpHeaderNames.ORIGIN);
if (!Strings.isNullOrEmpty(origin)) {
if ("null".equals(origin) && config.isNullOriginAllowed()) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This seems needed? Or is this handled in a different way?

return true;
}

if ("null".equals(origin) && config.isNullOriginAllowed()) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This seems needed? Or is this handled in a different way?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@danielmitterdorfer actually this is always false (there's no code assigning anything to that field in the builder) so this must be handled a different way or we have a bug on our hands ... (looking into that)
Looking at the Netty code it's unused there as well ... I guess I could drop this logic there also?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It appears unused indeed and I think we don't want/need it but maybe @tbrooks8 or @jasontedor can chime in here?

Copy link
Copy Markdown
Contributor Author

@original-brownbear original-brownbear Oct 5, 2018

Choose a reason for hiding this comment

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

I can't find a single usage of allowNullOrigin() (which would set the return of isNullOriginAllowed to true) in git in any revision. I also don't see why we'd want to support "null" for the origin really? (plus it seems this was never set to true before anyway)

@Tim-Brooks
Copy link
Copy Markdown
Contributor

I’ll take a look at this in the next few days.

For context, I’m pretty sure that this class is copied from netty. So that is why there is unused code.

At some point we need to consolidate this into a single class that lives in server and operates on the elasticsearch request object.

@original-brownbear
Copy link
Copy Markdown
Contributor Author

@tbrooks8 ping :)

For what it's worth I'm pretty sure this is copied from Netty since this method was never used so we're probably good removing it here and then eventually just drying this class up as you suggest?

@Tim-Brooks
Copy link
Copy Markdown
Contributor

I'll take a look at this tomorrow.

@colings86 colings86 added v6.6.0 and removed v6.5.0 labels Oct 25, 2018
Copy link
Copy Markdown
Contributor

@Tim-Brooks Tim-Brooks left a comment

Choose a reason for hiding this comment

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

LGTM

@original-brownbear
Copy link
Copy Markdown
Contributor Author

@tbrooks8 thanks!

@original-brownbear original-brownbear merged commit 71dddfd into elastic:master Oct 27, 2018
@original-brownbear original-brownbear deleted the deadcode-nio-http branch October 27, 2018 12:54
kcm pushed a commit that referenced this pull request Oct 30, 2018
original-brownbear added a commit that referenced this pull request Nov 5, 2018
* Same as #34324 for the Netty transport, the `isNullOriginAllowed` setting is always false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Distributed/Network Http and internode communication implementations >non-issue v6.6.0 v7.0.0-beta1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants