Skip to content

Commit 25a1bfb

Browse files
committed
Avoid creation of unused logger instance in AbstractMediaTypeExpression
Closes gh-25901
1 parent 187b029 commit 25a1bfb

File tree

3 files changed

+6
-24
lines changed

3 files changed

+6
-24
lines changed

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

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,9 +16,6 @@
1616

1717
package org.springframework.web.reactive.result.condition;
1818

19-
import org.apache.commons.logging.Log;
20-
import org.apache.commons.logging.LogFactory;
21-
2219
import org.springframework.http.MediaType;
2320
import org.springframework.lang.Nullable;
2421
import org.springframework.web.bind.annotation.RequestMapping;
@@ -35,8 +32,6 @@
3532
*/
3633
abstract class AbstractMediaTypeExpression implements Comparable<AbstractMediaTypeExpression>, MediaTypeExpression {
3734

38-
protected final Log logger = LogFactory.getLog(getClass());
39-
4035
private final MediaType mediaType;
4136

4237
private final boolean isNegated;
@@ -108,12 +103,10 @@ public int hashCode() {
108103

109104
@Override
110105
public String toString() {
111-
StringBuilder builder = new StringBuilder();
112106
if (this.isNegated) {
113-
builder.append('!');
107+
return '!' + this.mediaType.toString();
114108
}
115-
builder.append(this.mediaType.toString());
116-
return builder.toString();
109+
return this.mediaType.toString();
117110
}
118111

119112
}

spring-webflux/src/main/java/org/springframework/web/reactive/result/method/HandlerMethodArgumentResolverComposite.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
import java.util.Map;
2323
import java.util.concurrent.ConcurrentHashMap;
2424

25-
import org.apache.commons.logging.Log;
26-
import org.apache.commons.logging.LogFactory;
2725
import reactor.core.publisher.Mono;
2826

2927
import org.springframework.core.MethodParameter;
@@ -41,8 +39,6 @@
4139
*/
4240
class HandlerMethodArgumentResolverComposite implements HandlerMethodArgumentResolver {
4341

44-
protected final Log logger = LogFactory.getLog(getClass());
45-
4642
private final List<HandlerMethodArgumentResolver> argumentResolvers = new LinkedList<>();
4743

4844
private final Map<MethodParameter, HandlerMethodArgumentResolver> argumentResolverCache =

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

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,9 +16,6 @@
1616

1717
package org.springframework.web.servlet.mvc.condition;
1818

19-
import org.apache.commons.logging.Log;
20-
import org.apache.commons.logging.LogFactory;
21-
2219
import org.springframework.http.MediaType;
2320
import org.springframework.lang.Nullable;
2421
import org.springframework.web.bind.annotation.RequestMapping;
@@ -33,8 +30,6 @@
3330
*/
3431
abstract class AbstractMediaTypeExpression implements MediaTypeExpression, Comparable<AbstractMediaTypeExpression> {
3532

36-
protected final Log logger = LogFactory.getLog(getClass());
37-
3833
private final MediaType mediaType;
3934

4035
private final boolean isNegated;
@@ -92,12 +87,10 @@ public int hashCode() {
9287

9388
@Override
9489
public String toString() {
95-
StringBuilder builder = new StringBuilder();
9690
if (this.isNegated) {
97-
builder.append('!');
91+
return '!' + this.mediaType.toString();
9892
}
99-
builder.append(this.mediaType.toString());
100-
return builder.toString();
93+
return this.mediaType.toString();
10194
}
10295

10396
}

0 commit comments

Comments
 (0)