Browse Source

Avoid creation of unused logger instance in AbstractMediaTypeExpression

Closes gh-25901
5.0.x
Juergen Hoeller 5 years ago
parent
commit
f355b174ad
  1. 13
      spring-webflux/src/main/java/org/springframework/web/reactive/result/condition/AbstractMediaTypeExpression.java
  2. 13
      spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/AbstractMediaTypeExpression.java

13
spring-webflux/src/main/java/org/springframework/web/reactive/result/condition/AbstractMediaTypeExpression.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -16,9 +16,6 @@ @@ -16,9 +16,6 @@
package org.springframework.web.reactive.result.condition;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.http.MediaType;
import org.springframework.lang.Nullable;
import org.springframework.web.bind.annotation.RequestMapping;
@ -35,8 +32,6 @@ import org.springframework.web.server.UnsupportedMediaTypeStatusException; @@ -35,8 +32,6 @@ import org.springframework.web.server.UnsupportedMediaTypeStatusException;
*/
abstract class AbstractMediaTypeExpression implements Comparable<AbstractMediaTypeExpression>, MediaTypeExpression {
protected final Log logger = LogFactory.getLog(getClass());
private final MediaType mediaType;
private final boolean isNegated;
@ -108,12 +103,10 @@ abstract class AbstractMediaTypeExpression implements Comparable<AbstractMediaTy @@ -108,12 +103,10 @@ abstract class AbstractMediaTypeExpression implements Comparable<AbstractMediaTy
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
if (this.isNegated) {
builder.append('!');
return '!' + this.mediaType.toString();
}
builder.append(this.mediaType.toString());
return builder.toString();
return this.mediaType.toString();
}
}

13
spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/AbstractMediaTypeExpression.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -16,9 +16,6 @@ @@ -16,9 +16,6 @@
package org.springframework.web.servlet.mvc.condition;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.http.MediaType;
import org.springframework.lang.Nullable;
import org.springframework.web.bind.annotation.RequestMapping;
@ -33,8 +30,6 @@ import org.springframework.web.bind.annotation.RequestMapping; @@ -33,8 +30,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
*/
abstract class AbstractMediaTypeExpression implements MediaTypeExpression, Comparable<AbstractMediaTypeExpression> {
protected final Log logger = LogFactory.getLog(getClass());
private final MediaType mediaType;
private final boolean isNegated;
@ -92,12 +87,10 @@ abstract class AbstractMediaTypeExpression implements MediaTypeExpression, Compa @@ -92,12 +87,10 @@ abstract class AbstractMediaTypeExpression implements MediaTypeExpression, Compa
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
if (this.isNegated) {
builder.append('!');
return '!' + this.mediaType.toString();
}
builder.append(this.mediaType.toString());
return builder.toString();
return this.mediaType.toString();
}
}

Loading…
Cancel
Save