Skip to content

Commit 22ca7ac

Browse files
committed
Polishing
(cherry picked from commit c926ec4)
1 parent 264f533 commit 22ca7ac

File tree

9 files changed

+37
-36
lines changed

9 files changed

+37
-36
lines changed

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -616,10 +616,12 @@ public <A extends Annotation> A findAnnotationOnBean(String beanName, Class<A> a
616616

617617
@Override
618618
public void registerResolvableDependency(Class<?> dependencyType, Object autowiredValue) {
619-
Assert.notNull(dependencyType, "Type must not be null");
619+
Assert.notNull(dependencyType, "Dependency type must not be null");
620620
if (autowiredValue != null) {
621-
Assert.isTrue((autowiredValue instanceof ObjectFactory || dependencyType.isInstance(autowiredValue)),
622-
"Value [" + autowiredValue + "] does not implement specified type [" + dependencyType.getName() + "]");
621+
if (!(autowiredValue instanceof ObjectFactory || dependencyType.isInstance(autowiredValue))) {
622+
throw new IllegalArgumentException("Value [" + autowiredValue +
623+
"] does not implement specified dependency type [" + dependencyType.getName() + "]");
624+
}
623625
this.resolvableDependencies.put(dependencyType, autowiredValue);
624626
}
625627
}
@@ -1545,7 +1547,7 @@ public Object getOrderSource(Object obj) {
15451547
sources.add(factoryMethod);
15461548
}
15471549
Class<?> targetType = beanDefinition.getTargetType();
1548-
if (targetType != null && !targetType.equals(obj.getClass())) {
1550+
if (targetType != null && targetType != obj.getClass()) {
15491551
sources.add(targetType);
15501552
}
15511553
return sources.toArray(new Object[sources.size()]);

spring-context/src/main/java/org/springframework/scheduling/support/CronSequenceGenerator.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
* <li>"0 0 * * * *" = the top of every hour of every day.</li>
4343
* <li>"*&#47;10 * * * * *" = every ten seconds.</li>
4444
* <li>"0 0 8-10 * * *" = 8, 9 and 10 o'clock of every day.</li>
45+
* <li>"0 * 6,19 * * *" = 6:00 AM and 7:00 PM every day.</li>
4546
* <li>"0 0/30 8-10 * * *" = 8:00, 8:30, 9:00, 9:30 and 10 o'clock every day.</li>
4647
* <li>"0 0 9-17 * * MON-FRI" = on the hour nine-to-five weekdays</li>
4748
* <li>"0 0 0 25 12 ?" = every Christmas Day at midnight</li>
@@ -115,7 +116,7 @@ public Date next(Date date) {
115116
/*
116117
The plan:
117118
118-
1 Round up to the next whole second
119+
1 Start with whole second (rounding up if necessary)
119120
120121
2 If seconds match move on, otherwise find the next match:
121122
2.1 If next match is in the next minute then roll forwards
@@ -127,8 +128,6 @@ public Date next(Date date) {
127128
4 If hour matches move on, otherwise find the next match
128129
4.1 If next match is in the next day then roll forwards,
129130
4.2 Reset the minutes and seconds and go to 2
130-
131-
...
132131
*/
133132

134133
Calendar calendar = new GregorianCalendar();
@@ -409,7 +408,7 @@ public int hashCode() {
409408

410409
@Override
411410
public String toString() {
412-
return (getClass().getSimpleName() + ": " + this.expression);
411+
return getClass().getSimpleName() + ": " + this.expression;
413412
}
414413

415414
}

spring-context/src/main/java/org/springframework/scripting/config/ScriptBeanDefinitionParser.java

Lines changed: 10 additions & 11 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.
@@ -35,17 +35,17 @@
3535

3636
/**
3737
* BeanDefinitionParser implementation for the '{@code <lang:groovy/>}',
38-
* '{@code <lang:jruby/>}' and '{@code <lang:bsh/>}' tags.
38+
* '{@code <lang:std/>}' and '{@code <lang:bsh/>}' tags.
3939
* Allows for objects written using dynamic languages to be easily exposed with
4040
* the {@link org.springframework.beans.factory.BeanFactory}.
4141
*
42-
* <p>The script for each object can be specified either as a reference to the Resource
43-
* containing it (using the '{@code script-source}' attribute) or inline in the XML configuration
44-
* itself (using the '{@code inline-script}' attribute.
42+
* <p>The script for each object can be specified either as a reference to the
43+
* resource containing it (using the '{@code script-source}' attribute) or inline
44+
* in the XML configuration itself (using the '{@code inline-script}' attribute.
4545
*
46-
* <p>By default, dynamic objects created with these tags are <strong>not</strong> refreshable.
47-
* To enable refreshing, specify the refresh check delay for each object (in milliseconds) using the
48-
* '{@code refresh-check-delay}' attribute.
46+
* <p>By default, dynamic objects created with these tags are <strong>not</strong>
47+
* refreshable. To enable refreshing, specify the refresh check delay for each
48+
* object (in milliseconds) using the '{@code refresh-check-delay}' attribute.
4949
*
5050
* @author Rob Harrop
5151
* @author Rod Johnson
@@ -176,14 +176,13 @@ else if (beanDefinitionDefaults.getDestroyMethodName() != null) {
176176
// Attach any refresh metadata.
177177
String refreshCheckDelay = element.getAttribute(REFRESH_CHECK_DELAY_ATTRIBUTE);
178178
if (StringUtils.hasText(refreshCheckDelay)) {
179-
bd.setAttribute(ScriptFactoryPostProcessor.REFRESH_CHECK_DELAY_ATTRIBUTE, new Long(refreshCheckDelay));
179+
bd.setAttribute(ScriptFactoryPostProcessor.REFRESH_CHECK_DELAY_ATTRIBUTE, Long.valueOf(refreshCheckDelay));
180180
}
181181

182182
// Attach any proxy target class metadata.
183183
String proxyTargetClass = element.getAttribute(PROXY_TARGET_CLASS_ATTRIBUTE);
184184
if (StringUtils.hasText(proxyTargetClass)) {
185-
Boolean flag = new Boolean(proxyTargetClass);
186-
bd.setAttribute(ScriptFactoryPostProcessor.PROXY_TARGET_CLASS_ATTRIBUTE, flag);
185+
bd.setAttribute(ScriptFactoryPostProcessor.PROXY_TARGET_CLASS_ATTRIBUTE, Boolean.valueOf(proxyTargetClass));
187186
}
188187

189188
// Add constructor arguments.

spring-context/src/main/java/org/springframework/scripting/config/ScriptingDefaultsParser.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.
@@ -41,7 +41,7 @@ public BeanDefinition parse(Element element, ParserContext parserContext) {
4141
LangNamespaceUtils.registerScriptFactoryPostProcessorIfNecessary(parserContext.getRegistry());
4242
String refreshCheckDelay = element.getAttribute(REFRESH_CHECK_DELAY_ATTRIBUTE);
4343
if (StringUtils.hasText(refreshCheckDelay)) {
44-
bd.getPropertyValues().add("defaultRefreshCheckDelay", new Long(refreshCheckDelay));
44+
bd.getPropertyValues().add("defaultRefreshCheckDelay", Long.valueOf(refreshCheckDelay));
4545
}
4646
String proxyTargetClass = element.getAttribute(PROXY_TARGET_CLASS_ATTRIBUTE);
4747
if (StringUtils.hasText(proxyTargetClass)) {

spring-jdbc/src/main/java/org/springframework/jdbc/datasource/ConnectionHolder.java

Lines changed: 3 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-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.
@@ -161,9 +161,9 @@ public Connection getConnection() {
161161
*/
162162
public boolean supportsSavepoints() throws SQLException {
163163
if (this.savepointsSupported == null) {
164-
this.savepointsSupported = new Boolean(getConnection().getMetaData().supportsSavepoints());
164+
this.savepointsSupported = getConnection().getMetaData().supportsSavepoints();
165165
}
166-
return this.savepointsSupported.booleanValue();
166+
return this.savepointsSupported;
167167
}
168168

169169
/**

spring-jms/src/main/java/org/springframework/jms/config/JcaListenerContainerParser.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-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.
@@ -88,7 +88,7 @@ protected MutablePropertyValues parseCommonContainerProperties(Element container
8888

8989
String prefetch = containerEle.getAttribute(PREFETCH_ATTRIBUTE);
9090
if (StringUtils.hasText(prefetch)) {
91-
properties.add("prefetchSize", new Integer(prefetch));
91+
properties.add("prefetchSize", Integer.valueOf(prefetch));
9292
}
9393

9494
return properties;

spring-web/src/main/java/org/springframework/http/HttpHeaders.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -442,10 +442,10 @@ public void setAccessControlAllowCredentials(boolean allowCredentials) {
442442
}
443443

444444
/**
445-
* Returns the value of the {@code Access-Control-Allow-Credentials} response header.
445+
* Return the value of the {@code Access-Control-Allow-Credentials} response header.
446446
*/
447447
public boolean getAccessControlAllowCredentials() {
448-
return new Boolean(getFirst(ACCESS_CONTROL_ALLOW_CREDENTIALS));
448+
return Boolean.parseBoolean(getFirst(ACCESS_CONTROL_ALLOW_CREDENTIALS));
449449
}
450450

451451
/**
@@ -456,7 +456,7 @@ public void setAccessControlAllowHeaders(List<String> allowedHeaders) {
456456
}
457457

458458
/**
459-
* Returns the value of the {@code Access-Control-Allow-Headers} response header.
459+
* Return the value of the {@code Access-Control-Allow-Headers} response header.
460460
*/
461461
public List<String> getAccessControlAllowHeaders() {
462462
return getFirstValueAsList(ACCESS_CONTROL_ALLOW_HEADERS);
@@ -509,7 +509,7 @@ public void setAccessControlExposeHeaders(List<String> exposedHeaders) {
509509
}
510510

511511
/**
512-
* Returns the value of the {@code Access-Control-Expose-Headers} response header.
512+
* Return the value of the {@code Access-Control-Expose-Headers} response header.
513513
*/
514514
public List<String> getAccessControlExposeHeaders() {
515515
return getFirstValueAsList(ACCESS_CONTROL_EXPOSE_HEADERS);
@@ -523,7 +523,7 @@ public void setAccessControlMaxAge(long maxAge) {
523523
}
524524

525525
/**
526-
* Returns the value of the {@code Access-Control-Max-Age} response header.
526+
* Return the value of the {@code Access-Control-Max-Age} response header.
527527
* <p>Returns -1 when the max age is unknown.
528528
*/
529529
public long getAccessControlMaxAge() {
@@ -539,7 +539,7 @@ public void setAccessControlRequestHeaders(List<String> requestHeaders) {
539539
}
540540

541541
/**
542-
* Returns the value of the {@code Access-Control-Request-Headers} request header.
542+
* Return the value of the {@code Access-Control-Request-Headers} request header.
543543
*/
544544
public List<String> getAccessControlRequestHeaders() {
545545
return getFirstValueAsList(ACCESS_CONTROL_REQUEST_HEADERS);

spring-webmvc/src/main/java/org/springframework/web/servlet/handler/SimpleMappingExceptionResolver.java

Lines changed: 3 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.
@@ -46,6 +46,7 @@ public class SimpleMappingExceptionResolver extends AbstractHandlerExceptionReso
4646
/** The default name of the exception attribute: "exception". */
4747
public static final String DEFAULT_EXCEPTION_ATTRIBUTE = "exception";
4848

49+
4950
private Properties exceptionMappings;
5051

5152
private Class<?>[] excludedExceptions;
@@ -108,7 +109,7 @@ public void setDefaultErrorView(String defaultErrorView) {
108109
public void setStatusCodes(Properties statusCodes) {
109110
for (Enumeration<?> enumeration = statusCodes.propertyNames(); enumeration.hasMoreElements();) {
110111
String viewName = (String) enumeration.nextElement();
111-
Integer statusCode = new Integer(statusCodes.getProperty(viewName));
112+
Integer statusCode = Integer.valueOf(statusCodes.getProperty(viewName));
112113
this.statusCodes.put(viewName, statusCode);
113114
}
114115
}

spring-webmvc/src/main/java/org/springframework/web/servlet/view/jasperreports/AbstractJasperReportsView.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-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.
@@ -390,7 +390,7 @@ else if ("false".equals(str)) {
390390
else if (str.length() > 0 && Character.isDigit(str.charAt(0))) {
391391
// Looks like a number... let's try.
392392
try {
393-
return new Integer(str);
393+
return Integer.valueOf(str);
394394
}
395395
catch (NumberFormatException ex) {
396396
// OK, then let's keep it as a String value.

0 commit comments

Comments
 (0)