Skip to content

Conversation

@olcbean
Copy link
Contributor

@olcbean olcbean commented Mar 12, 2018

The check if an HTTP method is supported is performed in the RestController ( if a method different that GET/POST is used for _upgrade, the RestController throws "Incorrect HTTP method for uri [/_upgrade] and method [PUT], allowed: [GET, POST]" )
This PR simply removed the unnecessary / unreachable explicit check for the _upgrade endpoint

Relates to #24437

CC @dakrone

@elasticmachine
Copy link
Collaborator

Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually?

1 similar comment
@elasticmachine
Copy link
Collaborator

Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually?

@bleskes
Copy link
Contributor

bleskes commented Mar 12, 2018

@lastticmachine test this please

@bleskes bleskes added the :Core/Infra/REST API REST infrastructure and utilities label Mar 12, 2018
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra

Copy link
Member

@jasontedor jasontedor 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 a suggestion; I’m good either way.

throw new IllegalArgumentException("illegal method [" + request.method() + "] for request [" + request.path() + "]");
}
}
return handlePost(request, client);
Copy link
Member

Choose a reason for hiding this comment

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

Maybe only replace the else statement with assert false?

throw new IllegalArgumentException("illegal method [" + request.method() + "] for request [" + request.path() + "]");
}
assert false;
return null;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would prefer not to use assert false because of the dummy return..

Copy link
Member

Choose a reason for hiding this comment

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

That's fine; throw an AssertionError then. Also, I think that you can keep the existing structure: if / else if / else.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Then the only change is actually the type of the exception which does not make it really simpler ...

@nik9000
Copy link
Member

nik9000 commented Mar 13, 2018

Throwing the assertion communicates very strongly "I don't expect another type of method" so I think it is a positive change. Not a huge change, but a positive one.

@olcbean
Copy link
Contributor Author

olcbean commented Mar 14, 2018

Agreed. But at the same time, the error is thrown only when a handler has been registered to the controller and no handling of the new http method is added to the registerRequest.

I think that it would be cleaner if the handling of GET and POST is split in two dedicated classes (#29062) . Then this check can be removed altogether.
What do you think?

@dakrone
Copy link
Member

dakrone commented Mar 14, 2018

I think that it would be cleaner if the handling of GET and POST is split in two dedicated classes (#29062) . Then this check can be removed altogether.
What do you think?

I think this sounds better to me, I don't like having this class do double-duty

@jasontedor
Copy link
Member

+1

@olcbean
Copy link
Contributor Author

olcbean commented Mar 15, 2018

Thanks everybody!

I will go ahead and close this in favor of #29062.
Once #29062 is implemented, the issue addressed by this PR will be implicitly fixed.

@olcbean olcbean closed this Mar 15, 2018
@javanna
Copy link
Member

javanna commented Mar 15, 2018

++ thanks @olcbean

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Core/Infra/REST API REST infrastructure and utilities

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants