Commit 79922360 authored by Phillip Webb's avatar Phillip Webb

Polish

parent d10d819c
...@@ -62,27 +62,26 @@ public class FlywayEndpoint extends AbstractEndpoint<List<FlywayMigration>> { ...@@ -62,27 +62,26 @@ public class FlywayEndpoint extends AbstractEndpoint<List<FlywayMigration>> {
*/ */
public static class 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) { public FlywayMigration(MigrationInfo info) {
this.type = info.getType(); this.type = info.getType();
this.checksum = info.getChecksum(); this.checksum = info.getChecksum();
this.version = info.getVersion() != null ? info.getVersion().toString() this.version = nullSafeToString(info.getVersion());
: null;
this.description = info.getDescription(); this.description = info.getDescription();
this.script = info.getScript(); this.script = info.getScript();
this.state = info.getState(); this.state = info.getState();
...@@ -90,6 +89,10 @@ public class FlywayEndpoint extends AbstractEndpoint<List<FlywayMigration>> { ...@@ -90,6 +89,10 @@ public class FlywayEndpoint extends AbstractEndpoint<List<FlywayMigration>> {
this.executionTime = info.getExecutionTime(); this.executionTime = info.getExecutionTime();
} }
private String nullSafeToString(Object obj) {
return (obj == null ? null : obj.toString());
}
public MigrationType getType() { public MigrationType getType() {
return this.type; return this.type;
} }
......
...@@ -35,6 +35,14 @@ import org.springframework.context.ConfigurableApplicationContext; ...@@ -35,6 +35,14 @@ import org.springframework.context.ConfigurableApplicationContext;
public class ShutdownEndpoint extends AbstractEndpoint<Map<String, Object>> public class ShutdownEndpoint extends AbstractEndpoint<Map<String, Object>>
implements ApplicationContextAware { 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; private ConfigurableApplicationContext context;
/** /**
...@@ -46,19 +54,15 @@ public class ShutdownEndpoint extends AbstractEndpoint<Map<String, Object>> ...@@ -46,19 +54,15 @@ public class ShutdownEndpoint extends AbstractEndpoint<Map<String, Object>>
@Override @Override
public Map<String, Object> invoke() { public Map<String, Object> invoke() {
if (this.context == null) { if (this.context == null) {
return Collections.<String, Object>singletonMap("message", return NO_CONTEXT_MESSAGE;
"No context to shutdown.");
} }
try { try {
return Collections.<String, Object>singletonMap("message", return SHUTDOWN_MESSAGE;
"Shutting down, bye...");
} }
finally { finally {
new Thread(new Runnable() { new Thread(new Runnable() {
@Override @Override
public void run() { public void run() {
try { try {
...@@ -69,8 +73,8 @@ public class ShutdownEndpoint extends AbstractEndpoint<Map<String, Object>> ...@@ -69,8 +73,8 @@ public class ShutdownEndpoint extends AbstractEndpoint<Map<String, Object>>
} }
ShutdownEndpoint.this.context.close(); ShutdownEndpoint.this.context.close();
} }
}).start();
}).start();
} }
} }
......
/* /*
* 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
......
/* /*
* 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
......
...@@ -32,10 +32,9 @@ class DataSourceBeanCreationFailureAnalyzer ...@@ -32,10 +32,9 @@ class DataSourceBeanCreationFailureAnalyzer
@Override @Override
protected FailureAnalysis analyze(Throwable rootFailure, protected FailureAnalysis analyze(Throwable rootFailure,
DataSourceBeanCreationException cause) { DataSourceBeanCreationException cause) {
String description = cause.getMessage() String message = cause.getMessage();
.substring(0, cause.getMessage().indexOf(".")).trim(); String description = message.substring(0, message.indexOf(".")).trim();
String action = cause.getMessage().substring(cause.getMessage().indexOf(".") + 1) String action = message.substring(message.indexOf(".") + 1).trim();
.trim();
return new FailureAnalysis(description, action, cause); return new FailureAnalysis(description, action, cause);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment