Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a2cac0d
commit f948c45
Showing
20 changed files
with
376 additions
and
119 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
55 changes: 55 additions & 0 deletions
55
resteasy-core/src/main/java/org/jboss/resteasy/core/registry/MatchCache.java
This file contains 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 |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package org.jboss.resteasy.core.registry; | ||
|
||
|
||
import org.jboss.resteasy.specimpl.ResteasyUriInfo; | ||
import org.jboss.resteasy.spi.HttpRequest; | ||
import org.jboss.resteasy.spi.ResourceInvoker; | ||
|
||
import javax.ws.rs.core.MediaType; | ||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
public class MatchCache { | ||
public MediaType chosen; | ||
public SegmentNode.Match match; | ||
public ResourceInvoker invoker; | ||
|
||
public static class Key { | ||
public String path; | ||
public int start; | ||
public String method; | ||
public MediaType contentType; | ||
public List<MediaType> accepts; | ||
|
||
public Key(final HttpRequest request, final int start) { | ||
String matchingPath = ((ResteasyUriInfo) request.getUri()).getMatchingPath(); | ||
this.path = start == 0 ? matchingPath : matchingPath.substring(start); | ||
this.start = start; | ||
this.method = request.getHttpMethod(); | ||
this.contentType = request.getHttpHeaders().getMediaType(); | ||
this.accepts = request.getHttpHeaders().getAcceptableMediaTypes(); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
Key key = (Key) o; | ||
boolean b = start == key.start && | ||
path.equals(key.path) && | ||
method.equals(key.method) && | ||
Objects.equals(contentType, key.contentType); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
patriot1burke
via email
Author
Collaborator
|
||
if (!b) return false; | ||
if (accepts.isEmpty() && key.accepts.isEmpty()) return true; | ||
if (accepts.size() != key.accepts.size()) return false; | ||
// todo improve this | ||
return b && | ||
accepts.equals(key.accepts); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(path, start, method); | ||
} | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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.
The incoming request with content type with random boundary like this:
causes
equals()
be false all the time which allows the cache to grow infinitely, see RESTEASY-2646 for more details about the issue.