-
Notifications
You must be signed in to change notification settings - Fork 568
Remove MatchableHandlerMapping from DelegatingHandlerMapping #2604
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
Open
arimu1
wants to merge
1
commit into
spring-projects:main
Choose a base branch
from
arimu1:fix/2582-drop-matchable-handler-mapping
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,8 +31,6 @@ | |
| import org.springframework.web.bind.UnsatisfiedServletRequestParameterException; | ||
| import org.springframework.web.servlet.HandlerExecutionChain; | ||
| import org.springframework.web.servlet.HandlerMapping; | ||
| import org.springframework.web.servlet.handler.MatchableHandlerMapping; | ||
| import org.springframework.web.servlet.handler.RequestMatchResult; | ||
| import org.springframework.web.util.pattern.PathPatternParser; | ||
|
|
||
| /** | ||
|
|
@@ -42,7 +40,7 @@ | |
| * @author Oliver Gierke | ||
| * @soundtrack Benny Greb - Stabila (Moving Parts) | ||
| */ | ||
| class DelegatingHandlerMapping implements MatchableHandlerMapping, Iterable<HandlerMapping>, Ordered { | ||
| class DelegatingHandlerMapping implements HandlerMapping, Iterable<HandlerMapping>, Ordered { | ||
|
|
||
| private final List<HandlerMapping> delegates; | ||
| private final @Nullable PathPatternParser parser; | ||
|
|
@@ -66,7 +64,6 @@ public boolean usesPathPatterns() { | |
| } | ||
|
|
||
| @Nullable | ||
| @Override | ||
| public PathPatternParser getPatternParser() { | ||
|
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. Consider removing or making |
||
| return parser; | ||
| } | ||
|
|
@@ -91,20 +88,9 @@ public int getOrder() { | |
| return HandlerSelectionResult.from(request, delegates).resultOrException(); | ||
| } | ||
|
|
||
| @Override | ||
| public @Nullable RequestMatchResult match(HttpServletRequest request, String pattern) { | ||
|
|
||
| try { | ||
| return HandlerSelectionResult.from(request, delegates).match(pattern); | ||
| } catch (Exception o_O) { | ||
| return null; | ||
| } | ||
| } | ||
|
|
||
| private static class HandlerSelectionResult { | ||
|
|
||
| private final HttpServletRequest request; | ||
| private final @Nullable HandlerMapping mapping; | ||
| private final @Nullable HandlerExecutionChain result; | ||
| private final @Nullable Exception ignoredException; | ||
|
|
||
|
|
@@ -120,7 +106,7 @@ public static HandlerSelectionResult from(HttpServletRequest request, Iterable<H | |
| HandlerExecutionChain result = delegate.getHandler(request); | ||
|
|
||
| if (result != null) { | ||
| return HandlerSelectionResult.forResult(request, delegate, result); | ||
| return HandlerSelectionResult.forResult(request, result); | ||
| } | ||
|
|
||
| } catch (HttpMediaTypeNotSupportedException o_O) { | ||
|
|
@@ -137,13 +123,12 @@ public static HandlerSelectionResult from(HttpServletRequest request, Iterable<H | |
| return HandlerSelectionResult.withoutResult(request, ignoredException); | ||
| } | ||
|
|
||
| private static HandlerSelectionResult forResult(HttpServletRequest request, HandlerMapping delegate, | ||
| HandlerExecutionChain result) { | ||
| return new HandlerSelectionResult(request, delegate, result, null); | ||
| private static HandlerSelectionResult forResult(HttpServletRequest request, HandlerExecutionChain result) { | ||
| return new HandlerSelectionResult(request, result, null); | ||
| } | ||
|
|
||
| private static HandlerSelectionResult withoutResult(HttpServletRequest request, @Nullable Exception exception) { | ||
| return new HandlerSelectionResult(request, null, null, exception); | ||
| return new HandlerSelectionResult(request, null, exception); | ||
| } | ||
|
|
||
| public @Nullable HandlerExecutionChain resultOrException() throws Exception { | ||
|
|
@@ -155,20 +140,12 @@ private static HandlerSelectionResult withoutResult(HttpServletRequest request, | |
| return result; | ||
| } | ||
|
|
||
| public @Nullable RequestMatchResult match(String pattern) { | ||
|
|
||
| return MatchableHandlerMapping.class.isInstance(mapping) // | ||
| ? ((MatchableHandlerMapping) mapping).match(request, pattern) // | ||
| : null; | ||
| } | ||
|
|
||
| public HandlerSelectionResult(HttpServletRequest request, @Nullable HandlerMapping mapping, | ||
| @Nullable HandlerExecutionChain result, @Nullable Exception ignoredException) { | ||
| public HandlerSelectionResult(HttpServletRequest request, @Nullable HandlerExecutionChain result, | ||
| @Nullable Exception ignoredException) { | ||
|
|
||
| Assert.notNull(request, "HttpServletRequest must not be null"); | ||
|
|
||
| this.request = request; | ||
| this.mapping = mapping; | ||
| this.result = result; | ||
| this.ignoredException = ignoredException; | ||
| } | ||
|
|
@@ -187,20 +164,19 @@ public boolean equals(@Nullable Object o) { | |
| HandlerSelectionResult other = (HandlerSelectionResult) o; | ||
|
|
||
| return Objects.equals(request, other.request) // | ||
| && Objects.equals(mapping, other.mapping) // | ||
| && Objects.equals(result, other.result) // | ||
| && Objects.equals(ignoredException, other.ignoredException); | ||
| } | ||
|
|
||
| @Override | ||
| public int hashCode() { | ||
| return Objects.hash(request, mapping, result, ignoredException); | ||
| return Objects.hash(request, result, ignoredException); | ||
| } | ||
|
|
||
| @Override | ||
| public java.lang.String toString() { | ||
| return "DelegatingHandlerMapping.HandlerSelectionResult(request=" + request + ", mapping=" + mapping + ", result=" | ||
| + result + ", ignoredException=" + ignoredException + ")"; | ||
| return "DelegatingHandlerMapping.HandlerSelectionResult(request=" + request + ", result=" + result | ||
| + ", ignoredException=" + ignoredException + ")"; | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Add yourself as additional author