Skip to content

Commit 71fc2ba

Browse files
committed
Polishing
1 parent 48838d4 commit 71fc2ba

File tree

20 files changed

+181
-184
lines changed

20 files changed

+181
-184
lines changed

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

Lines changed: 5 additions & 3 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.
@@ -243,6 +243,7 @@ public String toString() {
243243

244244
private String toString(boolean includeModifier, boolean includeReturnTypeAndArgs,
245245
boolean useLongReturnAndArgumentTypeName, boolean useLongTypeName) {
246+
246247
StringBuilder sb = new StringBuilder();
247248
if (includeModifier) {
248249
sb.append(Modifier.toString(getModifiers()));
@@ -262,8 +263,9 @@ private String toString(boolean includeModifier, boolean includeReturnTypeAndArg
262263
return sb.toString();
263264
}
264265

265-
private void appendTypes(StringBuilder sb, Class<?>[] types,
266-
boolean includeArgs, boolean useLongReturnAndArgumentTypeName) {
266+
private void appendTypes(StringBuilder sb, Class<?>[] types, boolean includeArgs,
267+
boolean useLongReturnAndArgumentTypeName) {
268+
267269
if (includeArgs) {
268270
for (int size = types.length, i = 0; i < size; i++) {
269271
appendType(sb, types[i], useLongReturnAndArgumentTypeName);

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

Lines changed: 5 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.
@@ -48,8 +48,8 @@ public interface BeanPostProcessor {
4848
* The returned bean instance may be a wrapper around the original.
4949
* @param bean the new bean instance
5050
* @param beanName the name of the bean
51-
* @return the bean instance to use, either the original or a wrapped one; if
52-
* {@code null}, no subsequent BeanPostProcessors will be invoked
51+
* @return the bean instance to use, either the original or a wrapped one;
52+
* if {@code null}, no subsequent BeanPostProcessors will be invoked
5353
* @throws org.springframework.beans.BeansException in case of errors
5454
* @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet
5555
*/
@@ -69,8 +69,8 @@ public interface BeanPostProcessor {
6969
* in contrast to all other BeanPostProcessor callbacks.
7070
* @param bean the new bean instance
7171
* @param beanName the name of the bean
72-
* @return the bean instance to use, either the original or a wrapped one; if
73-
* {@code null}, no subsequent BeanPostProcessors will be invoked
72+
* @return the bean instance to use, either the original or a wrapped one;
73+
* if {@code null}, no subsequent BeanPostProcessors will be invoked
7474
* @throws org.springframework.beans.BeansException in case of errors
7575
* @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet
7676
* @see org.springframework.beans.factory.FactoryBean

spring-beans/src/main/java/org/springframework/beans/factory/support/DisposableBeanAdapter.java

Lines changed: 8 additions & 7 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.
@@ -37,11 +37,12 @@
3737
import org.springframework.beans.factory.config.DestructionAwareBeanPostProcessor;
3838
import org.springframework.util.Assert;
3939
import org.springframework.util.ClassUtils;
40+
import org.springframework.util.CollectionUtils;
4041
import org.springframework.util.ReflectionUtils;
4142

4243
/**
43-
* Adapter that implements the {@link DisposableBean} and {@link Runnable} interfaces
44-
* performing various destruction steps on a given bean instance:
44+
* Adapter that implements the {@link DisposableBean} and {@link Runnable}
45+
* interfaces performing various destruction steps on a given bean instance:
4546
* <ul>
4647
* <li>DestructionAwareBeanPostProcessors;
4748
* <li>the bean implementing DisposableBean itself;
@@ -175,8 +176,8 @@ private DisposableBeanAdapter(Object bean, String beanName, boolean invokeDispos
175176
/**
176177
* If the current value of the given beanDefinition's "destroyMethodName" property is
177178
* {@link AbstractBeanDefinition#INFER_METHOD}, then attempt to infer a destroy method.
178-
* Candidate methods are currently limited to public, no-arg methods named "close"
179-
* (whether declared locally or inherited). The given BeanDefinition's
179+
* Candidate methods are currently limited to public, no-arg methods named "close" or
180+
* "shutdown" (whether declared locally or inherited). The given BeanDefinition's
180181
* "destroyMethodName" is updated to be null if no such method is found, otherwise set
181182
* to the name of the inferred method. This constant serves as the default for the
182183
* {@code @Bean#destroyMethod} attribute and the value of the constant may also be
@@ -215,7 +216,7 @@ private String inferDestroyMethodIfNecessary(Object bean, RootBeanDefinition bea
215216
*/
216217
private List<DestructionAwareBeanPostProcessor> filterPostProcessors(List<BeanPostProcessor> postProcessors) {
217218
List<DestructionAwareBeanPostProcessor> filteredPostProcessors = null;
218-
if (postProcessors != null && !postProcessors.isEmpty()) {
219+
if (!CollectionUtils.isEmpty(postProcessors)) {
219220
filteredPostProcessors = new ArrayList<DestructionAwareBeanPostProcessor>(postProcessors.size());
220221
for (BeanPostProcessor postProcessor : postProcessors) {
221222
if (postProcessor instanceof DestructionAwareBeanPostProcessor) {
@@ -234,7 +235,7 @@ public void run() {
234235

235236
@Override
236237
public void destroy() {
237-
if (this.beanPostProcessors != null && !this.beanPostProcessors.isEmpty()) {
238+
if (!CollectionUtils.isEmpty(this.beanPostProcessors)) {
238239
for (DestructionAwareBeanPostProcessor processor : this.beanPostProcessors) {
239240
processor.postProcessBeforeDestruction(this.bean, this.beanName);
240241
}

spring-context/src/test/java/org/springframework/context/annotation/AnnotationConfigApplicationContextTests.java

Lines changed: 16 additions & 15 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.
@@ -25,6 +25,7 @@
2525
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
2626
import org.springframework.beans.factory.annotation.Autowired;
2727
import org.springframework.beans.factory.config.BeanPostProcessor;
28+
import org.springframework.context.ApplicationContext;
2829
import org.springframework.context.annotation6.ComponentForScanning;
2930
import org.springframework.context.annotation6.ConfigForScanning;
3031
import org.springframework.context.annotation6.Jsr330NamedForScanning;
@@ -40,10 +41,10 @@
4041
*/
4142
public class AnnotationConfigApplicationContextTests {
4243

43-
@Test(expected=IllegalArgumentException.class)
44+
@Test(expected = IllegalArgumentException.class)
4445
public void nullGetBeanParameterIsDisallowed() {
45-
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(Config.class);
46-
context.getBean((Class<?>)null);
46+
ApplicationContext context = new AnnotationConfigApplicationContext(Config.class);
47+
context.getBean((Class<?>) null);
4748
}
4849

4950
@Test
@@ -83,7 +84,7 @@ public void getBeansWithAnnotation() {
8384

8485
@Test
8586
public void getBeanByType() {
86-
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(Config.class);
87+
ApplicationContext context = new AnnotationConfigApplicationContext(Config.class);
8788
TestBean testBean = context.getBean(TestBean.class);
8889
assertNotNull("getBean() should not return null", testBean);
8990
assertThat(testBean.name, equalTo("foo"));
@@ -95,7 +96,7 @@ public void getBeanByType() {
9596
*/
9697
@Test
9798
public void defaultConfigClassBeanNameIsGeneratedProperly() {
98-
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(Config.class);
99+
ApplicationContext context = new AnnotationConfigApplicationContext(Config.class);
99100

100101
// attempt to retrieve the instance by its generated bean name
101102
Config configObject = (Config) context.getBean("annotationConfigApplicationContextTests.Config");
@@ -108,18 +109,16 @@ public void defaultConfigClassBeanNameIsGeneratedProperly() {
108109
*/
109110
@Test
110111
public void explicitConfigClassBeanNameIsRespected() {
111-
AnnotationConfigApplicationContext context =
112-
new AnnotationConfigApplicationContext(ConfigWithCustomName.class);
112+
ApplicationContext context = new AnnotationConfigApplicationContext(ConfigWithCustomName.class);
113113

114114
// attempt to retrieve the instance by its specified name
115-
ConfigWithCustomName configObject =
116-
(ConfigWithCustomName) context.getBean("customConfigBeanName");
115+
ConfigWithCustomName configObject = (ConfigWithCustomName) context.getBean("customConfigBeanName");
117116
assertNotNull(configObject);
118117
}
119118

120119
@Test
121120
public void getBeanByTypeRaisesNoSuchBeanDefinitionException() {
122-
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(Config.class);
121+
ApplicationContext context = new AnnotationConfigApplicationContext(Config.class);
123122

124123
// attempt to retrieve a bean that does not exist
125124
Class<?> targetType = Pattern.class;
@@ -135,7 +134,7 @@ public void getBeanByTypeRaisesNoSuchBeanDefinitionException() {
135134

136135
@Test
137136
public void getBeanByTypeAmbiguityRaisesException() {
138-
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(TwoTestBeanConfig.class);
137+
ApplicationContext context = new AnnotationConfigApplicationContext(TwoTestBeanConfig.class);
139138

140139
try {
141140
context.getBean(TestBean.class);
@@ -153,7 +152,7 @@ public void getBeanByTypeAmbiguityRaisesException() {
153152

154153
@Test
155154
public void autowiringIsEnabledByDefault() {
156-
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(AutowiredConfig.class);
155+
ApplicationContext context = new AnnotationConfigApplicationContext(AutowiredConfig.class);
157156
assertThat(context.getBean(TestBean.class).name, equalTo("foo"));
158157
}
159158

@@ -255,13 +254,14 @@ public boolean isSingleton() {
255254
}
256255

257256
class TestBean {
257+
258258
String name;
259259

260260
@Override
261261
public int hashCode() {
262262
final int prime = 31;
263263
int result = 1;
264-
result = prime * result + ((name == null) ? 0 : name.hashCode());
264+
result = prime * result + (name == null ? 0 : name.hashCode());
265265
return result;
266266
}
267267

@@ -277,7 +277,8 @@ public boolean equals(Object obj) {
277277
if (name == null) {
278278
if (other.name != null)
279279
return false;
280-
} else if (!name.equals(other.name))
280+
}
281+
else if (!name.equals(other.name))
281282
return false;
282283
return true;
283284
}

spring-core/src/main/java/org/springframework/util/ReflectionUtils.java

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public static Field findField(Class<?> clazz, String name, Class<?> type) {
102102
* <p>Thrown exceptions are handled via a call to {@link #handleReflectionException(Exception)}.
103103
* @param field the field to set
104104
* @param target the target object on which to set the field
105-
* @param value the value to set; may be {@code null}
105+
* @param value the value to set (may be {@code null})
106106
*/
107107
public static void setField(Field field, Object target, Object value) {
108108
try {
@@ -284,12 +284,11 @@ public static void handleInvocationTargetException(InvocationTargetException ex)
284284

285285
/**
286286
* Rethrow the given {@link Throwable exception}, which is presumably the
287-
* <em>target exception</em> of an {@link InvocationTargetException}. Should
288-
* only be called if no checked exception is expected to be thrown by the
289-
* target method.
287+
* <em>target exception</em> of an {@link InvocationTargetException}.
288+
* Should only be called if no checked exception is expected to be thrown
289+
* by the target method.
290290
* <p>Rethrows the underlying exception cast to an {@link RuntimeException} or
291-
* {@link Error} if appropriate; otherwise, throws an
292-
* {@link IllegalStateException}.
291+
* {@link Error} if appropriate; otherwise, throws an {@link IllegalStateException}.
293292
* @param ex the exception to rethrow
294293
* @throws RuntimeException the rethrown exception
295294
*/
@@ -305,12 +304,11 @@ public static void rethrowRuntimeException(Throwable ex) {
305304

306305
/**
307306
* Rethrow the given {@link Throwable exception}, which is presumably the
308-
* <em>target exception</em> of an {@link InvocationTargetException}. Should
309-
* only be called if no checked exception is expected to be thrown by the
310-
* target method.
307+
* <em>target exception</em> of an {@link InvocationTargetException}.
308+
* Should only be called if no checked exception is expected to be thrown
309+
* by the target method.
311310
* <p>Rethrows the underlying exception cast to an {@link Exception} or
312-
* {@link Error} if appropriate; otherwise, throws an
313-
* {@link IllegalStateException}.
311+
* {@link Error} if appropriate; otherwise, throws an {@link IllegalStateException}.
314312
* @param ex the exception to rethrow
315313
* @throws Exception the rethrown exception (in case of a checked exception)
316314
*/

spring-jdbc/src/main/java/org/springframework/jdbc/core/SqlParameter.java

Lines changed: 2 additions & 3 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.
@@ -43,7 +43,6 @@ public class SqlParameter {
4343
/** Used for types that are user-named like: STRUCT, DISTINCT, JAVA_OBJECT, named array types */
4444
private String typeName;
4545

46-
4746
/** The scale to apply in case of a NUMERIC or DECIMAL type, if any */
4847
private Integer scale;
4948

@@ -126,7 +125,7 @@ public SqlParameter(SqlParameter otherParam) {
126125

127126

128127
/**
129-
* Return the name of the parameter.
128+
* Return the name of the parameter, or {@code null} if anonymous.
130129
*/
131130
public String getName() {
132131
return this.name;

spring-jdbc/src/main/java/org/springframework/jdbc/core/simple/SimpleJdbcCall.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.
@@ -39,18 +39,19 @@
3939
* the JDBC driver. Since we rely on the JDBC driver, this "auto-detection"
4040
* can only be used for databases that are known to provide accurate meta data.
4141
* These currently include Derby, MySQL, Microsoft SQL Server, Oracle, DB2,
42-
* Sybase and PostgreSQL. For any other databases you are required to declare all
43-
* parameters explicitly. You can of course declare all parameters explicitly even
44-
* if the database provides the necessary meta data. In that case your declared
45-
* parameters will take precedence. You can also turn off any meta data processing
46-
* if you want to use parameter names that do not match what is declared during
47-
* the stored procedure compilation.
42+
* Sybase and PostgreSQL. For any other databases you are required to declare
43+
* all parameters explicitly. You can of course declare all parameters
44+
* explicitly even if the database provides the necessary meta data. In that
45+
* case your declared parameters will take precedence. You can also turn off
46+
* any metadata processing if you want to use parameter names that do not
47+
* match what is declared during the stored procedure compilation.
4848
*
4949
* <p>The actual insert is being handled using Spring's
5050
* {@link org.springframework.jdbc.core.JdbcTemplate}.
5151
*
52-
* <p>Many of the configuration methods return the current instance of the SimpleJdbcCall
53-
* to provide the ability to chain multiple ones together in a "fluent" interface style.
52+
* <p>Many of the configuration methods return the current instance of the
53+
* SimpleJdbcCall in order to provide the ability to chain multiple ones
54+
* together in a "fluent" interface style.
5455
*
5556
* @author Thomas Risberg
5657
* @since 2.5
@@ -60,8 +61,8 @@
6061
public class SimpleJdbcCall extends AbstractJdbcCall implements SimpleJdbcCallOperations {
6162

6263
/**
63-
* Constructor that takes one parameter with the JDBC DataSource to use when creating the
64-
* JdbcTemplate.
64+
* Constructor that takes one parameter with the JDBC DataSource to use when
65+
* creating the underlying JdbcTemplate.
6566
* @param dataSource the {@code DataSource} to use
6667
* @see org.springframework.jdbc.core.JdbcTemplate#setDataSource
6768
*/

spring-jdbc/src/test/java/org/springframework/jdbc/core/simple/SimpleJdbcCallTests.java

Lines changed: 7 additions & 9 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.
@@ -103,8 +103,7 @@ public void testAddInvoiceProcWithoutMetaDataUsingMapParamSource() throws Except
103103
adder.declareParameters(
104104
new SqlParameter("amount", Types.INTEGER),
105105
new SqlParameter("custid", Types.INTEGER),
106-
new SqlOutParameter("newid",
107-
Types.INTEGER));
106+
new SqlOutParameter("newid", Types.INTEGER));
108107
Number newId = adder.executeObject(Number.class, new MapSqlParameterSource().
109108
addValue("amount", 1103).
110109
addValue("custid", 3));
@@ -120,8 +119,7 @@ public void testAddInvoiceProcWithoutMetaDataUsingArrayParams() throws Exception
120119
adder.declareParameters(
121120
new SqlParameter("amount", Types.INTEGER),
122121
new SqlParameter("custid", Types.INTEGER),
123-
new SqlOutParameter("newid",
124-
Types.INTEGER));
122+
new SqlOutParameter("newid", Types.INTEGER));
125123
Number newId = adder.executeObject(Number.class, 1103, 3);
126124
assertEquals(4, newId.intValue());
127125
verifyAddInvoiceWithoutMetaData(false);
@@ -193,7 +191,8 @@ public void testAddInvoiceFuncWithMetaDataUsingMapParamSource() throws Exception
193191

194192
}
195193

196-
@Test public void testAddInvoiceFuncWithMetaDataUsingArrayParams() throws Exception {
194+
@Test
195+
public void testAddInvoiceFuncWithMetaDataUsingArrayParams() throws Exception {
197196
initializeAddInvoiceWithMetaData(true);
198197
SimpleJdbcCall adder = new SimpleJdbcCall(dataSource).withFunctionName("add_invoice");
199198
Number newId = adder.executeFunction(Number.class, 1103, 3);
@@ -203,8 +202,7 @@ public void testAddInvoiceFuncWithMetaDataUsingMapParamSource() throws Exception
203202

204203
}
205204

206-
private void initializeAddInvoiceWithoutMetaData(boolean isFunction)
207-
throws SQLException {
205+
private void initializeAddInvoiceWithoutMetaData(boolean isFunction) throws SQLException {
208206
given(databaseMetaData.getDatabaseProductName()).willReturn("MyDB");
209207
given(databaseMetaData.getUserName()).willReturn("me");
210208
given(databaseMetaData.storesLowerCaseIdentifiers()).willReturn(true);
@@ -281,6 +279,6 @@ private void verifyAddInvoiceWithMetaData(boolean isFunction) throws SQLExceptio
281279
verify(callableStatement).close();
282280
verify(proceduresResultSet).close();
283281
verify(procedureColumnsResultSet).close();
282+
}
284283

285284
}
286-
}

0 commit comments

Comments
 (0)