Skip to content

Commit 595cdf0

Browse files
committed
Polishing
1 parent e78b086 commit 595cdf0

File tree

5 files changed

+30
-25
lines changed

5 files changed

+30
-25
lines changed

spring-aspects/src/test/java/org/springframework/transaction/aspectj/JtaTransactionAspectsTests.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package org.springframework.transaction.aspectj;
1818

1919
import java.io.IOException;
20-
2120
import javax.transaction.Transactional;
2221

2322
import org.junit.Before;
@@ -132,6 +131,7 @@ public void echo(Throwable t) throws Throwable {
132131

133132
}
134133

134+
135135
protected static class JtaAnnotationProtectedAnnotatedMember {
136136

137137
public void doSomething() {
@@ -143,6 +143,7 @@ protected void doInTransaction() {
143143
}
144144
}
145145

146+
146147
protected static class JtaAnnotationPrivateAnnotatedMember {
147148

148149
public void doSomething() {
@@ -154,6 +155,7 @@ private void doInTransaction() {
154155
}
155156
}
156157

158+
157159
@Configuration
158160
protected static class Config {
159161

@@ -168,7 +170,6 @@ public JtaAnnotationTransactionAspect transactionAspect() {
168170
aspect.setTransactionManager(transactionManager());
169171
return aspect;
170172
}
171-
172173
}
173174

174175
}

spring-beans/src/main/java/org/springframework/beans/BeanWrapperImpl.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import java.lang.reflect.InvocationTargetException;
2323
import java.lang.reflect.Method;
2424
import java.lang.reflect.Modifier;
25+
import java.lang.reflect.UndeclaredThrowableException;
2526
import java.security.AccessControlContext;
2627
import java.security.AccessController;
2728
import java.security.PrivilegedAction;
@@ -1179,7 +1180,12 @@ public Object run() throws Exception {
11791180
throw new TypeMismatchException(propertyChangeEvent, pd.getPropertyType(), ex.getTargetException());
11801181
}
11811182
else {
1182-
throw new MethodInvocationException(propertyChangeEvent, ex.getTargetException());
1183+
Throwable cause = ex.getTargetException();
1184+
if (cause instanceof UndeclaredThrowableException) {
1185+
// May happen e.g. with Groovy-generated methods
1186+
cause = cause.getCause();
1187+
}
1188+
throw new MethodInvocationException(propertyChangeEvent, cause);
11831189
}
11841190
}
11851191
catch (Exception ex) {

spring-context/src/main/java/org/springframework/cache/annotation/EnableCaching.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2015 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.
@@ -162,13 +162,12 @@
162162
* Indicate whether subclass-based (CGLIB) proxies are to be created as opposed
163163
* to standard Java interface-based proxies. The default is {@code false}. <strong>
164164
* Applicable only if {@link #mode()} is set to {@link AdviceMode#PROXY}</strong>.
165-
*
166165
* <p>Note that setting this attribute to {@code true} will affect <em>all</em>
167-
* Spring-managed beans requiring proxying, not just those marked with
168-
* {@code @Cacheable}. For example, other beans marked with Spring's
169-
* {@code @Transactional} annotation will be upgraded to subclass proxying at the same
170-
* time. This approach has no negative impact in practice unless one is explicitly
171-
* expecting one type of proxy vs another, e.g. in tests.
166+
* Spring-managed beans requiring proxying, not just those marked with {@code @Cacheable}.
167+
* For example, other beans marked with Spring's {@code @Transactional} annotation will
168+
* be upgraded to subclass proxying at the same time. This approach has no negative
169+
* impact in practice unless one is explicitly expecting one type of proxy vs another,
170+
* e.g. in tests.
172171
*/
173172
boolean proxyTargetClass() default false;
174173

@@ -185,4 +184,5 @@
185184
* The default is {@link Ordered#LOWEST_PRECEDENCE}.
186185
*/
187186
int order() default Ordered.LOWEST_PRECEDENCE;
187+
188188
}

spring-context/src/main/java/org/springframework/scripting/groovy/GroovyScriptFactory.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 the original author or authors.
2+
* Copyright 2002-2015 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.
@@ -24,7 +24,6 @@
2424
import groovy.lang.Script;
2525
import org.codehaus.groovy.control.CompilationFailedException;
2626

27-
import org.springframework.beans.BeansException;
2827
import org.springframework.beans.factory.BeanClassLoaderAware;
2928
import org.springframework.beans.factory.BeanFactory;
3029
import org.springframework.beans.factory.BeanFactoryAware;
@@ -102,7 +101,7 @@ public GroovyScriptFactory(String scriptSourceLocator, GroovyObjectCustomizer gr
102101

103102

104103
@Override
105-
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
104+
public void setBeanFactory(BeanFactory beanFactory) {
106105
if (beanFactory instanceof ConfigurableListableBeanFactory) {
107106
((ConfigurableListableBeanFactory) beanFactory).ignoreDependencyType(MetaClass.class);
108107
}

spring-context/src/main/java/org/springframework/scripting/support/ScriptFactoryPostProcessor.java

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 the original author or authors.
2+
* Copyright 2002-2015 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.
@@ -94,7 +94,7 @@
9494
* &lt;property name="message" value="Hello World!"/&gt;
9595
* &lt;/bean&gt;
9696
*
97-
* &lt;bean id="groovyMessenger" class="org.springframework.scripting.bsh.GroovyScriptFactory"&gt;
97+
* &lt;bean id="groovyMessenger" class="org.springframework.scripting.groovy.GroovyScriptFactory"&gt;
9898
* &lt;constructor-arg value="classpath:mypackage/Messenger.groovy"/&gt;
9999
* &lt;property name="message" value="Hello World!"/&gt;
100100
* &lt;/bean&gt;</pre>
@@ -346,17 +346,16 @@ public Object postProcessBeforeInstantiation(Class<?> beanClass, String beanName
346346
* @param scriptedObjectBeanName the name of the internal scripted object bean
347347
*/
348348
protected void prepareScriptBeans(BeanDefinition bd, String scriptFactoryBeanName, String scriptedObjectBeanName) {
349-
350349
// Avoid recreation of the script bean definition in case of a prototype.
351350
synchronized (this.scriptBeanFactory) {
352351
if (!this.scriptBeanFactory.containsBeanDefinition(scriptedObjectBeanName)) {
353352

354-
this.scriptBeanFactory.registerBeanDefinition(scriptFactoryBeanName,
355-
createScriptFactoryBeanDefinition(bd));
356-
ScriptFactory scriptFactory = this.scriptBeanFactory
357-
.getBean(scriptFactoryBeanName, ScriptFactory.class);
358-
ScriptSource scriptSource = getScriptSource(scriptFactoryBeanName,
359-
scriptFactory.getScriptSourceLocator());
353+
this.scriptBeanFactory.registerBeanDefinition(
354+
scriptFactoryBeanName, createScriptFactoryBeanDefinition(bd));
355+
ScriptFactory scriptFactory =
356+
this.scriptBeanFactory.getBean(scriptFactoryBeanName, ScriptFactory.class);
357+
ScriptSource scriptSource =
358+
getScriptSource(scriptFactoryBeanName, scriptFactory.getScriptSourceLocator());
360359
Class<?>[] interfaces = scriptFactory.getScriptInterfaces();
361360

362361
Class<?>[] scriptedInterfaces = interfaces;
@@ -365,8 +364,8 @@ protected void prepareScriptBeans(BeanDefinition bd, String scriptFactoryBeanNam
365364
scriptedInterfaces = ObjectUtils.addObjectToArray(interfaces, configInterface);
366365
}
367366

368-
BeanDefinition objectBd = createScriptedObjectBeanDefinition(bd, scriptFactoryBeanName, scriptSource,
369-
scriptedInterfaces);
367+
BeanDefinition objectBd = createScriptedObjectBeanDefinition(
368+
bd, scriptFactoryBeanName, scriptSource, scriptedInterfaces);
370369
long refreshCheckDelay = resolveRefreshCheckDelay(bd);
371370
if (refreshCheckDelay >= 0) {
372371
objectBd.setScope(BeanDefinition.SCOPE_PROTOTYPE);
@@ -569,7 +568,7 @@ protected Object createRefreshableProxy(TargetSource ts, Class<?>[] interfaces,
569568
proxyFactory.setInterfaces(interfaces);
570569
if (proxyTargetClass) {
571570
classLoader = null; // force use of Class.getClassLoader()
572-
proxyFactory.setProxyTargetClass(proxyTargetClass);
571+
proxyFactory.setProxyTargetClass(true);
573572
}
574573

575574
DelegatingIntroductionInterceptor introduction = new DelegatingIntroductionInterceptor(ts);

0 commit comments

Comments
 (0)