From d7be1e0dab1d93e41e6919c2a7ee8520580bd26b Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Tue, 14 Jun 2022 15:09:39 +0200 Subject: [PATCH] Polishing --- .../springframework/core/io/UrlResource.java | 24 ++++++++++--------- .../jdbc/core/JdbcTemplateTests.java | 4 ++-- .../Jaxb2CollectionHttpMessageConverter.java | 4 ++-- .../web/filter/GenericFilterBean.java | 4 ++-- 4 files changed, 19 insertions(+), 17 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/core/io/UrlResource.java b/spring-core/src/main/java/org/springframework/core/io/UrlResource.java index 3f1dcc05ffe..53b38197e6c 100644 --- a/spring-core/src/main/java/org/springframework/core/io/UrlResource.java +++ b/spring-core/src/main/java/org/springframework/core/io/UrlResource.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2022 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. @@ -60,6 +60,18 @@ public class UrlResource extends AbstractFileResolvingResource { private volatile URL cleanedUrl; + /** + * Create a new {@code UrlResource} based on the given URL object. + * @param url a URL + * @see #UrlResource(URI) + * @see #UrlResource(String) + */ + public UrlResource(URL url) { + Assert.notNull(url, "URL must not be null"); + this.uri = null; + this.url = url; + } + /** * Create a new {@code UrlResource} based on the given URI object. * @param uri a URI @@ -72,16 +84,6 @@ public class UrlResource extends AbstractFileResolvingResource { this.url = uri.toURL(); } - /** - * Create a new {@code UrlResource} based on the given URL object. - * @param url a URL - */ - public UrlResource(URL url) { - Assert.notNull(url, "URL must not be null"); - this.uri = null; - this.url = url; - } - /** * Create a new {@code UrlResource} based on a URL path. *

Note: The given path needs to be pre-encoded if necessary. diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/core/JdbcTemplateTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/core/JdbcTemplateTests.java index 65c59fb321d..5b9f7b823e0 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/core/JdbcTemplateTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/core/JdbcTemplateTests.java @@ -955,7 +955,7 @@ public class JdbcTemplateTests { } @Test - public void testSQLErrorCodeTranslationWithSpecifiedDbName() throws Exception { + public void testSQLErrorCodeTranslationWithSpecifiedDatabaseName() throws Exception { final SQLException sqlException = new SQLException("I have a known problem", "99999", 1054); final String sql = "SELECT ID FROM CUSTOMER"; @@ -983,7 +983,7 @@ public class JdbcTemplateTests { * to get the metadata */ @Test - public void testUseCustomSQLErrorCodeTranslator() throws Exception { + public void testUseCustomExceptionTranslator() throws Exception { // Bad SQL state final SQLException sqlException = new SQLException("I have a known problem", "07000", 1054); final String sql = "SELECT ID FROM CUSTOMER"; diff --git a/spring-web/src/main/java/org/springframework/http/converter/xml/Jaxb2CollectionHttpMessageConverter.java b/spring-web/src/main/java/org/springframework/http/converter/xml/Jaxb2CollectionHttpMessageConverter.java index ab3850c42bf..b3c28e61958 100644 --- a/spring-web/src/main/java/org/springframework/http/converter/xml/Jaxb2CollectionHttpMessageConverter.java +++ b/spring-web/src/main/java/org/springframework/http/converter/xml/Jaxb2CollectionHttpMessageConverter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2022 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. @@ -174,7 +174,7 @@ public class Jaxb2CollectionHttpMessageConverter } catch (UnmarshalException ex) { throw new HttpMessageNotReadableException( - "Could not unmarshal to [" + elementClass + "]: " + ex.getMessage(), ex, inputMessage); + "Could not unmarshal to [" + elementClass + "]: " + ex, ex, inputMessage); } catch (JAXBException ex) { throw new HttpMessageConversionException("Invalid JAXB setup: " + ex.getMessage(), ex); diff --git a/spring-web/src/main/java/org/springframework/web/filter/GenericFilterBean.java b/spring-web/src/main/java/org/springframework/web/filter/GenericFilterBean.java index da36fb123b3..af995cccac2 100644 --- a/spring-web/src/main/java/org/springframework/web/filter/GenericFilterBean.java +++ b/spring-web/src/main/java/org/springframework/web/filter/GenericFilterBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2022 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. @@ -229,7 +229,7 @@ public abstract class GenericFilterBean implements Filter, BeanNameAware, Enviro } catch (BeansException ex) { String msg = "Failed to set bean properties on filter '" + - filterConfig.getFilterName() + "': " + ex.getMessage(); + filterConfig.getFilterName() + "': " + ex.getMessage(); logger.error(msg, ex); throw new NestedServletException(msg, ex); }