diff --git a/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassPostProcessor.java b/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassPostProcessor.java index 496136f158..339638eba8 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassPostProcessor.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassPostProcessor.java @@ -285,7 +285,7 @@ public class ConfigurationClassPostProcessor implements BeanDefinitionRegistryPo configCandidates.sort((bd1, bd2) -> { int i1 = ConfigurationClassUtils.getOrder(bd1.getBeanDefinition()); int i2 = ConfigurationClassUtils.getOrder(bd2.getBeanDefinition()); - return (i1 < i2) ? -1 : (i1 > i2) ? 1 : 0; + return Integer.compare(i1, i2); }); // Detect any custom bean name generation strategy supplied through the enclosing application context 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 b123d9d8c0..8444672bcd 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-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. @@ -165,9 +165,9 @@ public abstract class ScriptUtils { * @param statements the list that will contain the individual statements * @throws ScriptException if an error occurred while splitting the SQL script */ - public static void splitSqlScript(@Nullable EncodedResource resource, String script, String separator, String commentPrefix, - String blockCommentStartDelimiter, String blockCommentEndDelimiter, List statements) - throws ScriptException { + public static void splitSqlScript(@Nullable EncodedResource resource, String script, + String separator, String commentPrefix, 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"); @@ -179,6 +179,7 @@ public abstract class ScriptUtils { boolean inSingleQuote = false; boolean inDoubleQuote = false; boolean inEscape = false; + for (int i = 0; i < script.length(); i++) { char c = script.charAt(i); if (inEscape) { @@ -244,6 +245,7 @@ public abstract class ScriptUtils { } sb.append(c); } + if (StringUtils.hasText(sb)) { statements.add(sb.toString()); }