From ce42ed4d449e7fee7179275c8bacd5b902fa672e Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Tue, 13 Sep 2016 21:58:41 +0200 Subject: [PATCH] Polishing --- .../format/datetime/DateFormatter.java | 2 +- .../expression/spel/support/ReflectionHelper.java | 2 +- .../springframework/dao/support/DataAccessUtils.java | 12 ++++++------ ...AndViewResolverMethodReturnValueHandlerTests.java | 5 +++-- ...ervletAnnotationControllerHandlerMethodTests.java | 9 +++------ 5 files changed, 14 insertions(+), 16 deletions(-) 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 b595823149..4b7115b6f5 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 @@ -191,7 +191,7 @@ public class DateFormatter implements Formatter { if (timeStyle != -1) { return DateFormat.getTimeInstance(timeStyle, locale); } - throw new IllegalStateException("Unsupported style pattern '"+ this.stylePattern+ "'"); + throw new IllegalStateException("Unsupported style pattern '" + this.stylePattern + "'"); } return DateFormat.getDateInstance(this.style, locale); diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/support/ReflectionHelper.java b/spring-expression/src/main/java/org/springframework/expression/spel/support/ReflectionHelper.java index 4c721da50e..e4a1613370 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/support/ReflectionHelper.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/support/ReflectionHelper.java @@ -195,7 +195,7 @@ public class ReflectionHelper { TypeDescriptor varargsDesc = expectedArgTypes.get(expectedArgTypes.size() - 1); Class varargsParamType = varargsDesc.getElementTypeDescriptor().getType(); - // All remaining parameters must be of this type or convertable to this type + // All remaining parameters must be of this type or convertible to this type for (int i = expectedArgTypes.size() - 1; i < suppliedArgTypes.size(); i++) { TypeDescriptor suppliedArg = suppliedArgTypes.get(i); if (suppliedArg == null) { diff --git a/spring-tx/src/main/java/org/springframework/dao/support/DataAccessUtils.java b/spring-tx/src/main/java/org/springframework/dao/support/DataAccessUtils.java index c3649bad7e..4d68bd507b 100644 --- a/spring-tx/src/main/java/org/springframework/dao/support/DataAccessUtils.java +++ b/spring-tx/src/main/java/org/springframework/dao/support/DataAccessUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 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. @@ -122,7 +122,7 @@ public abstract class DataAccessUtils { /** * Return a unique result object from the given Collection. * Throws an exception if 0 or more than 1 result objects found, - * of if the unique result object is not convertable to the + * of if the unique result object is not convertible to the * specified required type. * @param results the result Collection (can be {@code null}) * @return the unique result object @@ -162,7 +162,7 @@ public abstract class DataAccessUtils { /** * Return a unique int result from the given Collection. * Throws an exception if 0 or more than 1 result objects found, - * of if the unique result object is not convertable to an int. + * of if the unique result object is not convertible to an int. * @param results the result Collection (can be {@code null}) * @return the unique int result * @throws IncorrectResultSizeDataAccessException if more than one @@ -170,7 +170,7 @@ public abstract class DataAccessUtils { * @throws EmptyResultDataAccessException if no result object * at all has been found in the given Collection * @throws TypeMismatchDataAccessException if the unique object - * in the collection is not convertable to an int + * in the collection is not convertible to an int */ public static int intResult(Collection results) throws IncorrectResultSizeDataAccessException, TypeMismatchDataAccessException { @@ -181,7 +181,7 @@ public abstract class DataAccessUtils { /** * Return a unique long result from the given Collection. * Throws an exception if 0 or more than 1 result objects found, - * of if the unique result object is not convertable to a long. + * of if the unique result object is not convertible to a long. * @param results the result Collection (can be {@code null}) * @return the unique long result * @throws IncorrectResultSizeDataAccessException if more than one @@ -189,7 +189,7 @@ public abstract class DataAccessUtils { * @throws EmptyResultDataAccessException if no result object * at all has been found in the given Collection * @throws TypeMismatchDataAccessException if the unique object - * in the collection is not convertable to a long + * in the collection is not convertible to a long */ public static long longResult(Collection results) throws IncorrectResultSizeDataAccessException, TypeMismatchDataAccessException { diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ModelAndViewResolverMethodReturnValueHandlerTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ModelAndViewResolverMethodReturnValueHandlerTests.java index 4bbd25ab23..d05252ef5a 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ModelAndViewResolverMethodReturnValueHandlerTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ModelAndViewResolverMethodReturnValueHandlerTests.java @@ -126,8 +126,9 @@ public class ModelAndViewResolverMethodReturnValueHandlerTests { @Override @SuppressWarnings("rawtypes") - public ModelAndView resolveModelAndView(Method method, Class handlerType, Object returnValue, + public ModelAndView resolveModelAndView(Method method, Class handlerType, Object returnValue, ExtendedModelMap model, NativeWebRequest request) { + if (returnValue != null && returnValue.getClass().equals(returnValueType)) { return new ModelAndView("viewName", "modelAttrName", returnValue); } @@ -137,4 +138,4 @@ public class ModelAndViewResolverMethodReturnValueHandlerTests { } } -} \ No newline at end of file +} diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletAnnotationControllerHandlerMethodTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletAnnotationControllerHandlerMethodTests.java index d9f5d14441..7d08349038 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletAnnotationControllerHandlerMethodTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletAnnotationControllerHandlerMethodTests.java @@ -2851,18 +2851,15 @@ public class ServletAnnotationControllerHandlerMethodTests extends AbstractServl @Override @SuppressWarnings("rawtypes") - public ModelAndView resolveModelAndView(Method handlerMethod, - Class handlerType, - Object returnValue, - ExtendedModelMap implicitModel, - NativeWebRequest webRequest) { + public ModelAndView resolveModelAndView(Method handlerMethod, Class handlerType, Object returnValue, + ExtendedModelMap implicitModel, NativeWebRequest webRequest) { + if (returnValue instanceof MySpecialArg) { return new ModelAndView(new View() { @Override public String getContentType() { return "text/html"; } - @Override public void render(Map model, HttpServletRequest request, HttpServletResponse response) throws Exception {