From ae1d15c8f4d10d21e9cb9abc42a95e9584683fef Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Tue, 8 Sep 2020 12:22:25 +0200 Subject: [PATCH 1/2] Declare protected getCharset method as non-static See gh-25509 --- .../json/AbstractJackson2HttpMessageConverter.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/http/converter/json/AbstractJackson2HttpMessageConverter.java b/spring-web/src/main/java/org/springframework/http/converter/json/AbstractJackson2HttpMessageConverter.java index 78ca9fb8d31..9799165a5fe 100644 --- a/spring-web/src/main/java/org/springframework/http/converter/json/AbstractJackson2HttpMessageConverter.java +++ b/spring-web/src/main/java/org/springframework/http/converter/json/AbstractJackson2HttpMessageConverter.java @@ -286,14 +286,14 @@ public abstract class AbstractJackson2HttpMessageConverter extends AbstractGener } /** - * Return the charset to use for JSON input. + * Determine the charset to use for JSON input. *

By default this is either the charset from the input {@code MediaType} - * or otherwise falling back on {@code UTF-8}. + * or otherwise falling back on {@code UTF-8}. Can be overridden in subclasses. * @param contentType the content type of the HTTP input message * @return the charset to use * @since 5.1.18 */ - protected static Charset getCharset(@Nullable MediaType contentType) { + protected Charset getCharset(@Nullable MediaType contentType) { if (contentType != null && contentType.getCharset() != null) { return contentType.getCharset(); } From c6cc6705ef21f01be046374fd90c4d62567d1b73 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Tue, 8 Sep 2020 12:23:27 +0200 Subject: [PATCH 2/2] FileUrlResource.isWritable() exclusively relies on getFile() implementation Closes gh-25584 --- .../org/springframework/core/io/FileUrlResource.java | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/core/io/FileUrlResource.java b/spring-core/src/main/java/org/springframework/core/io/FileUrlResource.java index 4e1b0fa8093..b910bbc9165 100644 --- a/spring-core/src/main/java/org/springframework/core/io/FileUrlResource.java +++ b/spring-core/src/main/java/org/springframework/core/io/FileUrlResource.java @@ -89,15 +89,8 @@ public class FileUrlResource extends UrlResource implements WritableResource { @Override public boolean isWritable() { try { - URL url = getURL(); - if (ResourceUtils.isFileURL(url)) { - // Proceed with file system resolution - File file = getFile(); - return (file.canWrite() && !file.isDirectory()); - } - else { - return true; - } + File file = getFile(); + return (file.canWrite() && !file.isDirectory()); } catch (IOException ex) { return false;