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

Prefer doIndex over index views #101

Merged
merged 7 commits into from
Jan 18, 2017
Merged

Prefer doIndex over index views #101

merged 7 commits into from
Jan 18, 2017

Conversation

kohsuke
Copy link
Member

@kohsuke kohsuke commented Jan 15, 2017

Adjustment of pull request #97

The goal of #97 was to improve performance of request routing to objects that do not have index views but do have the doIndex method. This is achieved by swapping the priority between those two routes, which was done in 8156216. This is strictly speaking an incompatible change, but in practice acceptable and preferrable because:

  1. no valid code could have existed out there that has both index view and the doIndex method because the latter would have never been invoked
  2. the change makes the relative order of view and web method the same between index (index.jelly vs doIndex) and regular routes (xyz.jelly vs doXyz.)

To make this possible, this PR also converts index view routing and a few other routes that were previously hard-coded in Stapler.tryInvoke into Dispatcher implementations.

For uniformity and to precisely control its priority, this logic should
be a regular Dispatcher, not a hard-coded part of Stapler.tryInvoke()
... for better modularity.

In the future we should allow this behaviour to be modified by the
class, for example via annotation. Some API bound objects like Jenkins
Blue Ocean would prefer not to have this behaviour.
So that the buildDispatchers method look a little manageable
Currently the code performs index view lookup before doIndex handling.
This behaviour is inconsistent with the relative ordering between
xyz.jelly vs doXyz where the latter wins. This behaviour is considered
sensible because it'd allow programmatic check before a view is
rendered by using StaplerRequest.getView().

The code also has a performance improvement effect for those model
objects that do not define any index view but doIndex, by going straight
to doIndex without bothering to try index views. Objects that do define
index view without doIndex will perform the same, because the presence
of doIndex is tested during MetaClass.buildDispatchers(), and not during
dispatching requests.

See: #97
A non-null ServletContext is needed to build MetaClass
@kohsuke
Copy link
Member Author

kohsuke commented Jan 15, 2017

Tested with the tip of Jenkins to make sure all the tests pass

@kohsuke
Copy link
Member Author

kohsuke commented Jan 16, 2017

@reviewbybees

@ghost
Copy link

ghost commented Jan 16, 2017

This pull request originates from a CloudBees employee. At CloudBees, we require that all pull requests be reviewed by other CloudBees employees before we seek to have the change accepted. If you want to learn more about our process please see this explanation.

@jglick jglick merged commit 40b620a into master Jan 18, 2017
jglick added a commit that referenced this pull request Jan 18, 2017
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.

2 participants