Skip to content

Commit b5127dc

Browse files
committed
Polishing
1 parent a9136d9 commit b5127dc

File tree

22 files changed

+116
-121
lines changed

22 files changed

+116
-121
lines changed

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

Lines changed: 11 additions & 10 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-2016 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.
@@ -151,7 +151,7 @@ public BeanWrapper autowireConstructor(final String beanName, final RootBeanDefi
151151
catch (Throwable ex) {
152152
throw new BeanCreationException(mbd.getResourceDescription(), beanName,
153153
"Resolution of declared constructors on bean Class [" + beanClass.getName() +
154-
"] from ClassLoader [" + beanClass.getClassLoader() + "] failed", ex);
154+
"] from ClassLoader [" + beanClass.getClassLoader() + "] failed", ex);
155155
}
156156
}
157157
AutowireUtils.sortConstructors(candidates);
@@ -609,8 +609,8 @@ public Object run() {
609609
private int resolveConstructorArguments(String beanName, RootBeanDefinition mbd, BeanWrapper bw,
610610
ConstructorArgumentValues cargs, ConstructorArgumentValues resolvedValues) {
611611

612-
TypeConverter converter = (this.beanFactory.getCustomTypeConverter() != null ?
613-
this.beanFactory.getCustomTypeConverter() : bw);
612+
TypeConverter customConverter = this.beanFactory.getCustomTypeConverter();
613+
TypeConverter converter = (customConverter != null ? customConverter : bw);
614614
BeanDefinitionValueResolver valueResolver =
615615
new BeanDefinitionValueResolver(this.beanFactory, beanName, mbd, converter);
616616

@@ -666,8 +666,8 @@ private ArgumentsHolder createArgumentArray(
666666
boolean autowiring) throws UnsatisfiedDependencyException {
667667

668668
String methodType = (methodOrCtor instanceof Constructor ? "constructor" : "factory method");
669-
TypeConverter converter = (this.beanFactory.getCustomTypeConverter() != null ?
670-
this.beanFactory.getCustomTypeConverter() : bw);
669+
TypeConverter customConverter = this.beanFactory.getCustomTypeConverter();
670+
TypeConverter converter = (customConverter != null ? customConverter : bw);
671671

672672
ArgumentsHolder args = new ArgumentsHolder(paramTypes.length);
673673
Set<ConstructorArgumentValues.ValueHolder> usedValueHolders =
@@ -768,12 +768,13 @@ private ArgumentsHolder createArgumentArray(
768768
private Object[] resolvePreparedArguments(
769769
String beanName, RootBeanDefinition mbd, BeanWrapper bw, Member methodOrCtor, Object[] argsToResolve) {
770770

771-
Class<?>[] paramTypes = (methodOrCtor instanceof Method ?
772-
((Method) methodOrCtor).getParameterTypes() : ((Constructor<?>) methodOrCtor).getParameterTypes());
773-
TypeConverter converter = (this.beanFactory.getCustomTypeConverter() != null ?
774-
this.beanFactory.getCustomTypeConverter() : bw);
771+
TypeConverter customConverter = this.beanFactory.getCustomTypeConverter();
772+
TypeConverter converter = (customConverter != null ? customConverter : bw);
775773
BeanDefinitionValueResolver valueResolver =
776774
new BeanDefinitionValueResolver(this.beanFactory, beanName, mbd, converter);
775+
Class<?>[] paramTypes = (methodOrCtor instanceof Method ?
776+
((Method) methodOrCtor).getParameterTypes() : ((Constructor<?>) methodOrCtor).getParameterTypes());
777+
777778
Object[] resolvedArgs = new Object[argsToResolve.length];
778779
for (int argIndex = 0; argIndex < argsToResolve.length; argIndex++) {
779780
Object argValue = argsToResolve[argIndex];

spring-context/src/main/java/org/springframework/jmx/export/assembler/MethodNameBasedMBeanInfoAssembler.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-2016 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.
@@ -72,7 +72,7 @@ public class MethodNameBasedMBeanInfoAssembler extends AbstractConfigurableMBean
7272
* @param methodNames an array of method names indicating the methods to use
7373
* @see #setMethodMappings
7474
*/
75-
public void setManagedMethods(String[] methodNames) {
75+
public void setManagedMethods(String... methodNames) {
7676
this.managedMethods = new HashSet<String>(Arrays.asList(methodNames));
7777
}
7878

spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodNameBasedMBeanInfoAssemblerMappedTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public void testGetAgeIsReadOnly() throws Exception {
4747
public void testWithFallThrough() throws Exception {
4848
MethodNameBasedMBeanInfoAssembler assembler =
4949
getWithMapping("foobar", "add,myOperation,getName,setName,getAge");
50-
assembler.setManagedMethods(new String[]{"getNickName", "setNickName"});
50+
assembler.setManagedMethods("getNickName", "setNickName");
5151

5252
ModelMBeanInfo inf = assembler.getMBeanInfo(getBean(), getObjectName());
5353
MBeanAttributeInfo attr = inf.getAttribute("NickName");

spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodNameBasedMBeanInfoAssemblerTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ protected int getExpectedAttributeCount() {
5252
@Override
5353
protected MBeanInfoAssembler getAssembler() {
5454
MethodNameBasedMBeanInfoAssembler assembler = new MethodNameBasedMBeanInfoAssembler();
55-
assembler.setManagedMethods(new String[] {"add", "myOperation", "getName", "setName", "getAge"});
55+
assembler.setManagedMethods("add", "myOperation", "getName", "setName", "getAge");
5656
return assembler;
5757
}
5858

spring-core/src/main/java/org/springframework/core/ConfigurableObjectInputStream.java

Lines changed: 6 additions & 6 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-2016 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.
@@ -21,7 +21,6 @@
2121
import java.io.NotSerializableException;
2222
import java.io.ObjectInputStream;
2323
import java.io.ObjectStreamClass;
24-
import java.lang.reflect.Proxy;
2524

2625
import org.springframework.util.ClassUtils;
2726

@@ -101,7 +100,7 @@ protected Class<?> resolveProxyClass(String[] interfaces) throws IOException, Cl
101100
}
102101
}
103102
try {
104-
return Proxy.getProxyClass(this.classLoader, resolvedInterfaces);
103+
return ClassUtils.createCompositeInterface(resolvedInterfaces, this.classLoader);
105104
}
106105
catch (IllegalArgumentException ex) {
107106
throw new ClassNotFoundException(null, ex);
@@ -117,7 +116,7 @@ protected Class<?> resolveProxyClass(String[] interfaces) throws IOException, Cl
117116
for (int i = 0; i < interfaces.length; i++) {
118117
resolvedInterfaces[i] = resolveFallbackIfPossible(interfaces[i], ex);
119118
}
120-
return Proxy.getProxyClass(getFallbackClassLoader(), resolvedInterfaces);
119+
return ClassUtils.createCompositeInterface(resolvedInterfaces, getFallbackClassLoader());
121120
}
122121
}
123122
}
@@ -139,8 +138,9 @@ protected Class<?> resolveFallbackIfPossible(String className, ClassNotFoundExce
139138

140139
/**
141140
* Return the fallback ClassLoader to use when no ClassLoader was specified
142-
* and ObjectInputStream's own default ClassLoader failed.
143-
* <p>The default implementation simply returns {@code null}.
141+
* and ObjectInputStream's own default class loader failed.
142+
* <p>The default implementation simply returns {@code null}, indicating
143+
* that no specific fallback is available.
144144
*/
145145
protected ClassLoader getFallbackClassLoader() throws IOException {
146146
return null;

spring-core/src/main/java/org/springframework/core/io/AbstractFileResolvingResource.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2015 the original author or authors.
2+
* Copyright 2002-2016 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.
@@ -72,7 +72,7 @@ protected File getFileForLastModifiedCheck() throws IOException {
7272
}
7373

7474
/**
75-
* This implementation returns a File reference for the underlying class path
75+
* This implementation returns a File reference for the given URI-identified
7676
* resource, provided that it refers to a file in the file system.
7777
* @see org.springframework.util.ResourceUtils#getFile(java.net.URI, String)
7878
*/

spring-core/src/main/java/org/springframework/core/io/PathResource.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2015 the original author or authors.
2+
* Copyright 2002-2016 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.
@@ -182,8 +182,8 @@ public File getFile() throws IOException {
182182
return this.path.toFile();
183183
}
184184
catch (UnsupportedOperationException ex) {
185-
// only Paths on the default file system can be converted to a File
186-
// do exception translation for cases where conversion is not possible
185+
// Only paths on the default file system can be converted to a File:
186+
// Do exception translation for cases where conversion is not possible.
187187
throw new FileNotFoundException(this.path + " cannot be resolved to " + "absolute file path");
188188
}
189189
}

spring-core/src/main/java/org/springframework/core/io/Resource.java

Lines changed: 12 additions & 11 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-2016 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,26 +37,26 @@
3737
* @see #getFile()
3838
* @see WritableResource
3939
* @see ContextResource
40-
* @see FileSystemResource
41-
* @see ClassPathResource
4240
* @see UrlResource
41+
* @see ClassPathResource
42+
* @see FileSystemResource
43+
* @see PathResource
4344
* @see ByteArrayResource
4445
* @see InputStreamResource
45-
* @see PathResource
4646
*/
4747
public interface Resource extends InputStreamSource {
4848

4949
/**
50-
* Return whether this resource actually exists in physical form.
50+
* Determine whether this resource actually exists in physical form.
5151
* <p>This method performs a definitive existence check, whereas the
52-
* existence of a {@code Resource} handle only guarantees a
53-
* valid descriptor handle.
52+
* existence of a {@code Resource} handle only guarantees a valid
53+
* descriptor handle.
5454
*/
5555
boolean exists();
5656

5757
/**
58-
* Return whether the contents of this resource can be read,
59-
* e.g. via {@link #getInputStream()} or {@link #getFile()}.
58+
* Indicate whether the contents of this resource can be read via
59+
* {@link #getInputStream()}.
6060
* <p>Will be {@code true} for typical resource descriptors;
6161
* note that actual content reading may still fail when attempted.
6262
* However, a value of {@code false} is a definitive indication
@@ -66,8 +66,8 @@ public interface Resource extends InputStreamSource {
6666
boolean isReadable();
6767

6868
/**
69-
* Return whether this resource represents a handle with an open
70-
* stream. If true, the InputStream cannot be read multiple times,
69+
* Indicate whether this resource represents a handle with an open stream.
70+
* If {@code true}, the InputStream cannot be read multiple times,
7171
* and must be read and closed to avoid resource leaks.
7272
* <p>Will be {@code false} for typical resource descriptors.
7373
*/
@@ -84,6 +84,7 @@ public interface Resource extends InputStreamSource {
8484
* Return a URI handle for this resource.
8585
* @throws IOException if the resource cannot be resolved as URI,
8686
* i.e. if the resource is not available as descriptor
87+
* @since 2.5
8788
*/
8889
URI getURI() throws IOException;
8990

spring-core/src/main/java/org/springframework/core/io/UrlResource.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2015 the original author or authors.
2+
* Copyright 2002-2016 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.
@@ -61,6 +61,7 @@ public class UrlResource extends AbstractFileResolvingResource {
6161
* Create a new {@code UrlResource} based on the given URI object.
6262
* @param uri a URI
6363
* @throws MalformedURLException if the given URL path is not valid
64+
* @since 2.5
6465
*/
6566
public UrlResource(URI uri) throws MalformedURLException {
6667
Assert.notNull(uri, "URI must not be null");

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1158,7 +1158,6 @@ public static Set<Class<?>> getAllInterfacesForClassAsSet(Class<?> clazz, ClassL
11581158
*/
11591159
public static Class<?> createCompositeInterface(Class<?>[] interfaces, ClassLoader classLoader) {
11601160
Assert.notEmpty(interfaces, "Interfaces must not be empty");
1161-
Assert.notNull(classLoader, "ClassLoader must not be null");
11621161
return Proxy.getProxyClass(classLoader, interfaces);
11631162
}
11641163

0 commit comments

Comments
 (0)