Skip to content

Commit 38db9fa

Browse files
committed
Polishing
(cherry picked from commit 667fc7e)
1 parent af5f4e6 commit 38db9fa

File tree

11 files changed

+72
-76
lines changed

11 files changed

+72
-76
lines changed

spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AspectJProxyFactory.java

Lines changed: 2 additions & 2 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.
@@ -76,7 +76,7 @@ public AspectJProxyFactory(Object target) {
7676
* Create a new {@code AspectJProxyFactory}.
7777
* No target, only interfaces. Must add interceptors.
7878
*/
79-
public AspectJProxyFactory(Class<?>[] interfaces) {
79+
public AspectJProxyFactory(Class<?>... interfaces) {
8080
setInterfaces(interfaces);
8181
}
8282

spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectProxyFactoryTests.java

Lines changed: 6 additions & 6 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.
@@ -32,9 +32,9 @@
3232
* @author Juergen Hoeller
3333
* @author Chris Beams
3434
*/
35-
public final class AspectProxyFactoryTests {
35+
public class AspectProxyFactoryTests {
3636

37-
@Test(expected=IllegalArgumentException.class)
37+
@Test(expected = IllegalArgumentException.class)
3838
public void testWithNonAspect() {
3939
AspectJProxyFactory proxyFactory = new AspectJProxyFactory(new TestBean());
4040
proxyFactory.addAspect(TestBean.class);
@@ -70,7 +70,7 @@ public void testWithPerThisAspect() throws Exception {
7070
assertEquals(2, proxy1.getAge());
7171
}
7272

73-
@Test(expected=IllegalArgumentException.class)
73+
@Test(expected = IllegalArgumentException.class)
7474
public void testWithInstanceWithNonAspect() throws Exception {
7575
AspectJProxyFactory pf = new AspectJProxyFactory();
7676
pf.addAspect(new TestBean());
@@ -96,14 +96,14 @@ public void testWithInstance() throws Exception {
9696
assertEquals(target.getAge() * multiple, serializedProxy.getAge());
9797
}
9898

99-
@Test(expected=IllegalArgumentException.class)
99+
@Test(expected = IllegalArgumentException.class)
100100
public void testWithNonSingletonAspectInstance() throws Exception {
101101
AspectJProxyFactory pf = new AspectJProxyFactory();
102102
pf.addAspect(new PerThisAspect());
103103
}
104104

105105

106-
public static interface ITestBean {
106+
public interface ITestBean {
107107

108108
int getAge();
109109
}

spring-beans/src/main/java/org/springframework/beans/factory/config/YamlProcessor.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -393,17 +393,14 @@ public enum ResolutionMethod {
393393
*/
394394
protected static class StrictMapAppenderConstructor extends Constructor {
395395

396-
public StrictMapAppenderConstructor() {
397-
super();
398-
}
399-
400396
@Override
401397
protected Map<Object, Object> constructMapping(MappingNode node) {
402398
try {
403399
return super.constructMapping(node);
404-
} catch (IllegalStateException e) {
400+
}
401+
catch (IllegalStateException ex) {
405402
throw new ParserException("while parsing MappingNode",
406-
node.getStartMark(), e.getMessage(), node.getEndMark());
403+
node.getStartMark(), ex.getMessage(), node.getEndMark());
407404
}
408405
}
409406

@@ -414,7 +411,7 @@ protected Map<Object, Object> createDefaultMap() {
414411
@Override
415412
public Object put(Object key, Object value) {
416413
if (delegate.containsKey(key)) {
417-
throw new IllegalStateException("duplicate key: " + key);
414+
throw new IllegalStateException("Duplicate key: " + key);
418415
}
419416
return delegate.put(key, value);
420417
}

spring-context/src/test/java/org/springframework/aop/framework/CglibProxyTests.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 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.
@@ -49,7 +49,7 @@
4949
* @author Chris Beams
5050
*/
5151
@SuppressWarnings("serial")
52-
public final class CglibProxyTests extends AbstractAopProxyTests implements Serializable {
52+
public class CglibProxyTests extends AbstractAopProxyTests implements Serializable {
5353

5454
private static final String DEPENDENCY_CHECK_CONTEXT =
5555
CglibProxyTests.class.getSimpleName() + "-with-dependency-checking.xml";
@@ -74,6 +74,7 @@ protected boolean requiresTarget() {
7474
return true;
7575
}
7676

77+
7778
@Test
7879
public void testNullConfig() {
7980
try {

spring-context/src/test/java/org/springframework/aop/framework/JdkDynamicProxyTests.java

Lines changed: 20 additions & 19 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.
@@ -20,6 +20,7 @@
2020

2121
import org.aopalliance.intercept.MethodInterceptor;
2222
import org.aopalliance.intercept.MethodInvocation;
23+
import org.junit.Test;
2324

2425
import org.springframework.aop.interceptor.ExposeInvocationInterceptor;
2526
import org.springframework.aop.support.AopUtils;
@@ -28,7 +29,6 @@
2829
import org.springframework.tests.sample.beans.TestBean;
2930

3031
import static org.junit.Assert.*;
31-
import static org.mockito.BDDMockito.*;
3232

3333
/**
3434
* @since 13.03.2003
@@ -37,7 +37,7 @@
3737
* @author Chris Beams
3838
*/
3939
@SuppressWarnings("serial")
40-
public final class JdkDynamicProxyTests extends AbstractAopProxyTests implements Serializable {
40+
public class JdkDynamicProxyTests extends AbstractAopProxyTests implements Serializable {
4141

4242
@Override
4343
protected Object createProxy(ProxyCreatorSupport as) {
@@ -52,6 +52,8 @@ protected AopProxy createAopProxy(AdvisedSupport as) {
5252
return new JdkDynamicAopProxy(as);
5353
}
5454

55+
56+
@Test
5557
public void testNullConfig() {
5658
try {
5759
new JdkDynamicAopProxy(null);
@@ -62,6 +64,7 @@ public void testNullConfig() {
6264
}
6365
}
6466

67+
@Test
6568
public void testProxyIsJustInterface() throws Throwable {
6669
TestBean raw = new TestBean();
6770
raw.setAge(32);
@@ -74,32 +77,32 @@ public void testProxyIsJustInterface() throws Throwable {
7477
assertTrue(!(proxy instanceof TestBean));
7578
}
7679

80+
@Test
7781
public void testInterceptorIsInvokedWithNoTarget() throws Throwable {
7882
// Test return value
79-
int age = 25;
80-
MethodInterceptor mi = mock(MethodInterceptor.class);
83+
final Integer age = 25;
84+
MethodInterceptor mi = (invocation -> age);
8185

82-
AdvisedSupport pc = new AdvisedSupport(new Class<?>[] { ITestBean.class });
86+
AdvisedSupport pc = new AdvisedSupport(new Class<?>[] {ITestBean.class});
8387
pc.addAdvice(mi);
8488
AopProxy aop = createAopProxy(pc);
8589

86-
given(mi.invoke(null)).willReturn(age);
87-
8890
ITestBean tb = (ITestBean) aop.getProxy();
8991
assertTrue("correct return value", tb.getAge() == age);
9092
}
9193

94+
@Test
9295
public void testTargetCanGetInvocationWithPrivateClass() throws Throwable {
9396
final ExposedInvocationTestBean expectedTarget = new ExposedInvocationTestBean() {
9497
@Override
9598
protected void assertions(MethodInvocation invocation) {
9699
assertTrue(invocation.getThis() == this);
97100
assertTrue("Invocation should be on ITestBean: " + invocation.getMethod(),
98-
invocation.getMethod().getDeclaringClass() == ITestBean.class);
101+
invocation.getMethod().getDeclaringClass() == ITestBean.class);
99102
}
100103
};
101104

102-
AdvisedSupport pc = new AdvisedSupport(new Class<?>[] { ITestBean.class, IOther.class });
105+
AdvisedSupport pc = new AdvisedSupport(new Class<?>[] {ITestBean.class, IOther.class});
103106
pc.addAdvice(ExposeInvocationInterceptor.INSTANCE);
104107
TrapTargetInterceptor tii = new TrapTargetInterceptor() {
105108
@Override
@@ -126,10 +129,11 @@ public Object invoke(MethodInvocation invocation) throws Throwable {
126129
//assertTrue(target.invocation == tii.invocation);
127130
}
128131

132+
@Test
129133
public void testProxyNotWrappedIfIncompatible() {
130134
FooBar bean = new FooBar();
131135
ProxyCreatorSupport as = new ProxyCreatorSupport();
132-
as.setInterfaces(new Class<?>[] {Foo.class});
136+
as.setInterfaces(Foo.class);
133137
as.setTarget(bean);
134138

135139
Foo proxy = (Foo) createProxy(as);
@@ -138,6 +142,7 @@ public void testProxyNotWrappedIfIncompatible() {
138142

139143
}
140144

145+
@Test
141146
public void testEqualsAndHashCodeDefined() throws Exception {
142147
AdvisedSupport as = new AdvisedSupport(new Class<?>[]{Named.class});
143148
as.setTarget(new Person());
@@ -149,16 +154,15 @@ public void testEqualsAndHashCodeDefined() throws Exception {
149154
}
150155

151156

152-
public static interface Foo {
157+
public interface Foo {
153158

154159
Bar getBarThis();
155160

156161
Foo getFooThis();
157162
}
158163

159164

160-
public static interface Bar {
161-
165+
public interface Bar {
162166
}
163167

164168

@@ -176,7 +180,7 @@ public Foo getFooThis() {
176180
}
177181

178182

179-
public static interface Named {
183+
public interface Named {
180184

181185
String getName();
182186

@@ -201,11 +205,8 @@ public String getName() {
201205
public boolean equals(Object o) {
202206
if (this == o) return true;
203207
if (o == null || getClass() != o.getClass()) return false;
204-
205-
final Person person = (Person) o;
206-
208+
Person person = (Person) o;
207209
if (!name.equals(person.name)) return false;
208-
209210
return true;
210211
}
211212

spring-expression/src/main/java/org/springframework/expression/spel/support/ReflectiveMethodExecutor.java

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 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.
@@ -35,11 +35,11 @@
3535
public class ReflectiveMethodExecutor implements MethodExecutor {
3636

3737
private final Method method;
38-
38+
3939
private final Integer varargsPosition;
4040

4141
private boolean computedPublicDeclaringClass = false;
42-
42+
4343
private Class<?> publicDeclaringClass;
4444

4545
private boolean argumentConversionOccurred = false;
@@ -58,10 +58,10 @@ public ReflectiveMethodExecutor(Method method) {
5858
public Method getMethod() {
5959
return this.method;
6060
}
61-
61+
6262
/**
6363
* Find the first public class in the methods declaring class hierarchy that declares this method.
64-
* Sometimes the reflective method discovery logic finds a suitable method that can easily be
64+
* Sometimes the reflective method discovery logic finds a suitable method that can easily be
6565
* called via reflection but cannot be called from generated code when compiling the expression
6666
* because of visibility restrictions. For example if a non public class overrides toString(), this
6767
* helper method will walk up the type hierarchy to find the first public type that declares the
@@ -80,20 +80,21 @@ private Class<?> discoverPublicClass(Method method, Class<?> clazz) {
8080
try {
8181
clazz.getDeclaredMethod(method.getName(), method.getParameterTypes());
8282
return clazz;
83-
} catch (NoSuchMethodException nsme) {
84-
83+
}
84+
catch (NoSuchMethodException ex) {
85+
// Continue below...
8586
}
8687
}
87-
Class<?>[] intfaces = clazz.getInterfaces();
88-
for (Class<?> intface: intfaces) {
89-
discoverPublicClass(method, intface);
88+
Class<?>[] ifcs = clazz.getInterfaces();
89+
for (Class<?> ifc: ifcs) {
90+
discoverPublicClass(method, ifc);
9091
}
9192
if (clazz.getSuperclass() != null) {
9293
return discoverPublicClass(method, clazz.getSuperclass());
9394
}
9495
return null;
9596
}
96-
97+
9798
public boolean didArgumentConversionOccur() {
9899
return this.argumentConversionOccurred;
99100
}

spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompDecoder.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 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.
@@ -58,9 +58,8 @@ public class StompDecoder {
5858

5959

6060
/**
61-
* Configure a
62-
* {@link org.springframework.messaging.support.MessageHeaderInitializer MessageHeaderInitializer}
63-
* to apply to the headers of {@link Message}s from decoded STOMP frames.
61+
* Configure a {@link MessageHeaderInitializer} to apply to the headers of
62+
* {@link Message}s from decoded STOMP frames.
6463
*/
6564
public void setHeaderInitializer(MessageHeaderInitializer headerInitializer) {
6665
this.headerInitializer = headerInitializer;

spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/ResponseBodyTests.java

Lines changed: 4 additions & 5 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.
@@ -38,22 +38,21 @@ public class ResponseBodyTests {
3838

3939
@Test
4040
public void json() throws Exception {
41-
4241
standaloneSetup(new PersonController()).build()
43-
.perform(get("/person/Lee").accept(MediaType.APPLICATION_JSON))
42+
.perform(get("/person/Lee").accept(MediaType.APPLICATION_JSON))
4443
.andExpect(status().isOk())
4544
.andExpect(content().contentType("application/json;charset=UTF-8"))
4645
.andExpect(jsonPath("$.name").value("Lee"));
4746
}
4847

48+
4949
@Controller
5050
private class PersonController {
5151

5252
@RequestMapping(value="/person/{name}")
5353
@ResponseBody
5454
public Person get(@PathVariable String name) {
55-
Person person = new Person(name);
56-
return person;
55+
return new Person(name);
5756
}
5857
}
5958

spring-web/src/main/java/org/springframework/web/accept/ContentNegotiationManagerFactoryBean.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 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.
@@ -234,7 +234,7 @@ public void afterPropertiesSet() {
234234
strategies.add(new HeaderContentNegotiationStrategy());
235235
}
236236

237-
if(this.defaultNegotiationStrategy != null) {
237+
if (this.defaultNegotiationStrategy != null) {
238238
strategies.add(defaultNegotiationStrategy);
239239
}
240240

0 commit comments

Comments
 (0)