diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/RequiredAnnotationBeanPostProcessor.java b/spring-beans/src/main/java/org/springframework/beans/factory/annotation/RequiredAnnotationBeanPostProcessor.java index 0d7eb6ee3b..31c0352879 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/RequiredAnnotationBeanPostProcessor.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/annotation/RequiredAnnotationBeanPostProcessor.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. @@ -55,8 +55,8 @@ import org.springframework.util.Assert; * and obviates the need (in part) for a developer to code a method that * simply checks that all required properties have actually been set. * - *
Please note that an 'init' method may still need to implemented (and may - * still be desirable), because all that this class does is enforce that a + *
Please note that an 'init' method may still need to be implemented (and may
+ * still be desirable), because all that this class does is enforcing that a
* 'required' property has actually been configured with a value. It does
* not check anything else... In particular, it does not check that a
* configured value is not {@code null}.
diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/standard/Tokenizer.java b/spring-expression/src/main/java/org/springframework/expression/spel/standard/Tokenizer.java
index bcd7ea7806..7b7829b8f5 100644
--- a/spring-expression/src/main/java/org/springframework/expression/spel/standard/Tokenizer.java
+++ b/spring-expression/src/main/java/org/springframework/expression/spel/standard/Tokenizer.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.
@@ -265,7 +265,7 @@ class Tokenizer {
raiseParseException(this.pos, SpelMessage.UNEXPECTED_ESCAPE_CHAR);
break;
default:
- throw new IllegalStateException("Cannot handle (" + Integer.valueOf(ch) + ") '" + ch + "'");
+ throw new IllegalStateException("Cannot handle (" + (int) ch + ") '" + ch + "'");
}
}
}
diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/support/DatabaseStartupValidator.java b/spring-jdbc/src/main/java/org/springframework/jdbc/support/DatabaseStartupValidator.java
index e5b11349f8..c6249a3115 100644
--- a/spring-jdbc/src/main/java/org/springframework/jdbc/support/DatabaseStartupValidator.java
+++ b/spring-jdbc/src/main/java/org/springframework/jdbc/support/DatabaseStartupValidator.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2012 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.
@@ -72,7 +72,7 @@ public class DatabaseStartupValidator implements InitializingBean {
/**
* Set the interval between validation runs (in seconds).
- * Default is 1.
+ * Default is {@value #DEFAULT_INTERVAL}.
*/
public void setInterval(int interval) {
this.interval = interval;
@@ -80,7 +80,7 @@ public class DatabaseStartupValidator implements InitializingBean {
/**
* Set the timeout (in seconds) after which a fatal exception
- * will be thrown. Default is 60.
+ * will be thrown. Default is {@value #DEFAULT_TIMEOUT}.
*/
public void setTimeout(int timeout) {
this.timeout = timeout;
@@ -94,11 +94,12 @@ public class DatabaseStartupValidator implements InitializingBean {
*/
@Override
public void afterPropertiesSet() {
- if (this.dataSource == null) {
- throw new IllegalArgumentException("dataSource is required");
+ DataSource dataSource = this.dataSource;
+ if (dataSource == null) {
+ throw new IllegalArgumentException("Property 'dataSource' is required");
}
if (this.validationQuery == null) {
- throw new IllegalArgumentException("validationQuery is required");
+ throw new IllegalArgumentException("Property 'validationQuery' is required");
}
try {
@@ -111,18 +112,22 @@ public class DatabaseStartupValidator implements InitializingBean {
Connection con = null;
Statement stmt = null;
try {
- con = this.dataSource.getConnection();
+ con = dataSource.getConnection();
stmt = con.createStatement();
stmt.execute(this.validationQuery);
validated = true;
}
catch (SQLException ex) {
latestEx = ex;
- logger.debug("Validation query [" + this.validationQuery + "] threw exception", ex);
- float rest = ((float) (deadLine - System.currentTimeMillis())) / 1000;
- if (rest > this.interval) {
- logger.warn("Database has not started up yet - retrying in " + this.interval +
- " seconds (timeout in " + rest + " seconds)");
+ if (logger.isDebugEnabled()) {
+ logger.debug("Validation query [" + this.validationQuery + "] threw exception", ex);
+ }
+ if (logger.isWarnEnabled()) {
+ float rest = ((float) (deadLine - System.currentTimeMillis())) / 1000;
+ if (rest > this.interval) {
+ logger.warn("Database has not started up yet - retrying in " + this.interval +
+ " seconds (timeout in " + rest + " seconds)");
+ }
}
}
finally {
@@ -140,8 +145,8 @@ public class DatabaseStartupValidator implements InitializingBean {
"Database has not started up within " + this.timeout + " seconds", latestEx);
}
- float duration = (System.currentTimeMillis() - beginTime) / 1000;
if (logger.isInfoEnabled()) {
+ float duration = ((float) (System.currentTimeMillis() - beginTime)) / 1000;
logger.info("Database startup detected after " + duration + " seconds");
}
}
diff --git a/spring-web/src/main/java/org/springframework/http/HttpHeaders.java b/spring-web/src/main/java/org/springframework/http/HttpHeaders.java
index 9f74a8978b..517c67e00c 100644
--- a/spring-web/src/main/java/org/springframework/http/HttpHeaders.java
+++ b/spring-web/src/main/java/org/springframework/http/HttpHeaders.java
@@ -400,7 +400,6 @@ public class HttpHeaders implements MultiValueMap The default implementation sends a response error using
* {@link HttpServletResponse#sendError(int)} or
* {@link HttpServletResponse#sendError(int, String)} if the annotation has a
@@ -88,11 +88,9 @@ public class ResponseStatusExceptionResolver extends AbstractHandlerExceptionRes
* @param request current HTTP request
* @param response current HTTP response
* @param handler the executed handler, or {@code null} if none chosen at the
- * time of the exception (for example, if multipart resolution failed)
- * @param ex the exception that got thrown during handler execution or the
- * exception that has the ResponseStatus annotation if found on the cause.
- * @return a corresponding ModelAndView to forward to, or {@code null}
- * for default processing
+ * time of the exception, e.g. if multipart resolution failed
+ * @param ex the exception
+ * @return an empty ModelAndView, i.e. exception resolved
*/
protected ModelAndView resolveResponseStatus(ResponseStatus responseStatus, HttpServletRequest request,
HttpServletResponse response, Object handler, Exception ex) throws Exception {
diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/support/DefaultHandlerExceptionResolver.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/support/DefaultHandlerExceptionResolver.java
index 456a27a525..56a35df001 100644
--- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/support/DefaultHandlerExceptionResolver.java
+++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/support/DefaultHandlerExceptionResolver.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.
@@ -52,9 +52,9 @@ import org.springframework.web.servlet.NoHandlerFoundException;
import org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver;
/**
- * Default implementation of the {@link org.springframework.web.servlet.HandlerExceptionResolver
- * HandlerExceptionResolver} interface that resolves standard Spring exceptions and translates
- * them to corresponding HTTP status codes.
+ * The default implementation of the {@link org.springframework.web.servlet.HandlerExceptionResolver}
+ * interface, resolving standard Spring MVC exceptions and translating them to corresponding
+ * HTTP status codes.
*
* This exception resolver is enabled by default in the common Spring
* {@link org.springframework.web.servlet.DispatcherServlet}.
@@ -102,63 +102,69 @@ public class DefaultHandlerExceptionResolver extends AbstractHandlerExceptionRes
@Override
@SuppressWarnings("deprecation")
- protected ModelAndView doResolveException(HttpServletRequest request, HttpServletResponse response,
- Object handler, Exception ex) {
+ protected ModelAndView doResolveException(
+ HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) {
try {
if (ex instanceof org.springframework.web.servlet.mvc.multiaction.NoSuchRequestHandlingMethodException) {
- return handleNoSuchRequestHandlingMethod((org.springframework.web.servlet.mvc.multiaction.NoSuchRequestHandlingMethodException) ex,
+ return handleNoSuchRequestHandlingMethod(
+ (org.springframework.web.servlet.mvc.multiaction.NoSuchRequestHandlingMethodException) ex,
request, response, handler);
}
else if (ex instanceof HttpRequestMethodNotSupportedException) {
- return handleHttpRequestMethodNotSupported((HttpRequestMethodNotSupportedException) ex, request,
- response, handler);
+ return handleHttpRequestMethodNotSupported(
+ (HttpRequestMethodNotSupportedException) ex, request, response, handler);
}
else if (ex instanceof HttpMediaTypeNotSupportedException) {
- return handleHttpMediaTypeNotSupported((HttpMediaTypeNotSupportedException) ex, request, response,
- handler);
+ return handleHttpMediaTypeNotSupported(
+ (HttpMediaTypeNotSupportedException) ex, request, response, handler);
}
else if (ex instanceof HttpMediaTypeNotAcceptableException) {
- return handleHttpMediaTypeNotAcceptable((HttpMediaTypeNotAcceptableException) ex, request, response,
- handler);
+ return handleHttpMediaTypeNotAcceptable(
+ (HttpMediaTypeNotAcceptableException) ex, request, response, handler);
}
else if (ex instanceof MissingPathVariableException) {
- return handleMissingPathVariable((MissingPathVariableException) ex, request,
- response, handler);
+ return handleMissingPathVariable(
+ (MissingPathVariableException) ex, request, response, handler);
}
else if (ex instanceof MissingServletRequestParameterException) {
- return handleMissingServletRequestParameter((MissingServletRequestParameterException) ex, request,
- response, handler);
+ return handleMissingServletRequestParameter(
+ (MissingServletRequestParameterException) ex, request, response, handler);
}
else if (ex instanceof ServletRequestBindingException) {
- return handleServletRequestBindingException((ServletRequestBindingException) ex, request, response,
- handler);
+ return handleServletRequestBindingException(
+ (ServletRequestBindingException) ex, request, response, handler);
}
else if (ex instanceof ConversionNotSupportedException) {
- return handleConversionNotSupported((ConversionNotSupportedException) ex, request, response, handler);
+ return handleConversionNotSupported(
+ (ConversionNotSupportedException) ex, request, response, handler);
}
else if (ex instanceof TypeMismatchException) {
- return handleTypeMismatch((TypeMismatchException) ex, request, response, handler);
+ return handleTypeMismatch(
+ (TypeMismatchException) ex, request, response, handler);
}
else if (ex instanceof HttpMessageNotReadableException) {
- return handleHttpMessageNotReadable((HttpMessageNotReadableException) ex, request, response, handler);
+ return handleHttpMessageNotReadable(
+ (HttpMessageNotReadableException) ex, request, response, handler);
}
else if (ex instanceof HttpMessageNotWritableException) {
- return handleHttpMessageNotWritable((HttpMessageNotWritableException) ex, request, response, handler);
+ return handleHttpMessageNotWritable(
+ (HttpMessageNotWritableException) ex, request, response, handler);
}
else if (ex instanceof MethodArgumentNotValidException) {
- return handleMethodArgumentNotValidException((MethodArgumentNotValidException) ex, request, response,
- handler);
+ return handleMethodArgumentNotValidException(
+ (MethodArgumentNotValidException) ex, request, response, handler);
}
else if (ex instanceof MissingServletRequestPartException) {
- return handleMissingServletRequestPartException((MissingServletRequestPartException) ex, request,
- response, handler);
+ return handleMissingServletRequestPartException(
+ (MissingServletRequestPartException) ex, request, response, handler);
}
else if (ex instanceof BindException) {
return handleBindException((BindException) ex, request, response, handler);
}
else if (ex instanceof NoHandlerFoundException) {
- return handleNoHandlerFoundException((NoHandlerFoundException) ex, request, response, handler);
+ return handleNoHandlerFoundException(
+ (NoHandlerFoundException) ex, request, response, handler);
}
else if (ex instanceof AsyncRequestTimeoutException) {
return handleAsyncRequestTimeoutException(
@@ -167,7 +173,7 @@ public class DefaultHandlerExceptionResolver extends AbstractHandlerExceptionRes
}
catch (Exception handlerException) {
if (logger.isWarnEnabled()) {
- logger.warn("Handling of [" + ex.getClass().getName() + "] resulted in Exception", handlerException);
+ logger.warn("Handling of [" + ex.getClass().getName() + "] resulted in exception", handlerException);
}
}
return null;
@@ -507,7 +513,6 @@ public class DefaultHandlerExceptionResolver extends AbstractHandlerExceptionRes
return new ModelAndView();
}
-
/**
* Invoked to send a server error. Sets the status to 500 and also sets the
* request attribute "javax.servlet.error.exception" to the Exception.
@@ -515,7 +520,6 @@ public class DefaultHandlerExceptionResolver extends AbstractHandlerExceptionRes
protected void sendServerError(Exception ex, HttpServletRequest request, HttpServletResponse response)
throws IOException {
-
request.setAttribute("javax.servlet.error.exception", ex);
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
}
>(headers.size(), Locale.ENGLISH);
@@ -1319,6 +1318,7 @@ public class HttpHeaders implements MultiValueMap