Skip to content

Commit b4f83db

Browse files
committed
Polishing
1 parent 0795ae5 commit b4f83db

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-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.
@@ -33,17 +33,15 @@
3333
import org.springframework.util.Assert;
3434

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

6058
@Nullable
61-
private Object[] defensiveCopyOfArgs;
59+
private Object[] args;
6260

6361
/** Lazily initialized signature object */
6462
@Nullable
@@ -79,6 +77,7 @@ public MethodInvocationProceedingJoinPoint(ProxyMethodInvocation methodInvocatio
7977
this.methodInvocation = methodInvocation;
8078
}
8179

80+
8281
@Override
8382
public void set$AroundClosure(AroundClosure aroundClosure) {
8483
throw new UnsupportedOperationException();
@@ -120,20 +119,18 @@ public Object getTarget() {
120119

121120
@Override
122121
public Object[] getArgs() {
123-
if (this.defensiveCopyOfArgs == null) {
124-
Object[] argsSource = this.methodInvocation.getArguments();
125-
this.defensiveCopyOfArgs = new Object[argsSource.length];
126-
System.arraycopy(argsSource, 0, this.defensiveCopyOfArgs, 0, argsSource.length);
122+
if (this.args == null) {
123+
this.args = this.methodInvocation.getArguments().clone();
127124
}
128-
return this.defensiveCopyOfArgs;
125+
return this.args;
129126
}
130127

131128
@Override
132129
public Signature getSignature() {
133130
if (this.signature == null) {
134131
this.signature = new MethodSignatureImpl();
135132
}
136-
return signature;
133+
return this.signature;
137134
}
138135

139136
@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.
@@ -201,7 +201,7 @@ private String registerResourceHandler(ParserContext context, Element element,
201201

202202

203203
private CacheControl parseCacheControl(Element element) {
204-
CacheControl cacheControl = CacheControl.empty();
204+
CacheControl cacheControl;
205205
if ("true".equals(element.getAttribute("no-cache"))) {
206206
cacheControl = CacheControl.noCache();
207207
}
@@ -211,6 +211,10 @@ else if ("true".equals(element.getAttribute("no-store"))) {
211211
else if (element.hasAttribute("max-age")) {
212212
cacheControl = CacheControl.maxAge(Long.parseLong(element.getAttribute("max-age")), TimeUnit.SECONDS);
213213
}
214+
else {
215+
cacheControl = CacheControl.empty();
216+
}
217+
214218
if ("true".equals(element.getAttribute("must-revalidate"))) {
215219
cacheControl = cacheControl.mustRevalidate();
216220
}

0 commit comments

Comments
 (0)