This commit is contained in:
Phillip Webb
2016-04-24 22:29:38 -07:00
parent d10d819ca5
commit 79922360e1
5 changed files with 30 additions and 24 deletions

View File

@@ -62,27 +62,26 @@ public class FlywayEndpoint extends AbstractEndpoint<List<FlywayMigration>> {
*/
public static class FlywayMigration {
private MigrationType type;
private final MigrationType type;
private Integer checksum;
private final Integer checksum;
private String version;
private final String version;
private String description;
private final String description;
private String script;
private final String script;
private MigrationState state;
private final MigrationState state;
private Date installedOn;
private final Date installedOn;
private Integer executionTime;
private final Integer executionTime;
public FlywayMigration(MigrationInfo info) {
this.type = info.getType();
this.checksum = info.getChecksum();
this.version = info.getVersion() != null ? info.getVersion().toString()
: null;
this.version = nullSafeToString(info.getVersion());
this.description = info.getDescription();
this.script = info.getScript();
this.state = info.getState();
@@ -90,6 +89,10 @@ public class FlywayEndpoint extends AbstractEndpoint<List<FlywayMigration>> {
this.executionTime = info.getExecutionTime();
}
private String nullSafeToString(Object obj) {
return (obj == null ? null : obj.toString());
}
public MigrationType getType() {
return this.type;
}

View File

@@ -35,6 +35,14 @@ import org.springframework.context.ConfigurableApplicationContext;
public class ShutdownEndpoint extends AbstractEndpoint<Map<String, Object>>
implements ApplicationContextAware {
private static final Map<String, Object> NO_CONTEXT_MESSAGE = Collections
.unmodifiableMap(Collections.<String, Object>singletonMap("message",
"No context to shutdown."));
private static final Map<String, Object> SHUTDOWN_MESSAGE = Collections
.unmodifiableMap(Collections.<String, Object>singletonMap("message",
"Shutting down, bye..."));
private ConfigurableApplicationContext context;
/**
@@ -46,19 +54,15 @@ public class ShutdownEndpoint extends AbstractEndpoint<Map<String, Object>>
@Override
public Map<String, Object> invoke() {
if (this.context == null) {
return Collections.<String, Object>singletonMap("message",
"No context to shutdown.");
return NO_CONTEXT_MESSAGE;
}
try {
return Collections.<String, Object>singletonMap("message",
"Shutting down, bye...");
return SHUTDOWN_MESSAGE;
}
finally {
new Thread(new Runnable() {
@Override
public void run() {
try {
@@ -69,8 +73,8 @@ public class ShutdownEndpoint extends AbstractEndpoint<Map<String, Object>>
}
ShutdownEndpoint.this.context.close();
}
}).start();
}).start();
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2015 the original author or authors.
* Copyright 2012-2016 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.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2015 the original author or authors.
* Copyright 2012-2016 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.

View File

@@ -32,10 +32,9 @@ class DataSourceBeanCreationFailureAnalyzer
@Override
protected FailureAnalysis analyze(Throwable rootFailure,
DataSourceBeanCreationException cause) {
String description = cause.getMessage()
.substring(0, cause.getMessage().indexOf(".")).trim();
String action = cause.getMessage().substring(cause.getMessage().indexOf(".") + 1)
.trim();
String message = cause.getMessage();
String description = message.substring(0, message.indexOf(".")).trim();
String action = message.substring(message.indexOf(".") + 1).trim();
return new FailureAnalysis(description, action, cause);
}