diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/init/ScriptUtils.java b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/init/ScriptUtils.java index 18190283c3..3c97dab059 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/init/ScriptUtils.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/init/ScriptUtils.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. @@ -168,11 +168,11 @@ public abstract class ScriptUtils { String blockCommentStartDelimiter, String blockCommentEndDelimiter, List statements) throws ScriptException { - Assert.hasText(script, "script must not be null or empty"); - Assert.notNull(separator, "separator must not be null"); - Assert.hasText(commentPrefix, "commentPrefix must not be null or empty"); - Assert.hasText(blockCommentStartDelimiter, "blockCommentStartDelimiter must not be null or empty"); - Assert.hasText(blockCommentEndDelimiter, "blockCommentEndDelimiter must not be null or empty"); + Assert.hasText(script, "'script' must not be null or empty"); + Assert.notNull(separator, "'separator' must not be null"); + Assert.hasText(commentPrefix, "'commentPrefix' must not be null or empty"); + Assert.hasText(blockCommentStartDelimiter, "'blockCommentStartDelimiter' must not be null or empty"); + Assert.hasText(blockCommentEndDelimiter, "'blockCommentEndDelimiter' must not be null or empty"); StringBuilder sb = new StringBuilder(); boolean inSingleQuote = false; diff --git a/spring-web/src/main/java/org/springframework/http/MediaTypeFactory.java b/spring-web/src/main/java/org/springframework/http/MediaTypeFactory.java index bc9ebecaba..b5ecdd59f7 100644 --- a/spring-web/src/main/java/org/springframework/http/MediaTypeFactory.java +++ b/spring-web/src/main/java/org/springframework/http/MediaTypeFactory.java @@ -43,11 +43,8 @@ public class MediaTypeFactory { private static final String MIME_TYPES_FILE_NAME = "/org/springframework/http/mime.types"; - private static final MultiValueMap fileExtensionToMediaTypes; + private static final MultiValueMap fileExtensionToMediaTypes = parseMimeTypes(); - static { - fileExtensionToMediaTypes = parseMimeTypes(); - } /** * Parse the {@code mime.types} file found in the resources. Format is: @@ -65,9 +62,7 @@ public class MediaTypeFactory { InputStream is = null; try { is = MediaTypeFactory.class.getResourceAsStream(MIME_TYPES_FILE_NAME); - BufferedReader reader = - new BufferedReader(new InputStreamReader(is, StandardCharsets.US_ASCII)); - + BufferedReader reader = new BufferedReader(new InputStreamReader(is, StandardCharsets.US_ASCII)); MultiValueMap result = new LinkedMultiValueMap<>(); String line; while ((line = reader.readLine()) != null) { @@ -76,7 +71,6 @@ public class MediaTypeFactory { } String[] tokens = StringUtils.tokenizeToStringArray(line, " \t\n\r\f"); MediaType mediaType = MediaType.parseMediaType(tokens[0]); - for (int i = 1; i < tokens.length; i++) { String fileExtension = tokens[i].toLowerCase(Locale.ENGLISH); result.add(fileExtension, mediaType);