Skip to content

Commit d5e4592

Browse files
committed
Polishing
1 parent 233393e commit d5e4592

File tree

8 files changed

+48
-50
lines changed

8 files changed

+48
-50
lines changed

spring-beans/src/main/java/org/springframework/beans/factory/NoSuchBeanDefinitionException.java

Lines changed: 7 additions & 5 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-2014 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,21 +20,23 @@
2020
import org.springframework.util.StringUtils;
2121

2222
/**
23-
* Exception thrown when a {@code BeanFactory} is asked for a bean instance
24-
* for which it cannot find a definition.
23+
* Exception thrown when a {@code BeanFactory} is asked for a bean instance for which it
24+
* cannot find a definition. This may point to a non-existing bean, a non-unique bean,
25+
* or a manually registered singleton instance without an associated bean definition.
2526
*
2627
* @author Rod Johnson
2728
* @author Juergen Hoeller
2829
* @see BeanFactory#getBean(String)
2930
* @see BeanFactory#getBean(Class)
31+
* @see NoUniqueBeanDefinitionException
3032
*/
3133
@SuppressWarnings("serial")
3234
public class NoSuchBeanDefinitionException extends BeansException {
3335

34-
/** Name of the missing bean. */
36+
/** Name of the missing bean */
3537
private String beanName;
3638

37-
/** Required type of the missing bean. */
39+
/** Required type of the missing bean */
3840
private Class<?> beanType;
3941

4042

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,14 +135,14 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
135135
/** Map of bean definition objects, keyed by bean name */
136136
private final Map<String, BeanDefinition> beanDefinitionMap = new ConcurrentHashMap<String, BeanDefinition>(64);
137137

138-
/** Map of singleton and non-singleton bean names keyed by dependency type */
138+
/** Map of singleton and non-singleton bean names, keyed by dependency type */
139139
private final Map<Class<?>, String[]> allBeanNamesByType = new ConcurrentHashMap<Class<?>, String[]>(64);
140140

141-
/** Map of singleton-only bean names keyed by dependency type */
141+
/** Map of singleton-only bean names, keyed by dependency type */
142142
private final Map<Class<?>, String[]> singletonBeanNamesByType = new ConcurrentHashMap<Class<?>, String[]>(64);
143143

144144
/** List of bean definition names, in registration order */
145-
private final List<String> beanDefinitionNames = new ArrayList<String>();
145+
private final List<String> beanDefinitionNames = new ArrayList<String>(64);
146146

147147
/** Whether bean definition metadata may be cached for all beans */
148148
private boolean configurationFrozen = false;

spring-expression/src/test/java/org/springframework/expression/spel/SpelReproTests.java

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1847,21 +1847,21 @@ public static class BooleanHolder {
18471847

18481848
private boolean primitiveProperty = true;
18491849

1850-
public Boolean isSimpleProperty() {
1851-
return simpleProperty;
1852-
}
1853-
18541850
public void setSimpleProperty(Boolean simpleProperty) {
18551851
this.simpleProperty = simpleProperty;
18561852
}
18571853

1858-
public boolean isPrimitiveProperty() {
1859-
return primitiveProperty;
1854+
public Boolean isSimpleProperty() {
1855+
return this.simpleProperty;
18601856
}
18611857

18621858
public void setPrimitiveProperty(boolean primitiveProperty) {
18631859
this.primitiveProperty = primitiveProperty;
18641860
}
1861+
1862+
public boolean isPrimitiveProperty() {
1863+
return this.primitiveProperty;
1864+
}
18651865
}
18661866

18671867

@@ -1914,13 +1914,13 @@ public static class Spr10486 {
19141914

19151915
private String name = "name";
19161916

1917-
public String getName() {
1918-
return name;
1919-
}
1920-
19211917
public void setName(String name) {
19221918
this.name = name;
19231919
}
1920+
1921+
public String getName() {
1922+
return this.name;
1923+
}
19241924
}
19251925

19261926

@@ -1932,25 +1932,22 @@ public String isSomething() {
19321932
}
19331933

19341934

1935-
static class TestClass2 { // SPR-9194
1935+
static class TestClass2 { // SPR-9194
19361936

19371937
String string;
19381938

1939-
19401939
public TestClass2(String string) {
19411940
this.string = string;
19421941
}
19431942

1944-
@Override
1945-
public int hashCode() {
1946-
return 0;
1943+
public boolean equals(Object other) {
1944+
return (this == other || (other instanceof TestClass2 &&
1945+
this.string.equals(((TestClass2) other).string)));
19471946
}
19481947

1949-
public boolean equals(Object o) {
1950-
if (o instanceof TestClass2) {
1951-
return string.equals(((TestClass2) o).string);
1952-
}
1953-
return false;
1948+
@Override
1949+
public int hashCode() {
1950+
return this.string.hashCode();
19541951
}
19551952
}
19561953

@@ -1964,12 +1961,12 @@ public int echo(int invocation) {
19641961
}
19651962

19661963
public int parameter() {
1967-
return counter.incrementAndGet();
1964+
return this.counter.incrementAndGet();
19681965
}
19691966

19701967
@Override
19711968
public Object resolve(EvaluationContext context, String beanName) throws AccessException {
1972-
return beanName.equals("bean") ? this : null;
1969+
return (beanName.equals("bean") ? this : null);
19731970
}
19741971
}
19751972

spring-jms/src/main/java/org/springframework/jms/connection/DelegatingConnectionFactory.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-2014 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 ConnectionFactory getTargetConnectionFactory() {
7676
/**
7777
* Indicate whether Connections obtained from the target factory are supposed
7878
* to be stopped before closed ("true") or simply closed ("false").
79-
* The latter may be necessary for some connection pools that simply return
79+
* An extra stop call may be necessary for some connection pools that simply return
8080
* released connections to the pool, not stopping them while they sit in the pool.
8181
* <p>Default is "false", simply closing Connections.
8282
* @see ConnectionFactoryUtils#releaseConnection

spring-jms/src/main/java/org/springframework/jms/connection/SingleConnectionFactory.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,8 @@
7373
* @see org.springframework.jms.listener.SimpleMessageListenerContainer
7474
* @see org.springframework.jms.listener.DefaultMessageListenerContainer#setCacheLevel
7575
*/
76-
public class SingleConnectionFactory
77-
implements ConnectionFactory, QueueConnectionFactory, TopicConnectionFactory, ExceptionListener,
78-
InitializingBean, DisposableBean {
76+
public class SingleConnectionFactory implements ConnectionFactory, QueueConnectionFactory,
77+
TopicConnectionFactory, ExceptionListener, InitializingBean, DisposableBean {
7978

8079
protected final Log logger = LogFactory.getLog(getClass());
8180

@@ -171,7 +170,7 @@ protected String getClientId() {
171170

172171
/**
173172
* Specify an JMS ExceptionListener implementation that should be
174-
* registered with with the single Connection created by this factory.
173+
* registered with the single Connection created by this factory.
175174
* @see #setReconnectOnException
176175
*/
177176
public void setExceptionListener(ExceptionListener exceptionListener) {
@@ -180,7 +179,7 @@ public void setExceptionListener(ExceptionListener exceptionListener) {
180179

181180
/**
182181
* Return the JMS ExceptionListener implementation that should be registered
183-
* with with the single Connection created by this factory, if any.
182+
* with the single Connection created by this factory, if any.
184183
*/
185184
protected ExceptionListener getExceptionListener() {
186185
return this.exceptionListener;
@@ -307,13 +306,15 @@ public void onException(JMSException ex) {
307306
* The provider of this ConnectionFactory needs to care for proper shutdown.
308307
* <p>As this bean implements DisposableBean, a bean factory will
309308
* automatically invoke this on destruction of its cached singletons.
309+
* @see #resetConnection()
310310
*/
311311
public void destroy() {
312312
resetConnection();
313313
}
314314

315315
/**
316316
* Reset the underlying shared Connection, to be reinitialized on next access.
317+
* @see #closeConnection
317318
*/
318319
public void resetConnection() {
319320
synchronized (this.connectionMonitor) {

spring-web/src/main/java/org/springframework/web/util/Log4jWebConfigurer.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,7 @@ public static void initLogging(ServletContext servletContext) {
127127

128128
// Leave a URL (e.g. "classpath:" or "file:") as-is.
129129
if (!ResourceUtils.isUrl(location)) {
130-
// Consider a plain file path as relative to the web
131-
// application root directory.
130+
// Consider a plain file path as relative to the web application root directory.
132131
location = WebUtils.getRealPath(servletContext, location);
133132
}
134133

spring-webmvc-tiles3/src/main/java/org/springframework/web/servlet/view/tiles3/SpringWildcardServletTilesApplicationContext.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
import org.springframework.core.io.Resource;
3232
import org.springframework.core.io.support.ResourcePatternResolver;
33+
import org.springframework.util.CollectionUtils;
3334
import org.springframework.util.ObjectUtils;
3435
import org.springframework.web.context.support.ServletContextResourcePatternResolver;
3536

@@ -53,22 +54,20 @@ public SpringWildcardServletTilesApplicationContext(ServletContext servletContex
5354

5455
@Override
5556
public ApplicationResource getResource(String localePath) {
56-
ApplicationResource retValue = null;
5757
Collection<ApplicationResource> urlSet = getResources(localePath);
58-
if (urlSet != null && !urlSet.isEmpty()) {
59-
retValue = urlSet.iterator().next();
58+
if (!CollectionUtils.isEmpty(urlSet)) {
59+
return urlSet.iterator().next();
6060
}
61-
return retValue;
61+
return null;
6262
}
6363

6464
@Override
6565
public ApplicationResource getResource(ApplicationResource base, Locale locale) {
66-
ApplicationResource retValue = null;
6766
Collection<ApplicationResource> urlSet = getResources(base.getLocalePath(locale));
68-
if (urlSet != null && !urlSet.isEmpty()) {
69-
retValue = urlSet.iterator().next();
67+
if (!CollectionUtils.isEmpty(urlSet)) {
68+
return urlSet.iterator().next();
7069
}
71-
return retValue;
70+
return null;
7271
}
7372

7473
@Override

spring-webmvc/src/main/java/org/springframework/web/servlet/view/tiles2/SpringTilesApplicationContextFactory.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public class SpringTilesApplicationContextFactory extends AbstractTilesApplicati
4949

5050
private Map<String, String> params;
5151

52+
5253
public void init(Map<String, String> params) {
5354
this.params = params;
5455
}
@@ -89,12 +90,11 @@ public Map<String, String> getInitParams() {
8990

9091
@Override
9192
public URL getResource(String path) throws IOException {
92-
URL retValue = null;
9393
Set<URL> urlSet = getResources(path);
9494
if (!CollectionUtils.isEmpty(urlSet)) {
95-
retValue = urlSet.iterator().next();
95+
return urlSet.iterator().next();
9696
}
97-
return retValue;
97+
return null;
9898
}
9999

100100
@Override

0 commit comments

Comments
 (0)