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

Route priority wrong in reverse routing #3050

Closed
AntonFagerberg opened this issue Jun 19, 2014 · 3 comments · Fixed by #3052
Closed

Route priority wrong in reverse routing #3050

AntonFagerberg opened this issue Jun 19, 2014 · 3 comments · Fixed by #3052
Milestone

Comments

@AntonFagerberg
Copy link

From the documentation:

Many routes can match the same request. If there is a conflict, the first route (in declaration order) is used.

However, the wrong route is used in this example:

routes-file:

GET     /               controllers.Application.index
GET     /use-this       controllers.Application.test
GET     /dont-use-this  controllers.Application.test

controller-file:

  def index = Action {
    Redirect(routes.Application.test())
  }

  def test = Action {
    Ok("")
  }

Visiting index will redirect to url "/dont-use-this" and not "/use-this".

This bug has appeared since upgrading to Play 2.3.

@cchantep
Copy link
Member

Wrong reverse routing you mean?

@AntonFagerberg
Copy link
Author

@cchantep Yes, exactly.

@AntonFagerberg AntonFagerberg changed the title Route priority wrong with redirect Route priority wrong in reverse routing Jun 19, 2014
@gmethvin
Copy link
Member

This was caused by the change in #2197. Previously we generated the reverse routes for all routes, and later ones that matched the same controller call would produce an unreachable code warning. Removing duplicates with a ListMap removes the warning, but causes the last route to take priority instead of the first.

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 a pull request may close this issue.

4 participants