diff --git a/spring-aop/src/main/java/org/springframework/aop/support/Pointcuts.java b/spring-aop/src/main/java/org/springframework/aop/support/Pointcuts.java
index b17977ba48..8a4f15b075 100644
--- a/spring-aop/src/main/java/org/springframework/aop/support/Pointcuts.java
+++ b/spring-aop/src/main/java/org/springframework/aop/support/Pointcuts.java
@@ -94,7 +94,7 @@ public abstract class Pointcuts {
@SuppressWarnings("serial")
private static class SetterPointcut extends StaticMethodMatcherPointcut implements Serializable {
- public static SetterPointcut INSTANCE = new SetterPointcut();
+ public static final SetterPointcut INSTANCE = new SetterPointcut();
@Override
public boolean matches(Method method, Class> targetClass) {
@@ -115,7 +115,7 @@ public abstract class Pointcuts {
@SuppressWarnings("serial")
private static class GetterPointcut extends StaticMethodMatcherPointcut implements Serializable {
- public static GetterPointcut INSTANCE = new GetterPointcut();
+ public static final GetterPointcut INSTANCE = new GetterPointcut();
@Override
public boolean matches(Method method, Class> targetClass) {
diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/AutowireCandidateQualifier.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/AutowireCandidateQualifier.java
index f5991ac930..9674e5ccb6 100644
--- a/spring-beans/src/main/java/org/springframework/beans/factory/support/AutowireCandidateQualifier.java
+++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/AutowireCandidateQualifier.java
@@ -32,7 +32,7 @@ import org.springframework.util.Assert;
@SuppressWarnings("serial")
public class AutowireCandidateQualifier extends BeanMetadataAttributeAccessor {
- public static String VALUE_KEY = "value";
+ public static final String VALUE_KEY = "value";
private final String typeName;
diff --git a/spring-context/src/main/java/org/springframework/context/support/DefaultLifecycleProcessor.java b/spring-context/src/main/java/org/springframework/context/support/DefaultLifecycleProcessor.java
index 81268227d7..0b7761a850 100644
--- a/spring-context/src/main/java/org/springframework/context/support/DefaultLifecycleProcessor.java
+++ b/spring-context/src/main/java/org/springframework/context/support/DefaultLifecycleProcessor.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2017 the original author or authors.
+ * Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -61,7 +61,7 @@ public class DefaultLifecycleProcessor implements LifecycleProcessor, BeanFactor
/**
* Specify the maximum time allotted in milliseconds for the shutdown of
* any phase (group of SmartLifecycle beans with the same 'phase' value).
- * The default value is 30 seconds.
+ *
The default value is 30 seconds.
*/
public void setTimeoutPerShutdownPhase(long timeoutPerShutdownPhase) {
this.timeoutPerShutdownPhase = timeoutPerShutdownPhase;
@@ -80,13 +80,12 @@ public class DefaultLifecycleProcessor implements LifecycleProcessor, BeanFactor
// Lifecycle implementation
/**
- * Start all registered beans that implement Lifecycle and are
- * not already running. Any bean that implements SmartLifecycle
- * will be started within its 'phase', and all phases will be ordered
- * from lowest to highest value. All beans that do not implement
- * SmartLifecycle will be started in the default phase 0. A bean
- * declared as a dependency of another bean will be started before
- * the dependent bean regardless of the declared phase.
+ * Start all registered beans that implement {@link Lifecycle} and are not
+ * already running. Any bean that implements {@link SmartLifecycle} will be
+ * started within its 'phase', and all phases will be ordered from lowest to
+ * highest value. All beans that do not implement {@link SmartLifecycle} will be
+ * started in the default phase 0. A bean declared as a dependency of another bean
+ * will be started before the dependent bean regardless of the declared phase.
*/
@Override
public void start() {
@@ -95,13 +94,12 @@ public class DefaultLifecycleProcessor implements LifecycleProcessor, BeanFactor
}
/**
- * Stop all registered beans that implement Lifecycle and are
- * currently running. Any bean that implements SmartLifecycle
- * will be stopped within its 'phase', and all phases will be ordered
- * from highest to lowest value. All beans that do not implement
- * SmartLifecycle will be stopped in the default phase 0. A bean
- * declared as dependent on another bean will be stopped before
- * the dependency bean regardless of the declared phase.
+ * Stop all registered beans that implement {@link Lifecycle} and are
+ * currently running. Any bean that implements {@link SmartLifecycle} will be
+ * stopped within its 'phase', and all phases will be ordered from highest to
+ * lowest value. All beans that do not implement {@link SmartLifecycle} will be
+ * stopped in the default phase 0. A bean declared as dependent on another bean
+ * will be stopped before the dependency bean regardless of the declared phase.
*/
@Override
public void stop() {
@@ -127,7 +125,7 @@ public class DefaultLifecycleProcessor implements LifecycleProcessor, BeanFactor
}
- // internal helpers
+ // Internal helpers
private void startBeans(boolean autoStartupOnly) {
Map lifecycleBeans = getLifecycleBeans();
diff --git a/spring-context/src/main/java/org/springframework/format/datetime/DateFormatter.java b/spring-context/src/main/java/org/springframework/format/datetime/DateFormatter.java
index c812c6cff7..1ec4eafa35 100644
--- a/spring-context/src/main/java/org/springframework/format/datetime/DateFormatter.java
+++ b/spring-context/src/main/java/org/springframework/format/datetime/DateFormatter.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2016 the original author or authors.
+ * Copyright 2002-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,7 +21,7 @@ import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Collections;
import java.util.Date;
-import java.util.HashMap;
+import java.util.EnumMap;
import java.util.Locale;
import java.util.Map;
import java.util.TimeZone;
@@ -47,7 +47,7 @@ public class DateFormatter implements Formatter {
private static final Map ISO_PATTERNS;
static {
- Map formats = new HashMap(4);
+ Map formats = new EnumMap(ISO.class);
formats.put(ISO.DATE, "yyyy-MM-dd");
formats.put(ISO.TIME, "HH:mm:ss.SSSZ");
formats.put(ISO.DATE_TIME, "yyyy-MM-dd'T'HH:mm:ss.SSSZ");
diff --git a/spring-context/src/main/java/org/springframework/format/datetime/joda/JodaTimeFormatterRegistrar.java b/spring-context/src/main/java/org/springframework/format/datetime/joda/JodaTimeFormatterRegistrar.java
index 9c57310f73..81da7515ab 100644
--- a/spring-context/src/main/java/org/springframework/format/datetime/joda/JodaTimeFormatterRegistrar.java
+++ b/spring-context/src/main/java/org/springframework/format/datetime/joda/JodaTimeFormatterRegistrar.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2015 the original author or authors.
+ * Copyright 2002-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,7 +18,7 @@ package org.springframework.format.datetime.joda;
import java.util.Calendar;
import java.util.Date;
-import java.util.HashMap;
+import java.util.EnumMap;
import java.util.Map;
import org.joda.time.DateTime;
@@ -73,7 +73,7 @@ public class JodaTimeFormatterRegistrar implements FormatterRegistrar {
/**
* User defined formatters.
*/
- private final Map formatters = new HashMap();
+ private final Map formatters = new EnumMap(Type.class);
/**
* Factories used when specific formatters have not been specified.
@@ -82,7 +82,7 @@ public class JodaTimeFormatterRegistrar implements FormatterRegistrar {
public JodaTimeFormatterRegistrar() {
- this.factories = new HashMap();
+ this.factories = new EnumMap(Type.class);
for (Type type : Type.values()) {
this.factories.put(type, new DateTimeFormatterFactory());
}
diff --git a/spring-context/src/main/java/org/springframework/jmx/support/JmxUtils.java b/spring-context/src/main/java/org/springframework/jmx/support/JmxUtils.java
index 2a29683aad..5d42764ca1 100644
--- a/spring-context/src/main/java/org/springframework/jmx/support/JmxUtils.java
+++ b/spring-context/src/main/java/org/springframework/jmx/support/JmxUtils.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2014 the original author or authors.
+ * Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -34,6 +34,7 @@ import org.apache.commons.logging.LogFactory;
import org.springframework.jmx.MBeanServerNotFoundException;
import org.springframework.util.ClassUtils;
+import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
@@ -68,8 +69,7 @@ public abstract class JmxUtils {
* {@code MBeanServer} can be found. Logs a warning if more than one
* {@code MBeanServer} found, returning the first one from the list.
* @return the {@code MBeanServer} if found
- * @throws org.springframework.jmx.MBeanServerNotFoundException
- * if no {@code MBeanServer} could be found
+ * @throws MBeanServerNotFoundException if no {@code MBeanServer} could be found
* @see javax.management.MBeanServerFactory#findMBeanServer
*/
public static MBeanServer locateMBeanServer() throws MBeanServerNotFoundException {
@@ -84,8 +84,7 @@ public abstract class JmxUtils {
* If this parameter is {@code null}, all registered MBeanServers are considered.
* If the empty String is given, the platform MBeanServer will be returned.
* @return the {@code MBeanServer} if found
- * @throws org.springframework.jmx.MBeanServerNotFoundException
- * if no {@code MBeanServer} could be found
+ * @throws MBeanServerNotFoundException if no {@code MBeanServer} could be found
* @see javax.management.MBeanServerFactory#findMBeanServer(String)
*/
public static MBeanServer locateMBeanServer(String agentId) throws MBeanServerNotFoundException {
@@ -94,7 +93,7 @@ public abstract class JmxUtils {
// null means any registered server, but "" specifically means the platform server
if (!"".equals(agentId)) {
List servers = MBeanServerFactory.findMBeanServer(agentId);
- if (servers != null && servers.size() > 0) {
+ if (!CollectionUtils.isEmpty(servers)) {
// Check to see if an MBeanServer is registered.
if (servers.size() > 1 && logger.isWarnEnabled()) {
logger.warn("Found more than one MBeanServer instance" +
diff --git a/spring-context/src/main/java/org/springframework/validation/BindingResult.java b/spring-context/src/main/java/org/springframework/validation/BindingResult.java
index 32c93215cb..8e2bf3c78c 100644
--- a/spring-context/src/main/java/org/springframework/validation/BindingResult.java
+++ b/spring-context/src/main/java/org/springframework/validation/BindingResult.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2012 the original author or authors.
+ * Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -80,8 +80,7 @@ public interface BindingResult extends Errors {
* Extract the raw field value for the given field.
* Typically used for comparison purposes.
* @param field the field to check
- * @return the current value of the field in its raw form,
- * or {@code null} if not known
+ * @return the current value of the field in its raw form, or {@code null} if not known
*/
Object getRawFieldValue(String field);
diff --git a/spring-context/src/main/java/org/springframework/validation/DataBinder.java b/spring-context/src/main/java/org/springframework/validation/DataBinder.java
index a67819969e..2ecf9791ae 100644
--- a/spring-context/src/main/java/org/springframework/validation/DataBinder.java
+++ b/spring-context/src/main/java/org/springframework/validation/DataBinder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2016 the original author or authors.
+ * Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -562,9 +562,10 @@ public class DataBinder implements PropertyEditorRegistry, TypeConverter {
private void assertValidators(Validator... validators) {
Assert.notNull(validators, "Validators required");
+ Object target = getTarget();
for (Validator validator : validators) {
- if (validator != null && (getTarget() != null && !validator.supports(getTarget().getClass()))) {
- throw new IllegalStateException("Invalid target for Validator [" + validator + "]: " + getTarget());
+ if (validator != null && (target != null && !validator.supports(target.getClass()))) {
+ throw new IllegalStateException("Invalid target for Validator [" + validator + "]: " + target);
}
}
}
diff --git a/spring-context/src/main/java/org/springframework/validation/DefaultBindingErrorProcessor.java b/spring-context/src/main/java/org/springframework/validation/DefaultBindingErrorProcessor.java
index e1ae7d4b5d..529a8a8d69 100644
--- a/spring-context/src/main/java/org/springframework/validation/DefaultBindingErrorProcessor.java
+++ b/spring-context/src/main/java/org/springframework/validation/DefaultBindingErrorProcessor.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2012 the original author or authors.
+ * Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -58,9 +58,9 @@ public class DefaultBindingErrorProcessor implements BindingErrorProcessor {
String fixedField = bindingResult.getNestedPath() + missingField;
String[] codes = bindingResult.resolveMessageCodes(MISSING_FIELD_ERROR_CODE, missingField);
Object[] arguments = getArgumentsForBindError(bindingResult.getObjectName(), fixedField);
- bindingResult.addError(new FieldError(
- bindingResult.getObjectName(), fixedField, "", true,
- codes, arguments, "Field '" + fixedField + "' is required"));
+ FieldError error = new FieldError(bindingResult.getObjectName(), fixedField, "", true,
+ codes, arguments, "Field '" + fixedField + "' is required");
+ bindingResult.addError(error);
}
@Override
@@ -70,12 +70,12 @@ public class DefaultBindingErrorProcessor implements BindingErrorProcessor {
String[] codes = bindingResult.resolveMessageCodes(ex.getErrorCode(), field);
Object[] arguments = getArgumentsForBindError(bindingResult.getObjectName(), field);
Object rejectedValue = ex.getValue();
- if (rejectedValue != null && rejectedValue.getClass().isArray()) {
+ if (ObjectUtils.isArray(rejectedValue)) {
rejectedValue = StringUtils.arrayToCommaDelimitedString(ObjectUtils.toObjectArray(rejectedValue));
}
- bindingResult.addError(new FieldError(
- bindingResult.getObjectName(), field, rejectedValue, true,
- codes, arguments, ex.getLocalizedMessage()));
+ FieldError error = new FieldError(bindingResult.getObjectName(), field, rejectedValue, true,
+ codes, arguments, ex.getLocalizedMessage());
+ bindingResult.addError(error);
}
/**
diff --git a/spring-context/src/main/java/org/springframework/validation/FieldError.java b/spring-context/src/main/java/org/springframework/validation/FieldError.java
index f15c7994df..4f5d3d3940 100644
--- a/spring-context/src/main/java/org/springframework/validation/FieldError.java
+++ b/spring-context/src/main/java/org/springframework/validation/FieldError.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2017 the original author or authors.
+ * Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -96,12 +96,6 @@ public class FieldError extends ObjectError {
}
- @Override
- public String toString() {
- return "Field error in object '" + getObjectName() + "' on field '" + this.field +
- "': rejected value [" + this.rejectedValue + "]; " + resolvableToString();
- }
-
@Override
public boolean equals(Object other) {
if (this == other) {
@@ -125,4 +119,11 @@ public class FieldError extends ObjectError {
return hashCode;
}
+ @Override
+ public String toString() {
+ return "Field error in object '" + getObjectName() + "' on field '" + this.field +
+ "': rejected value [" + ObjectUtils.nullSafeToString(this.rejectedValue) + "]; " +
+ resolvableToString();
+ }
+
}
diff --git a/spring-context/src/main/java/org/springframework/validation/MessageCodeFormatter.java b/spring-context/src/main/java/org/springframework/validation/MessageCodeFormatter.java
index dd7c313291..8444f71c06 100644
--- a/spring-context/src/main/java/org/springframework/validation/MessageCodeFormatter.java
+++ b/spring-context/src/main/java/org/springframework/validation/MessageCodeFormatter.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2012 the original author or authors.
+ * Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,8 +27,8 @@ package org.springframework.validation;
public interface MessageCodeFormatter {
/**
- * Build and return a message code consisting of the given fields, usually delimited
- * by {@link DefaultMessageCodesResolver#CODE_SEPARATOR}.
+ * Build and return a message code consisting of the given fields,
+ * usually delimited by {@link DefaultMessageCodesResolver#CODE_SEPARATOR}.
* @param errorCode e.g.: "typeMismatch"
* @param objectName e.g.: "user"
* @param field e.g. "age"
@@ -36,4 +36,5 @@ public interface MessageCodeFormatter {
* @see DefaultMessageCodesResolver.Format
*/
String format(String errorCode, String objectName, String field);
-}
\ No newline at end of file
+
+}
diff --git a/spring-context/src/main/java/org/springframework/validation/ObjectError.java b/spring-context/src/main/java/org/springframework/validation/ObjectError.java
index e03fde6ad8..fb952d199d 100644
--- a/spring-context/src/main/java/org/springframework/validation/ObjectError.java
+++ b/spring-context/src/main/java/org/springframework/validation/ObjectError.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2017 the original author or authors.
+ * Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -68,11 +68,6 @@ public class ObjectError extends DefaultMessageSourceResolvable {
}
- @Override
- public String toString() {
- return "Error in object '" + this.objectName + "': " + resolvableToString();
- }
-
@Override
public boolean equals(Object other) {
if (this == other) {
@@ -90,4 +85,9 @@ public class ObjectError extends DefaultMessageSourceResolvable {
return super.hashCode() * 29 + getObjectName().hashCode();
}
+ @Override
+ public String toString() {
+ return "Error in object '" + this.objectName + "': " + resolvableToString();
+ }
+
}
diff --git a/spring-context/src/test/java/org/springframework/format/datetime/DateFormatterTests.java b/spring-context/src/test/java/org/springframework/format/datetime/DateFormatterTests.java
index 3bc6bc6eee..cac50694fd 100644
--- a/spring-context/src/test/java/org/springframework/format/datetime/DateFormatterTests.java
+++ b/spring-context/src/test/java/org/springframework/format/datetime/DateFormatterTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2015 the original author or authors.
+ * Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -46,7 +46,7 @@ public class DateFormatterTests {
private static final TimeZone UTC = TimeZone.getTimeZone("UTC");
@Rule
- public ExpectedException thown = ExpectedException.none();
+ public ExpectedException thrown = ExpectedException.none();
@Test
@@ -183,8 +183,8 @@ public class DateFormatterTests {
public void shouldThrowOnUnsupportedStylePattern() throws Exception {
DateFormatter formatter = new DateFormatter();
formatter.setStylePattern("OO");
- thown.expect(IllegalStateException.class);
- thown.expectMessage("Unsupported style pattern 'OO'");
+ thrown.expect(IllegalStateException.class);
+ thrown.expectMessage("Unsupported style pattern 'OO'");
formatter.parse("2009", Locale.US);
}
diff --git a/spring-context/src/test/java/org/springframework/format/datetime/DateFormattingTests.java b/spring-context/src/test/java/org/springframework/format/datetime/DateFormattingTests.java
index 0681d4ece1..9e626d039b 100644
--- a/spring-context/src/test/java/org/springframework/format/datetime/DateFormattingTests.java
+++ b/spring-context/src/test/java/org/springframework/format/datetime/DateFormattingTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2016 the original author or authors.
+ * Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -52,12 +52,12 @@ public class DateFormattingTests {
@Before
- public void setUp() {
+ public void setup() {
DateFormatterRegistrar registrar = new DateFormatterRegistrar();
- setUp(registrar);
+ setup(registrar);
}
- private void setUp(DateFormatterRegistrar registrar) {
+ private void setup(DateFormatterRegistrar registrar) {
DefaultConversionService.addDefaultConverters(conversionService);
registrar.registerFormatters(conversionService);
@@ -193,7 +193,7 @@ public class DateFormattingTests {
}
@Test
- public void dateToStringWithoutGlobalFormat() throws Exception {
+ public void dateToStringWithoutGlobalFormat() {
Date date = new Date();
Object actual = this.conversionService.convert(date, TypeDescriptor.valueOf(Date.class), TypeDescriptor.valueOf(String.class));
String expected = date.toString();
@@ -201,33 +201,31 @@ public class DateFormattingTests {
}
@Test
- public void dateToStringWithGlobalFormat() throws Exception {
+ public void dateToStringWithGlobalFormat() {
DateFormatterRegistrar registrar = new DateFormatterRegistrar();
registrar.setFormatter(new DateFormatter());
- setUp(registrar);
+ setup(registrar);
Date date = new Date();
Object actual = this.conversionService.convert(date, TypeDescriptor.valueOf(Date.class), TypeDescriptor.valueOf(String.class));
String expected = new DateFormatter().print(date, Locale.US);
assertEquals(expected, actual);
}
- @Test
+ @Test // SPR-10105
@SuppressWarnings("deprecation")
- public void stringToDateWithoutGlobalFormat() throws Exception {
- // SPR-10105
+ public void stringToDateWithoutGlobalFormat() {
String string = "Sat, 12 Aug 1995 13:30:00 GM";
Date date = this.conversionService.convert(string, Date.class);
assertThat(date, equalTo(new Date(string)));
}
- @Test
- public void stringToDateWithGlobalFormat() throws Exception {
- // SPR-10105
+ @Test // SPR-10105
+ public void stringToDateWithGlobalFormat() {
DateFormatterRegistrar registrar = new DateFormatterRegistrar();
DateFormatter dateFormatter = new DateFormatter();
dateFormatter.setIso(ISO.DATE_TIME);
registrar.setFormatter(dateFormatter);
- setUp(registrar);
+ setup(registrar);
// This is a format that cannot be parsed by new Date(String)
String string = "2009-06-01T14:23:05.003+0000";
Date date = this.conversionService.convert(string, Date.class);
@@ -260,7 +258,7 @@ public class DateFormattingTests {
@DateTimeFormat(iso=ISO.DATE_TIME)
private Date isoDateTime;
- private final List children = new ArrayList();
+ private final List children = new ArrayList<>();
public Long getMillis() {
return millis;
diff --git a/spring-context/src/test/java/org/springframework/format/datetime/joda/DateTimeFormatterFactoryBeanTests.java b/spring-context/src/test/java/org/springframework/format/datetime/joda/DateTimeFormatterFactoryBeanTests.java
index 6539bc4599..7a3e884db4 100644
--- a/spring-context/src/test/java/org/springframework/format/datetime/joda/DateTimeFormatterFactoryBeanTests.java
+++ b/spring-context/src/test/java/org/springframework/format/datetime/joda/DateTimeFormatterFactoryBeanTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2012 the original author or authors.
+ * Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,27 +29,28 @@ import static org.junit.Assert.*;
*/
public class DateTimeFormatterFactoryBeanTests {
- private DateTimeFormatterFactoryBean factory = new DateTimeFormatterFactoryBean();
+ private final DateTimeFormatterFactoryBean factory = new DateTimeFormatterFactoryBean();
+
@Test
- public void isSingleton() throws Exception {
+ public void isSingleton() {
assertThat(factory.isSingleton(), is(true));
}
@Test
@SuppressWarnings("rawtypes")
- public void getObjectType() throws Exception {
+ public void getObjectType() {
assertThat(factory.getObjectType(), is(equalTo((Class) DateTimeFormatter.class)));
}
@Test
- public void getObject() throws Exception {
+ public void getObject() {
factory.afterPropertiesSet();
assertThat(factory.getObject(), is(equalTo(DateTimeFormat.mediumDateTime())));
}
@Test
- public void getObjectIsAlwaysSingleton() throws Exception {
+ public void getObjectIsAlwaysSingleton() {
factory.afterPropertiesSet();
DateTimeFormatter formatter = factory.getObject();
assertThat(formatter, is(equalTo(DateTimeFormat.mediumDateTime())));
diff --git a/spring-context/src/test/java/org/springframework/format/datetime/joda/DateTimeFormatterFactoryTests.java b/spring-context/src/test/java/org/springframework/format/datetime/joda/DateTimeFormatterFactoryTests.java
index 122d3218b4..341b88e48b 100644
--- a/spring-context/src/test/java/org/springframework/format/datetime/joda/DateTimeFormatterFactoryTests.java
+++ b/spring-context/src/test/java/org/springframework/format/datetime/joda/DateTimeFormatterFactoryTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2015 the original author or authors.
+ * Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -50,32 +50,32 @@ public class DateTimeFormatterFactoryTests {
@Test
- public void createDateTimeFormatter() throws Exception {
+ public void createDateTimeFormatter() {
assertThat(factory.createDateTimeFormatter(), is(equalTo(DateTimeFormat.mediumDateTime())));
}
@Test
- public void createDateTimeFormatterWithPattern() throws Exception {
+ public void createDateTimeFormatterWithPattern() {
factory = new DateTimeFormatterFactory("yyyyMMddHHmmss");
DateTimeFormatter formatter = factory.createDateTimeFormatter();
assertThat(formatter.print(dateTime), is("20091021121000"));
}
@Test
- public void createDateTimeFormatterWithNullFallback() throws Exception {
+ public void createDateTimeFormatterWithNullFallback() {
DateTimeFormatter formatter = factory.createDateTimeFormatter(null);
assertThat(formatter, is(nullValue()));
}
@Test
- public void createDateTimeFormatterWithFallback() throws Exception {
+ public void createDateTimeFormatterWithFallback() {
DateTimeFormatter fallback = DateTimeFormat.forStyle("LL");
DateTimeFormatter formatter = factory.createDateTimeFormatter(fallback);
assertThat(formatter, is(sameInstance(fallback)));
}
@Test
- public void createDateTimeFormatterInOrderOfPropertyPriority() throws Exception {
+ public void createDateTimeFormatterInOrderOfPropertyPriority() {
factory.setStyle("SS");
String value = applyLocale(factory.createDateTimeFormatter()).print(dateTime);
assertTrue(value.startsWith("10/21/09"));
@@ -89,7 +89,7 @@ public class DateTimeFormatterFactoryTests {
}
@Test
- public void createDateTimeFormatterWithTimeZone() throws Exception {
+ public void createDateTimeFormatterWithTimeZone() {
factory.setPattern("yyyyMMddHHmmss Z");
factory.setTimeZone(TEST_TIMEZONE);
DateTimeZone dateTimeZone = DateTimeZone.forTimeZone(TEST_TIMEZONE);
diff --git a/spring-context/src/test/java/org/springframework/format/datetime/joda/JodaTimeFormattingTests.java b/spring-context/src/test/java/org/springframework/format/datetime/joda/JodaTimeFormattingTests.java
index b0de33ec7b..e86a4093b3 100644
--- a/spring-context/src/test/java/org/springframework/format/datetime/joda/JodaTimeFormattingTests.java
+++ b/spring-context/src/test/java/org/springframework/format/datetime/joda/JodaTimeFormattingTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2016 the original author or authors.
+ * Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -62,12 +62,12 @@ public class JodaTimeFormattingTests {
@Before
- public void setUp() {
+ public void setup() {
JodaTimeFormatterRegistrar registrar = new JodaTimeFormatterRegistrar();
- setUp(registrar);
+ setup(registrar);
}
- private void setUp(JodaTimeFormatterRegistrar registrar) {
+ private void setup(JodaTimeFormatterRegistrar registrar) {
conversionService = new FormattingConversionService();
DefaultConversionService.addDefaultConverters(conversionService);
registrar.registerFormatters(conversionService);
@@ -84,7 +84,7 @@ public class JodaTimeFormattingTests {
}
@After
- public void tearDown() {
+ public void cleanup() {
LocaleContextHolder.setLocale(null);
JodaTimeContextHolder.setJodaTimeContext(null);
}
@@ -108,10 +108,10 @@ public class JodaTimeFormattingTests {
}
@Test
- public void testBindLocalDateWithSpecificStyle() throws Exception {
+ public void testBindLocalDateWithSpecificStyle() {
JodaTimeFormatterRegistrar registrar = new JodaTimeFormatterRegistrar();
registrar.setDateStyle("L");
- setUp(registrar);
+ setup(registrar);
MutablePropertyValues propertyValues = new MutablePropertyValues();
propertyValues.add("localDate", "October 31, 2009");
binder.bind(propertyValues);
@@ -120,10 +120,10 @@ public class JodaTimeFormattingTests {
}
@Test
- public void testBindLocalDateWithSpecificFormatter() throws Exception {
+ public void testBindLocalDateWithSpecificFormatter() {
JodaTimeFormatterRegistrar registrar = new JodaTimeFormatterRegistrar();
registrar.setDateFormatter(org.joda.time.format.DateTimeFormat.forPattern("yyyyMMdd"));
- setUp(registrar);
+ setup(registrar);
MutablePropertyValues propertyValues = new MutablePropertyValues();
propertyValues.add("localDate", "20091031");
binder.bind(propertyValues);
@@ -196,10 +196,10 @@ public class JodaTimeFormattingTests {
}
@Test
- public void testBindLocalTimeWithSpecificStyle() throws Exception {
+ public void testBindLocalTimeWithSpecificStyle() {
JodaTimeFormatterRegistrar registrar = new JodaTimeFormatterRegistrar();
registrar.setTimeStyle("M");
- setUp(registrar);
+ setup(registrar);
MutablePropertyValues propertyValues = new MutablePropertyValues();
propertyValues.add("localTime", "12:00:00 PM");
binder.bind(propertyValues);
@@ -208,10 +208,10 @@ public class JodaTimeFormattingTests {
}
@Test
- public void testBindLocalTimeWithSpecificFormatter() throws Exception {
+ public void testBindLocalTimeWithSpecificFormatter() {
JodaTimeFormatterRegistrar registrar = new JodaTimeFormatterRegistrar();
registrar.setTimeFormatter(org.joda.time.format.DateTimeFormat.forPattern("HHmmss"));
- setUp(registrar);
+ setup(registrar);
MutablePropertyValues propertyValues = new MutablePropertyValues();
propertyValues.add("localTime", "130000");
binder.bind(propertyValues);
@@ -261,10 +261,10 @@ public class JodaTimeFormattingTests {
}
@Test
- public void testBindDateTimeWithSpecificStyle() throws Exception {
+ public void testBindDateTimeWithSpecificStyle() {
JodaTimeFormatterRegistrar registrar = new JodaTimeFormatterRegistrar();
registrar.setDateTimeStyle("MM");
- setUp(registrar);
+ setup(registrar);
MutablePropertyValues propertyValues = new MutablePropertyValues();
propertyValues.add("localDateTime", new LocalDateTime(2009, 10, 31, 12, 0));
binder.bind(propertyValues);
@@ -275,10 +275,10 @@ public class JodaTimeFormattingTests {
}
@Test
- public void testBindDateTimeISO() throws Exception {
+ public void testBindDateTimeISO() {
JodaTimeFormatterRegistrar registrar = new JodaTimeFormatterRegistrar();
registrar.setUseIsoFormat(true);
- setUp(registrar);
+ setup(registrar);
MutablePropertyValues propertyValues = new MutablePropertyValues();
propertyValues.add("dateTime", "2009-10-31T12:00:00.000Z");
binder.bind(propertyValues);
@@ -287,10 +287,10 @@ public class JodaTimeFormattingTests {
}
@Test
- public void testBindDateTimeWithSpecificFormatter() throws Exception {
+ public void testBindDateTimeWithSpecificFormatter() {
JodaTimeFormatterRegistrar registrar = new JodaTimeFormatterRegistrar();
registrar.setDateTimeFormatter(org.joda.time.format.DateTimeFormat.forPattern("yyyyMMddHHmmss"));
- setUp(registrar);
+ setup(registrar);
MutablePropertyValues propertyValues = new MutablePropertyValues();
propertyValues.add("dateTime", "20091031130000");
binder.bind(propertyValues);
@@ -435,33 +435,31 @@ public class JodaTimeFormattingTests {
}
@Test
- public void dateToStringWithFormat() throws Exception {
+ public void dateToStringWithFormat() {
JodaTimeFormatterRegistrar registrar = new JodaTimeFormatterRegistrar();
registrar.setDateTimeFormatter(org.joda.time.format.DateTimeFormat.shortDateTime());
- setUp(registrar);
+ setup(registrar);
Date date = new Date();
Object actual = this.conversionService.convert(date, TypeDescriptor.valueOf(Date.class), TypeDescriptor.valueOf(String.class));
String expected = JodaTimeContextHolder.getFormatter(org.joda.time.format.DateTimeFormat.shortDateTime(), Locale.US).print(new DateTime(date));
assertEquals(expected, actual);
}
- @Test
+ @Test // SPR-10105
@SuppressWarnings("deprecation")
- public void stringToDateWithoutGlobalFormat() throws Exception {
- // SPR-10105
+ public void stringToDateWithoutGlobalFormat() {
String string = "Sat, 12 Aug 1995 13:30:00 GM";
Date date = this.conversionService.convert(string, Date.class);
assertThat(date, equalTo(new Date(string)));
}
- @Test
- public void stringToDateWithGlobalFormat() throws Exception {
- // SPR-10105
+ @Test // SPR-10105
+ public void stringToDateWithGlobalFormat() {
JodaTimeFormatterRegistrar registrar = new JodaTimeFormatterRegistrar();
DateTimeFormatterFactory factory = new DateTimeFormatterFactory();
factory.setIso(ISO.DATE_TIME);
registrar.setDateTimeFormatter(factory.createDateTimeFormatter());
- setUp(registrar);
+ setup(registrar);
// This is a format that cannot be parsed by new Date(String)
String string = "2009-10-31T07:00:00.000-05:00";
Date date = this.conversionService.convert(string, Date.class);
@@ -570,7 +568,7 @@ public class JodaTimeFormattingTests {
private MonthDay monthDay;
- private final List children = new ArrayList();
+ private final List children = new ArrayList<>();
public LocalDate getLocalDate() {
return localDate;
diff --git a/spring-context/src/test/java/org/springframework/format/datetime/standard/DateTimeFormatterFactoryBeanTests.java b/spring-context/src/test/java/org/springframework/format/datetime/standard/DateTimeFormatterFactoryBeanTests.java
index 536921b387..860b1df730 100644
--- a/spring-context/src/test/java/org/springframework/format/datetime/standard/DateTimeFormatterFactoryBeanTests.java
+++ b/spring-context/src/test/java/org/springframework/format/datetime/standard/DateTimeFormatterFactoryBeanTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2012 the original author or authors.
+ * Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -30,31 +30,32 @@ import static org.junit.Assert.*;
*/
public class DateTimeFormatterFactoryBeanTests {
- private DateTimeFormatterFactoryBean factory = new DateTimeFormatterFactoryBean();
+ private final DateTimeFormatterFactoryBean factory = new DateTimeFormatterFactoryBean();
+
@Test
- public void isSingleton() throws Exception {
+ public void isSingleton() {
assertThat(factory.isSingleton(), is(true));
}
@Test
- @SuppressWarnings("rawtypes")
- public void getObjectType() throws Exception {
- assertThat(factory.getObjectType(), is(equalTo((Class) DateTimeFormatter.class)));
+ public void getObjectType() {
+ assertThat(factory.getObjectType(), is(equalTo(DateTimeFormatter.class)));
}
@Test
- public void getObject() throws Exception {
+ public void getObject() {
factory.afterPropertiesSet();
assertThat(factory.getObject().toString(), is(equalTo(DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM).toString())));
}
@Test
- public void getObjectIsAlwaysSingleton() throws Exception {
+ public void getObjectIsAlwaysSingleton() {
factory.afterPropertiesSet();
DateTimeFormatter formatter = factory.getObject();
assertThat(formatter.toString(), is(equalTo(DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM).toString())));
factory.setStylePattern("LL");
assertThat(factory.getObject(), is(sameInstance(formatter)));
}
+
}
diff --git a/spring-context/src/test/java/org/springframework/format/datetime/standard/DateTimeFormatterFactoryTests.java b/spring-context/src/test/java/org/springframework/format/datetime/standard/DateTimeFormatterFactoryTests.java
index 9c01af8657..b33d18e50d 100644
--- a/spring-context/src/test/java/org/springframework/format/datetime/standard/DateTimeFormatterFactoryTests.java
+++ b/spring-context/src/test/java/org/springframework/format/datetime/standard/DateTimeFormatterFactoryTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2015 the original author or authors.
+ * Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -51,32 +51,32 @@ public class DateTimeFormatterFactoryTests {
@Test
- public void createDateTimeFormatter() throws Exception {
+ public void createDateTimeFormatter() {
assertThat(factory.createDateTimeFormatter().toString(), is(equalTo(DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM).toString())));
}
@Test
- public void createDateTimeFormatterWithPattern() throws Exception {
+ public void createDateTimeFormatterWithPattern() {
factory = new DateTimeFormatterFactory("yyyyMMddHHmmss");
DateTimeFormatter formatter = factory.createDateTimeFormatter();
assertThat(formatter.format(dateTime), is("20091021121000"));
}
@Test
- public void createDateTimeFormatterWithNullFallback() throws Exception {
+ public void createDateTimeFormatterWithNullFallback() {
DateTimeFormatter formatter = factory.createDateTimeFormatter(null);
assertThat(formatter, is(nullValue()));
}
@Test
- public void createDateTimeFormatterWithFallback() throws Exception {
+ public void createDateTimeFormatterWithFallback() {
DateTimeFormatter fallback = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.LONG);
DateTimeFormatter formatter = factory.createDateTimeFormatter(fallback);
assertThat(formatter, is(sameInstance(fallback)));
}
@Test
- public void createDateTimeFormatterInOrderOfPropertyPriority() throws Exception {
+ public void createDateTimeFormatterInOrderOfPropertyPriority() {
factory.setStylePattern("SS");
String value = applyLocale(factory.createDateTimeFormatter()).format(dateTime);
assertTrue(value.startsWith("10/21/09"));
@@ -90,7 +90,7 @@ public class DateTimeFormatterFactoryTests {
}
@Test
- public void createDateTimeFormatterWithTimeZone() throws Exception {
+ public void createDateTimeFormatterWithTimeZone() {
factory.setPattern("yyyyMMddHHmmss Z");
factory.setTimeZone(TEST_TIMEZONE);
ZoneId dateTimeZone = TEST_TIMEZONE.toZoneId();
diff --git a/spring-core/src/main/java/org/springframework/core/io/VfsUtils.java b/spring-core/src/main/java/org/springframework/core/io/VfsUtils.java
index d66b9a63c4..36c2019b0d 100644
--- a/spring-core/src/main/java/org/springframework/core/io/VfsUtils.java
+++ b/spring-core/src/main/java/org/springframework/core/io/VfsUtils.java
@@ -46,24 +46,24 @@ public abstract class VfsUtils {
private static final String VFS3_PKG = "org.jboss.vfs.";
private static final String VFS_NAME = "VFS";
- private static Method VFS_METHOD_GET_ROOT_URL;
- private static Method VFS_METHOD_GET_ROOT_URI;
+ private static final Method VFS_METHOD_GET_ROOT_URL;
+ private static final Method VFS_METHOD_GET_ROOT_URI;
- private static Method VIRTUAL_FILE_METHOD_EXISTS;
- private static Method VIRTUAL_FILE_METHOD_GET_INPUT_STREAM;
- private static Method VIRTUAL_FILE_METHOD_GET_SIZE;
- private static Method VIRTUAL_FILE_METHOD_GET_LAST_MODIFIED;
- private static Method VIRTUAL_FILE_METHOD_TO_URL;
- private static Method VIRTUAL_FILE_METHOD_TO_URI;
- private static Method VIRTUAL_FILE_METHOD_GET_NAME;
- private static Method VIRTUAL_FILE_METHOD_GET_PATH_NAME;
- private static Method VIRTUAL_FILE_METHOD_GET_CHILD;
+ private static final Method VIRTUAL_FILE_METHOD_EXISTS;
+ private static final Method VIRTUAL_FILE_METHOD_GET_INPUT_STREAM;
+ private static final Method VIRTUAL_FILE_METHOD_GET_SIZE;
+ private static final Method VIRTUAL_FILE_METHOD_GET_LAST_MODIFIED;
+ private static final Method VIRTUAL_FILE_METHOD_TO_URL;
+ private static final Method VIRTUAL_FILE_METHOD_TO_URI;
+ private static final Method VIRTUAL_FILE_METHOD_GET_NAME;
+ private static final Method VIRTUAL_FILE_METHOD_GET_PATH_NAME;
+ private static final Method VIRTUAL_FILE_METHOD_GET_CHILD;
- protected static Class> VIRTUAL_FILE_VISITOR_INTERFACE;
- protected static Method VIRTUAL_FILE_METHOD_VISIT;
+ protected static final Class> VIRTUAL_FILE_VISITOR_INTERFACE;
+ protected static final Method VIRTUAL_FILE_METHOD_VISIT;
- private static Field VISITOR_ATTRIBUTES_FIELD_RECURSE;
- private static Method GET_PHYSICAL_FILE;
+ private static final Field VISITOR_ATTRIBUTES_FIELD_RECURSE;
+ private static final Method GET_PHYSICAL_FILE;
static {
ClassLoader loader = VfsUtils.class.getClassLoader();
diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/ast/Operator.java b/spring-expression/src/main/java/org/springframework/expression/spel/ast/Operator.java
index 387259094b..4a4b89dfa3 100644
--- a/spring-expression/src/main/java/org/springframework/expression/spel/ast/Operator.java
+++ b/spring-expression/src/main/java/org/springframework/expression/spel/ast/Operator.java
@@ -233,9 +233,9 @@ public abstract class Operator extends SpelNodeImpl {
*/
protected static class DescriptorComparison {
- static DescriptorComparison NOT_NUMBERS = new DescriptorComparison(false, false, ' ');
+ static final DescriptorComparison NOT_NUMBERS = new DescriptorComparison(false, false, ' ');
- static DescriptorComparison INCOMPATIBLE_NUMBERS = new DescriptorComparison(true, false, ' ');
+ static final DescriptorComparison INCOMPATIBLE_NUMBERS = new DescriptorComparison(true, false, ' ');
final boolean areNumbers; // Were the two compared descriptor both for numbers?
diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/ast/SpelNodeImpl.java b/spring-expression/src/main/java/org/springframework/expression/spel/ast/SpelNodeImpl.java
index 4e88e5bf2d..47206f4190 100644
--- a/spring-expression/src/main/java/org/springframework/expression/spel/ast/SpelNodeImpl.java
+++ b/spring-expression/src/main/java/org/springframework/expression/spel/ast/SpelNodeImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2017 the original author or authors.
+ * Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -43,7 +43,7 @@ import org.springframework.util.ObjectUtils;
*/
public abstract class SpelNodeImpl implements SpelNode, Opcodes {
- private static SpelNodeImpl[] NO_CHILDREN = new SpelNodeImpl[0];
+ private static final SpelNodeImpl[] NO_CHILDREN = new SpelNodeImpl[0];
protected int pos; // start = top 16bits, end = bottom 16bits
diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/object/BatchSqlUpdate.java b/spring-jdbc/src/main/java/org/springframework/jdbc/object/BatchSqlUpdate.java
index c8b0484652..2a91dc6bc7 100644
--- a/spring-jdbc/src/main/java/org/springframework/jdbc/object/BatchSqlUpdate.java
+++ b/spring-jdbc/src/main/java/org/springframework/jdbc/object/BatchSqlUpdate.java
@@ -48,7 +48,7 @@ public class BatchSqlUpdate extends SqlUpdate {
/**
* Default number of inserts to accumulate before commiting a batch (5000).
*/
- public static int DEFAULT_BATCH_SIZE = 5000;
+ public static final int DEFAULT_BATCH_SIZE = 5000;
private int batchSize = DEFAULT_BATCH_SIZE;
diff --git a/spring-jms/src/main/java/org/springframework/jms/support/SimpleJmsHeaderMapper.java b/spring-jms/src/main/java/org/springframework/jms/support/SimpleJmsHeaderMapper.java
index 10bd931850..5320daf264 100644
--- a/spring-jms/src/main/java/org/springframework/jms/support/SimpleJmsHeaderMapper.java
+++ b/spring-jms/src/main/java/org/springframework/jms/support/SimpleJmsHeaderMapper.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2014 the original author or authors.
+ * Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -55,7 +55,7 @@ import org.springframework.util.StringUtils;
*/
public class SimpleJmsHeaderMapper extends AbstractHeaderMapper implements JmsHeaderMapper {
- private static Set> SUPPORTED_PROPERTY_TYPES = new HashSet>(Arrays.asList(new Class>[] {
+ private static final Set> SUPPORTED_PROPERTY_TYPES = new HashSet>(Arrays.asList(new Class>[] {
Boolean.class, Byte.class, Double.class, Float.class, Integer.class, Long.class, Short.class, String.class}));
diff --git a/spring-messaging/src/main/java/org/springframework/messaging/simp/broker/AbstractSubscriptionRegistry.java b/spring-messaging/src/main/java/org/springframework/messaging/simp/broker/AbstractSubscriptionRegistry.java
index bf37bb16c3..5b563e69cc 100644
--- a/spring-messaging/src/main/java/org/springframework/messaging/simp/broker/AbstractSubscriptionRegistry.java
+++ b/spring-messaging/src/main/java/org/springframework/messaging/simp/broker/AbstractSubscriptionRegistry.java
@@ -37,7 +37,7 @@ import org.springframework.util.MultiValueMap;
*/
public abstract class AbstractSubscriptionRegistry implements SubscriptionRegistry {
- private static MultiValueMap EMPTY_MAP =
+ private static final MultiValueMap EMPTY_MAP =
CollectionUtils.unmodifiableMultiValueMap(new LinkedMultiValueMap(0));
protected final Log logger = LogFactory.getLog(getClass());
diff --git a/spring-test/src/main/java/org/springframework/test/web/servlet/MockMvc.java b/spring-test/src/main/java/org/springframework/test/web/servlet/MockMvc.java
index 360bf33c25..70a605c051 100644
--- a/spring-test/src/main/java/org/springframework/test/web/servlet/MockMvc.java
+++ b/spring-test/src/main/java/org/springframework/test/web/servlet/MockMvc.java
@@ -60,7 +60,7 @@ import org.springframework.web.context.request.ServletRequestAttributes;
*/
public final class MockMvc {
- static String MVC_RESULT_ATTRIBUTE = MockMvc.class.getName().concat(".MVC_RESULT_ATTRIBUTE");
+ static final String MVC_RESULT_ATTRIBUTE = MockMvc.class.getName().concat(".MVC_RESULT_ATTRIBUTE");
private final TestDispatcherServlet servlet;
diff --git a/spring-web/src/main/java/org/springframework/http/server/ServletServerHttpAsyncRequestControl.java b/spring-web/src/main/java/org/springframework/http/server/ServletServerHttpAsyncRequestControl.java
index d21cd784d7..5517e438a0 100644
--- a/spring-web/src/main/java/org/springframework/http/server/ServletServerHttpAsyncRequestControl.java
+++ b/spring-web/src/main/java/org/springframework/http/server/ServletServerHttpAsyncRequestControl.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2014 the original author or authors.
+ * Copyright 2002-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -34,7 +34,7 @@ import org.springframework.util.Assert;
*/
public class ServletServerHttpAsyncRequestControl implements ServerHttpAsyncRequestControl, AsyncListener {
- private static long NO_TIMEOUT_VALUE = Long.MIN_VALUE;
+ private static final long NO_TIMEOUT_VALUE = Long.MIN_VALUE;
private final ServletServerHttpRequest request;
diff --git a/spring-web/src/main/java/org/springframework/remoting/httpinvoker/SimpleHttpInvokerRequestExecutor.java b/spring-web/src/main/java/org/springframework/remoting/httpinvoker/SimpleHttpInvokerRequestExecutor.java
index d07bedd040..5cd27eb6c0 100644
--- a/spring-web/src/main/java/org/springframework/remoting/httpinvoker/SimpleHttpInvokerRequestExecutor.java
+++ b/spring-web/src/main/java/org/springframework/remoting/httpinvoker/SimpleHttpInvokerRequestExecutor.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2017 the original author or authors.
+ * Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,14 +31,13 @@ import org.springframework.remoting.support.RemoteInvocationResult;
import org.springframework.util.StringUtils;
/**
- * HttpInvokerRequestExecutor implementation that uses standard J2SE facilities
- * to execute POST requests, without support for HTTP authentication or
- * advanced configuration options.
+ * {@link org.springframework.remoting.httpinvoker.HttpInvokerRequestExecutor} implementation
+ * that uses standard Java facilities to execute POST requests, without support for HTTP
+ * authentication or advanced configuration options.
*
- * Designed for easy subclassing, customizing specific template methods.
- * However, consider {@code HttpComponentsHttpInvokerRequestExecutor} for
- * more sophisticated needs: The J2SE HttpURLConnection is rather limited
- * in its capabilities.
+ *
Designed for easy subclassing, customizing specific template methods. However,
+ * consider {@code HttpComponentsHttpInvokerRequestExecutor} for more sophisticated needs:
+ * The standard {@link HttpURLConnection} class is rather limited in its capabilities.
*
* @author Juergen Hoeller
* @since 1.1
@@ -73,7 +72,7 @@ public class SimpleHttpInvokerRequestExecutor extends AbstractHttpInvokerRequest
/**
- * Execute the given request through a standard J2SE HttpURLConnection.
+ * Execute the given request through a standard {@link HttpURLConnection}.
*
This method implements the basic processing workflow:
* The actual work happens in this class's template methods.
* @see #openConnection
@@ -97,7 +96,7 @@ public class SimpleHttpInvokerRequestExecutor extends AbstractHttpInvokerRequest
}
/**
- * Open an HttpURLConnection for the given remote invocation request.
+ * Open an {@link HttpURLConnection} for the given remote invocation request.
* @param config the HTTP invoker configuration that specifies the
* target service
* @return the HttpURLConnection for the given request
@@ -171,7 +170,7 @@ public class SimpleHttpInvokerRequestExecutor extends AbstractHttpInvokerRequest
}
/**
- * Validate the given response as contained in the HttpURLConnection object,
+ * Validate the given response as contained in the {@link HttpURLConnection} object,
* throwing an exception if it does not correspond to a successful HTTP response.
*
Default implementation rejects any HTTP status code beyond 2xx, to avoid
* parsing the response body and trying to deserialize from a corrupted stream.
diff --git a/spring-web/src/main/java/org/springframework/web/context/request/ServletWebRequest.java b/spring-web/src/main/java/org/springframework/web/context/request/ServletWebRequest.java
index 4906310f92..877f60941f 100644
--- a/spring-web/src/main/java/org/springframework/web/context/request/ServletWebRequest.java
+++ b/spring-web/src/main/java/org/springframework/web/context/request/ServletWebRequest.java
@@ -78,7 +78,7 @@ public class ServletWebRequest extends ServletRequestAttributes implements Nativ
"EEE MMM dd HH:mm:ss yyyy"
};
- private static TimeZone GMT = TimeZone.getTimeZone("GMT");
+ private static final TimeZone GMT = TimeZone.getTimeZone("GMT");
/** Checking for Servlet 3.0+ HttpServletResponse.getHeader(String) */
private static final boolean servlet3Present =
diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/View.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/View.java
index f63658d0bf..5186b4884c 100644
--- a/spring-webmvc/src/main/java/org/springframework/web/servlet/View.java
+++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/View.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2012 the original author or authors.
+ * Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,8 +20,6 @@ import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import org.springframework.http.MediaType;
-
/**
* MVC View for a web interaction. Implementations are responsible for rendering
* content, and exposing the model. A single view exposes multiple model attributes.
@@ -39,6 +37,7 @@ import org.springframework.http.MediaType;
*
* @author Rod Johnson
* @author Arjen Poutsma
+ * @author Rossen Stoyanchev
* @see org.springframework.web.servlet.view.AbstractView
* @see org.springframework.web.servlet.view.InternalResourceView
*/
@@ -47,6 +46,7 @@ public interface View {
/**
* Name of the {@link HttpServletRequest} attribute that contains the response status code.
*
Note: This attribute is not required to be supported by all View implementations.
+ * @since 3.0
*/
String RESPONSE_STATUS_ATTRIBUTE = View.class.getName() + ".responseStatus";
@@ -54,33 +54,34 @@ public interface View {
* Name of the {@link HttpServletRequest} attribute that contains a Map with path variables.
* The map consists of String-based URI template variable names as keys and their corresponding
* Object-based values -- extracted from segments of the URL and type converted.
- *
*
Note: This attribute is not required to be supported by all View implementations.
+ * @since 3.1
*/
String PATH_VARIABLES = View.class.getName() + ".pathVariables";
/**
- * The {@link MediaType} selected during content negotiation, which may be
- * more specific than the one the View is configured with. For example:
+ * The {@link org.springframework.http.MediaType} selected during content negotiation,
+ * which may be more specific than the one the View is configured with. For example:
* "application/vnd.example-v1+xml" vs "application/*+xml".
+ * @since 3.2
*/
String SELECTED_CONTENT_TYPE = View.class.getName() + ".selectedContentType";
+
/**
* Return the content type of the view, if predetermined.
- *
Can be used to check the content type upfront,
- * before the actual rendering process.
+ *
Can be used to check the view's content type upfront,
+ * i.e. before an actual rendering attempt.
* @return the content type String (optionally including a character set),
- * or {@code null} if not predetermined.
+ * or {@code null} if not predetermined
*/
String getContentType();
/**
* Render the view given the specified model.
- *
The first step will be preparing the request: In the JSP case,
- * this would mean setting model objects as request attributes.
- * The second step will be the actual rendering of the view,
- * for example including the JSP via a RequestDispatcher.
+ *
The first step will be preparing the request: In the JSP case, this would mean
+ * setting model objects as request attributes. The second step will be the actual
+ * rendering of the view, for example including the JSP via a RequestDispatcher.
* @param model Map with name Strings as keys and corresponding model
* objects as values (Map can also be {@code null} in case of empty model)
* @param request current HTTP request
diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/support/BindStatus.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/support/BindStatus.java
index 4fd4058ef1..1ac4545d88 100644
--- a/spring-webmvc/src/main/java/org/springframework/web/servlet/support/BindStatus.java
+++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/support/BindStatus.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2014 the original author or authors.
+ * Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -82,9 +82,7 @@ public class BindStatus {
* @param htmlEscape whether to HTML-escape error messages and string values
* @throws IllegalStateException if no corresponding Errors object found
*/
- public BindStatus(RequestContext requestContext, String path, boolean htmlEscape)
- throws IllegalStateException {
-
+ public BindStatus(RequestContext requestContext, String path, boolean htmlEscape) throws IllegalStateException {
this.requestContext = requestContext;
this.path = path;
this.htmlEscape = htmlEscape;
diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/messaging/StompSubProtocolErrorHandler.java b/spring-websocket/src/main/java/org/springframework/web/socket/messaging/StompSubProtocolErrorHandler.java
index 9560d93385..2be1d57d29 100644
--- a/spring-websocket/src/main/java/org/springframework/web/socket/messaging/StompSubProtocolErrorHandler.java
+++ b/spring-websocket/src/main/java/org/springframework/web/socket/messaging/StompSubProtocolErrorHandler.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2015 the original author or authors.
+ * Copyright 2002-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,7 +31,7 @@ import org.springframework.util.Assert;
*/
public class StompSubProtocolErrorHandler implements SubProtocolErrorHandler {
- private static byte[] EMPTY_PAYLOAD = new byte[0];
+ private static final byte[] EMPTY_PAYLOAD = new byte[0];
@Override
diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/TransportHandlingSockJsService.java b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/TransportHandlingSockJsService.java
index 462b04fc8b..1055b8d377 100644
--- a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/TransportHandlingSockJsService.java
+++ b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/TransportHandlingSockJsService.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2016 the original author or authors.
+ * Copyright 2002-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,6 +21,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
+import java.util.EnumMap;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -66,7 +67,8 @@ public class TransportHandlingSockJsService extends AbstractSockJsService implem
"com.fasterxml.jackson.databind.ObjectMapper", TransportHandlingSockJsService.class.getClassLoader());
- private final Map handlers = new HashMap();
+ private final Map handlers =
+ new EnumMap(TransportType.class);
private SockJsMessageCodec messageCodec;