Skip to content

Commit

Permalink
optimize: 优化 ApplicationJsonHttpServletRequestWrapper,将contentTypeEnu…
Browse files Browse the repository at this point in the history
…meration变为常量,减少损耗。
  • Loading branch information
wangliang181230 committed Dec 26, 2023
1 parent 4ec5a66 commit 0899f2f
Showing 1 changed file with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,11 @@
*/
public class ApplicationJsonHttpServletRequestWrapper extends BodyHttpServletRequestWrapper {

private final Enumeration<String> contentTypeEnumeration;
private final static Enumeration<String> CONTENT_TYPE_ENUMERATION = Collections.enumeration(Collections.singletonList(MediaType.APPLICATION_JSON_VALUE));


public ApplicationJsonHttpServletRequestWrapper(HttpServletRequest request, String jsonData) {
super(request, jsonData);

this.contentTypeEnumeration = Collections.enumeration(Collections.singletonList(MediaType.APPLICATION_JSON_VALUE));
}


Expand All @@ -57,7 +55,7 @@ public String getHeader(String name) {
@Override
public Enumeration<String> getHeaders(String name) {
if (HttpHeaders.CONTENT_TYPE.equalsIgnoreCase(name)) {
return contentTypeEnumeration;
return CONTENT_TYPE_ENUMERATION;
}

return super.getHeaders(name);
Expand Down

0 comments on commit 0899f2f

Please sign in to comment.