From d9ff109b0f60aeb72471aefc7bef0d959d909d0a Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Mon, 7 May 2018 14:30:50 +0200 Subject: [PATCH] Polishing (cherry picked from commit b4f83db) --- .../MethodInvocationProceedingJoinPoint.java | 31 +++++++++---------- .../config/ResourcesBeanDefinitionParser.java | 8 +++-- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/spring-aop/src/main/java/org/springframework/aop/aspectj/MethodInvocationProceedingJoinPoint.java b/spring-aop/src/main/java/org/springframework/aop/aspectj/MethodInvocationProceedingJoinPoint.java index d6e43ec1fd1..fc606b21fc8 100644 --- a/spring-aop/src/main/java/org/springframework/aop/aspectj/MethodInvocationProceedingJoinPoint.java +++ b/spring-aop/src/main/java/org/springframework/aop/aspectj/MethodInvocationProceedingJoinPoint.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2018 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. @@ -32,17 +32,15 @@ import org.springframework.core.ParameterNameDiscoverer; import org.springframework.util.Assert; /** - * Implementation of AspectJ ProceedingJoinPoint interface - * wrapping an AOP Alliance MethodInvocation. + * An implementation of the AspectJ {@link ProceedingJoinPoint} interface + * wrapping an AOP Alliance {@link org.aopalliance.intercept.MethodInvocation}. * - *

Note: the {@code getThis()} method returns the current Spring AOP proxy. + *

Note: The {@code getThis()} method returns the current Spring AOP proxy. * The {@code getTarget()} method returns the current Spring AOP target (which may be - * {@code null} if there is no target), and is a plain POJO without any advice. - * If you want to call the object and have the advice take effect, use - * {@code getThis()}. A common example is casting the object to an - * introduced interface in the implementation of an introduction. - * - *

Of course there is no such distinction between target and proxy in AspectJ. + * {@code null} if there is no target instance) as a plain POJO without any advice. + * If you want to call the object and have the advice take effect, use {@code getThis()}. + * A common example is casting the object to an introduced interface in the implementation of + * an introduction. There is no such distinction between target and proxy in AspectJ itself. * * @author Rod Johnson * @author Juergen Hoeller @@ -56,7 +54,7 @@ public class MethodInvocationProceedingJoinPoint implements ProceedingJoinPoint, private final ProxyMethodInvocation methodInvocation; - private Object[] defensiveCopyOfArgs; + private Object[] args; /** Lazily initialized signature object */ private Signature signature; @@ -75,6 +73,7 @@ public class MethodInvocationProceedingJoinPoint implements ProceedingJoinPoint, this.methodInvocation = methodInvocation; } + @Override public void set$AroundClosure(AroundClosure aroundClosure) { throw new UnsupportedOperationException(); @@ -115,12 +114,10 @@ public class MethodInvocationProceedingJoinPoint implements ProceedingJoinPoint, @Override public Object[] getArgs() { - if (this.defensiveCopyOfArgs == null) { - Object[] argsSource = this.methodInvocation.getArguments(); - this.defensiveCopyOfArgs = new Object[argsSource.length]; - System.arraycopy(argsSource, 0, this.defensiveCopyOfArgs, 0, argsSource.length); + if (this.args == null) { + this.args = this.methodInvocation.getArguments().clone(); } - return this.defensiveCopyOfArgs; + return this.args; } @Override @@ -128,7 +125,7 @@ public class MethodInvocationProceedingJoinPoint implements ProceedingJoinPoint, if (this.signature == null) { this.signature = new MethodSignatureImpl(); } - return signature; + return this.signature; } @Override diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/ResourcesBeanDefinitionParser.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/ResourcesBeanDefinitionParser.java index 8a7f2a9bd0c..33b956d5942 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/ResourcesBeanDefinitionParser.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/ResourcesBeanDefinitionParser.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 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. @@ -199,7 +199,7 @@ class ResourcesBeanDefinitionParser implements BeanDefinitionParser { private CacheControl parseCacheControl(Element element) { - CacheControl cacheControl = CacheControl.empty(); + CacheControl cacheControl; if ("true".equals(element.getAttribute("no-cache"))) { cacheControl = CacheControl.noCache(); } @@ -209,6 +209,10 @@ class ResourcesBeanDefinitionParser implements BeanDefinitionParser { else if (element.hasAttribute("max-age")) { cacheControl = CacheControl.maxAge(Long.parseLong(element.getAttribute("max-age")), TimeUnit.SECONDS); } + else { + cacheControl = CacheControl.empty(); + } + if ("true".equals(element.getAttribute("must-revalidate"))) { cacheControl = cacheControl.mustRevalidate(); }