Skip to content

Commit d9ff109

Browse files
committed
Polishing
(cherry picked from commit b4f83db)
1 parent 8501cef commit d9ff109

File tree

2 files changed

+20
-19
lines changed

2 files changed

+20
-19
lines changed

spring-aop/src/main/java/org/springframework/aop/aspectj/MethodInvocationProceedingJoinPoint.java

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2015 the original author or authors.
2+
* Copyright 2002-2018 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.
@@ -32,17 +32,15 @@
3232
import org.springframework.util.Assert;
3333

3434
/**
35-
* Implementation of AspectJ ProceedingJoinPoint interface
36-
* wrapping an AOP Alliance MethodInvocation.
35+
* An implementation of the AspectJ {@link ProceedingJoinPoint} interface
36+
* wrapping an AOP Alliance {@link org.aopalliance.intercept.MethodInvocation}.
3737
*
38-
* <p><b>Note</b>: the {@code getThis()} method returns the current Spring AOP proxy.
38+
* <p><b>Note</b>: The {@code getThis()} method returns the current Spring AOP proxy.
3939
* The {@code getTarget()} method returns the current Spring AOP target (which may be
40-
* {@code null} if there is no target), and is a plain POJO without any advice.
41-
* <b>If you want to call the object and have the advice take effect, use
42-
* {@code getThis()}.</b> A common example is casting the object to an
43-
* introduced interface in the implementation of an introduction.
44-
*
45-
* <p>Of course there is no such distinction between target and proxy in AspectJ.
40+
* {@code null} if there is no target instance) as a plain POJO without any advice.
41+
* <b>If you want to call the object and have the advice take effect, use {@code getThis()}.</b>
42+
* A common example is casting the object to an introduced interface in the implementation of
43+
* an introduction. There is no such distinction between target and proxy in AspectJ itself.
4644
*
4745
* @author Rod Johnson
4846
* @author Juergen Hoeller
@@ -56,7 +54,7 @@ public class MethodInvocationProceedingJoinPoint implements ProceedingJoinPoint,
5654

5755
private final ProxyMethodInvocation methodInvocation;
5856

59-
private Object[] defensiveCopyOfArgs;
57+
private Object[] args;
6058

6159
/** Lazily initialized signature object */
6260
private Signature signature;
@@ -75,6 +73,7 @@ public MethodInvocationProceedingJoinPoint(ProxyMethodInvocation methodInvocatio
7573
this.methodInvocation = methodInvocation;
7674
}
7775

76+
7877
@Override
7978
public void set$AroundClosure(AroundClosure aroundClosure) {
8079
throw new UnsupportedOperationException();
@@ -115,20 +114,18 @@ public Object getTarget() {
115114

116115
@Override
117116
public Object[] getArgs() {
118-
if (this.defensiveCopyOfArgs == null) {
119-
Object[] argsSource = this.methodInvocation.getArguments();
120-
this.defensiveCopyOfArgs = new Object[argsSource.length];
121-
System.arraycopy(argsSource, 0, this.defensiveCopyOfArgs, 0, argsSource.length);
117+
if (this.args == null) {
118+
this.args = this.methodInvocation.getArguments().clone();
122119
}
123-
return this.defensiveCopyOfArgs;
120+
return this.args;
124121
}
125122

126123
@Override
127124
public Signature getSignature() {
128125
if (this.signature == null) {
129126
this.signature = new MethodSignatureImpl();
130127
}
131-
return signature;
128+
return this.signature;
132129
}
133130

134131
@Override

spring-webmvc/src/main/java/org/springframework/web/servlet/config/ResourcesBeanDefinitionParser.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 the original author or authors.
2+
* Copyright 2002-2018 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.
@@ -199,7 +199,7 @@ private String registerResourceHandler(
199199

200200

201201
private CacheControl parseCacheControl(Element element) {
202-
CacheControl cacheControl = CacheControl.empty();
202+
CacheControl cacheControl;
203203
if ("true".equals(element.getAttribute("no-cache"))) {
204204
cacheControl = CacheControl.noCache();
205205
}
@@ -209,6 +209,10 @@ else if ("true".equals(element.getAttribute("no-store"))) {
209209
else if (element.hasAttribute("max-age")) {
210210
cacheControl = CacheControl.maxAge(Long.parseLong(element.getAttribute("max-age")), TimeUnit.SECONDS);
211211
}
212+
else {
213+
cacheControl = CacheControl.empty();
214+
}
215+
212216
if ("true".equals(element.getAttribute("must-revalidate"))) {
213217
cacheControl = cacheControl.mustRevalidate();
214218
}

0 commit comments

Comments
 (0)