Skip to content

Commit 2705788

Browse files
committed
Polishing
1 parent d74542e commit 2705788

File tree

3 files changed

+24
-23
lines changed

3 files changed

+24
-23
lines changed

spring-beans/src/main/java/org/springframework/beans/factory/parsing/Problem.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-2017 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.
@@ -42,7 +42,7 @@ public class Problem {
4242

4343
/**
4444
* Create a new instance of the {@link Problem} class.
45-
* @param message a message detailing the problem
45+
* @param message a message detailing the problem
4646
* @param location the location within a bean configuration source that triggered the error
4747
*/
4848
public Problem(String message, Location location) {
@@ -51,7 +51,7 @@ public Problem(String message, Location location) {
5151

5252
/**
5353
* Create a new instance of the {@link Problem} class.
54-
* @param message a message detailing the problem
54+
* @param message a message detailing the problem
5555
* @param parseState the {@link ParseState} at the time of the error
5656
* @param location the location within a bean configuration source that triggered the error
5757
*/
@@ -61,8 +61,8 @@ public Problem(String message, Location location, ParseState parseState) {
6161

6262
/**
6363
* Create a new instance of the {@link Problem} class.
64-
* @param message a message detailing the problem
65-
* @param rootCause the underlying expection that caused the error (may be {@code null})
64+
* @param message a message detailing the problem
65+
* @param rootCause the underlying exception that caused the error (may be {@code null})
6666
* @param parseState the {@link ParseState} at the time of the error
6767
* @param location the location within a bean configuration source that triggered the error
6868
*/
@@ -107,7 +107,7 @@ public ParseState getParseState() {
107107
}
108108

109109
/**
110-
* Get the underlying expection that caused the error (may be {@code null}).
110+
* Get the underlying exception that caused the error (may be {@code null}).
111111
*/
112112
public Throwable getRootCause() {
113113
return this.rootCause;

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,10 @@ public File getFile() throws IOException {
125125
}
126126

127127
/**
128-
* This implementation returns {@link Channels#newChannel(InputStream)} with the result of
129-
* {@link #getInputStream()}.
128+
* This implementation returns {@link Channels#newChannel(InputStream)}
129+
* with the result of {@link #getInputStream()}.
130+
* <p>This is the same as in {@link Resource}'s corresponding default method
131+
* but mirrored here for efficient JVM-level dispatching in a class hierarchy.
130132
*/
131133
@Override
132134
public ReadableByteChannel readableChannel() throws IOException {
@@ -138,7 +140,6 @@ public ReadableByteChannel readableChannel() throws IOException {
138140
* content length. Subclasses will almost always be able to provide
139141
* a more optimal version of this, e.g. checking a File length.
140142
* @see #getInputStream()
141-
* @throws IllegalStateException if {@link #getInputStream()} returns null.
142143
*/
143144
@Override
144145
public long contentLength() throws IOException {

spring-core/src/main/java/org/springframework/core/io/support/SpringFactoriesLoader.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
import org.apache.commons.logging.Log;
3030
import org.apache.commons.logging.LogFactory;
31+
3132
import org.springframework.core.annotation.AnnotationAwareOrderComparator;
3233
import org.springframework.core.io.UrlResource;
3334
import org.springframework.util.Assert;
@@ -60,21 +61,22 @@
6061
*/
6162
public abstract class SpringFactoriesLoader {
6263

63-
private static final Log logger = LogFactory.getLog(SpringFactoriesLoader.class);
64-
65-
private static Map<ClassLoader, MultiValueMap<String, String>> cache = new ConcurrentReferenceHashMap<>();
66-
6764
/**
6865
* The location to look for factories.
6966
* <p>Can be present in multiple JAR files.
7067
*/
7168
public static final String FACTORIES_RESOURCE_LOCATION = "META-INF/spring.factories";
7269

7370

71+
private static final Log logger = LogFactory.getLog(SpringFactoriesLoader.class);
72+
73+
private static final Map<ClassLoader, MultiValueMap<String, String>> cache = new ConcurrentReferenceHashMap<>();
74+
75+
7476
/**
7577
* Load and instantiate the factory implementations of the given type from
7678
* {@value #FACTORIES_RESOURCE_LOCATION}, using the given class loader.
77-
* <p>The returned factories are sorted in accordance with the {@link AnnotationAwareOrderComparator}.
79+
* <p>The returned factories are sorted through {@link AnnotationAwareOrderComparator}.
7880
* <p>If a custom instantiation strategy is required, use {@link #loadFactoryNames}
7981
* to obtain all registered factory names.
8082
* @param factoryClass the interface or abstract class representing the factory
@@ -113,19 +115,17 @@ public static <T> List<T> loadFactories(Class<T> factoryClass, ClassLoader class
113115
*/
114116
public static List<String> loadFactoryNames(Class<?> factoryClass, ClassLoader classLoader) {
115117
String factoryClassName = factoryClass.getName();
116-
return loadSpringFactories(classLoader).getOrDefault(factoryClassName,
117-
Collections.emptyList());
118+
return loadSpringFactories(classLoader).getOrDefault(factoryClassName, Collections.emptyList());
118119
}
119120

120-
private static Map<String, List<String>> loadSpringFactories(
121-
ClassLoader classLoader) {
121+
private static Map<String, List<String>> loadSpringFactories(ClassLoader classLoader) {
122122
MultiValueMap<String, String> result = cache.get(classLoader);
123123
if (result != null)
124124
return result;
125125
try {
126-
Enumeration<URL> urls = (classLoader != null
127-
? classLoader.getResources(FACTORIES_RESOURCE_LOCATION)
128-
: ClassLoader.getSystemResources(FACTORIES_RESOURCE_LOCATION));
126+
Enumeration<URL> urls = (classLoader != null ?
127+
classLoader.getResources(FACTORIES_RESOURCE_LOCATION) :
128+
ClassLoader.getSystemResources(FACTORIES_RESOURCE_LOCATION));
129129
result = new LinkedMultiValueMap<>();
130130
while (urls.hasMoreElements()) {
131131
URL url = urls.nextElement();
@@ -141,8 +141,8 @@ private static Map<String, List<String>> loadSpringFactories(
141141
return result;
142142
}
143143
catch (IOException ex) {
144-
throw new IllegalArgumentException("Unable to load factories from location ["
145-
+ FACTORIES_RESOURCE_LOCATION + "]", ex);
144+
throw new IllegalArgumentException("Unable to load factories from location [" +
145+
FACTORIES_RESOURCE_LOCATION + "]", ex);
146146
}
147147
}
148148

0 commit comments

Comments
 (0)