diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/BatchProperties.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/BatchProperties.java index 998098416d..bf5547472c 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/BatchProperties.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/BatchProperties.java @@ -16,9 +16,7 @@ package org.springframework.boot.autoconfigure.batch; -import org.springframework.boot.autoconfigure.transaction.TransactionProperties; import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.boot.context.properties.NestedConfigurationProperty; /** * Configuration properties for Spring Batch. @@ -48,9 +46,6 @@ public class BatchProperties { private final Job job = new Job(); - @NestedConfigurationProperty - private final TransactionProperties transaction = new TransactionProperties(); - public String getSchema() { return this.schema; } @@ -75,10 +70,6 @@ public class BatchProperties { return this.job; } - public TransactionProperties getTransaction() { - return this.transaction; - } - public class Initializer { /** diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/neo4j/Neo4jProperties.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/neo4j/Neo4jProperties.java index 030b69cee6..e58bda102b 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/neo4j/Neo4jProperties.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/neo4j/Neo4jProperties.java @@ -23,9 +23,7 @@ import org.neo4j.ogm.config.Configuration; import org.neo4j.ogm.config.DriverConfiguration; import org.springframework.beans.BeansException; -import org.springframework.boot.autoconfigure.transaction.TransactionProperties; import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.boot.context.properties.NestedConfigurationProperty; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; import org.springframework.util.ClassUtils; @@ -71,9 +69,6 @@ public class Neo4jProperties implements ApplicationContextAware { private final Embedded embedded = new Embedded(); - @NestedConfigurationProperty - private final TransactionProperties transaction = new TransactionProperties(); - private ClassLoader classLoader = Neo4jProperties.class.getClassLoader(); public String getUri() { @@ -112,10 +107,6 @@ public class Neo4jProperties implements ApplicationContextAware { return this.embedded; } - public TransactionProperties getTransaction() { - return this.transaction; - } - @Override public void setApplicationContext(ApplicationContext ctx) throws BeansException { this.classLoader = ctx.getClassLoader(); diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/transaction/TransactionManagerCustomizers.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/transaction/TransactionManagerCustomizers.java index e44502775a..8a79946283 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/transaction/TransactionManagerCustomizers.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/transaction/TransactionManagerCustomizers.java @@ -20,6 +20,9 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + import org.springframework.core.ResolvableType; import org.springframework.transaction.PlatformTransactionManager; @@ -31,6 +34,9 @@ import org.springframework.transaction.PlatformTransactionManager; */ public class TransactionManagerCustomizers { + private static final Log logger = LogFactory + .getLog(TransactionManagerCustomizers.class); + private final List> customizers; public TransactionManagerCustomizers( @@ -56,7 +62,17 @@ public class TransactionManagerCustomizers { @SuppressWarnings({ "unchecked", "rawtypes" }) private void customize(PlatformTransactionManager transactionManager, PlatformTransactionManagerCustomizer customizer) { - customizer.customize(transactionManager); + try { + customizer.customize(transactionManager); + } + catch (ClassCastException ex) { + // Possibly a lambda-defined listener which we could not resolve the generic + // event type for + if (logger.isDebugEnabled()) { + logger.debug("Non-matching transaction manager type for customizer: " + + customizer, ex); + } + } } } diff --git a/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/java/org/springframework/boot/launchscript/SysVinitLaunchScriptIT.java b/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/java/org/springframework/boot/launchscript/SysVinitLaunchScriptIT.java index 2ad08cac5b..57f44a7646 100644 --- a/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/java/org/springframework/boot/launchscript/SysVinitLaunchScriptIT.java +++ b/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/java/org/springframework/boot/launchscript/SysVinitLaunchScriptIT.java @@ -118,6 +118,14 @@ public class SysVinitLaunchScriptIT { .has(coloredString(AnsiColor.YELLOW, "Not running (pidfile not found)")); } + @Test + public void forceStopWhenStopped() throws Exception { + String output = doTest("force-stop-when-stopped.sh"); + assertThat(output).contains("Status: 0"); + assertThat(output) + .has(coloredString(AnsiColor.YELLOW, "Not running (pidfile not found)")); + } + @Test public void startWhenStarted() throws Exception { String output = doTest("start-when-started.sh"); diff --git a/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/force-stop-when-stopped.sh b/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/force-stop-when-stopped.sh new file mode 100644 index 0000000000..465b555329 --- /dev/null +++ b/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/force-stop-when-stopped.sh @@ -0,0 +1,4 @@ +source ./test-functions.sh +install_service +force_stop_service +echo "Status: $?" diff --git a/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/test-functions.sh b/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/test-functions.sh index aab41ca0f3..c1734c757b 100644 --- a/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/test-functions.sh +++ b/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/test-functions.sh @@ -21,6 +21,10 @@ stop_service() { service spring-boot-app stop } +force_stop_service() { + service spring-boot-app force-stop +} + await_app() { if [ -z $1 ] then diff --git a/spring-boot-tools/spring-boot-loader-tools/src/main/resources/org/springframework/boot/loader/tools/launch.script b/spring-boot-tools/spring-boot-loader-tools/src/main/resources/org/springframework/boot/loader/tools/launch.script index feb9f538a7..cba5329854 100755 --- a/spring-boot-tools/spring-boot-loader-tools/src/main/resources/org/springframework/boot/loader/tools/launch.script +++ b/spring-boot-tools/spring-boot-loader-tools/src/main/resources/org/springframework/boot/loader/tools/launch.script @@ -203,6 +203,24 @@ do_stop() { return 1; } +force_stop() { + [[ -f $pid_file ]] || { echoYellow "Not running (pidfile not found)"; return 0; } + pid=$(cat "$pid_file") + isRunning "$pid" || { echoYellow "Not running (process ${pid}). Removing stale pid file."; rm -f "$pid_file"; return 0; } + do_force_stop "$pid" "$pid_file" +} + +do_force_stop() { + kill -9 "$1" &> /dev/null || { echoRed "Unable to kill process $1"; return 1; } + for i in $(seq 1 60); do + isRunning "$1" || { echoGreen "Stopped [$1]"; rm -f "$2"; return 0; } + [[ $i -eq 30 ]] && kill -9 "$1" &> /dev/null + sleep 1 + done + echoRed "Unable to kill process $1"; + return 1; +} + restart() { stop && start } @@ -242,6 +260,8 @@ start) start "$@"; exit $?;; stop) stop "$@"; exit $?;; +force-stop) + force_stop "$@"; exit $?;; restart) restart "$@"; exit $?;; force-reload)