pull/7164/head
Phillip Webb 8 years ago
parent d3e06c4627
commit d818a09ed8

@ -115,6 +115,7 @@ import org.springframework.util.StringUtils;
* @author Christian Dupuis
* @author Matt Benson
* @see ShellProperties
* @deprecated as of 1.5
*/
@Configuration
@ConditionalOnClass(PluginLifeCycle.class)

@ -38,6 +38,7 @@ import org.springframework.util.StringUtils;
* @author Phillip Webb
* @author Eddú Meléndez
* @author Stephane Nicoll
* @deprecated as of 1.5
*/
@ConfigurationProperties(prefix = ShellProperties.SHELL_PREFIX, ignoreUnknownFields = true)
@Deprecated

@ -89,14 +89,13 @@ public class AutoConfigurationReportEndpoint extends AbstractEndpoint<Report> {
add(this.negativeMatches, entry.getKey(), entry.getValue());
}
}
this.parent = report.getParent() != null ? new Report(report.getParent())
: null;
boolean hasParent = report.getParent() != null;
this.parent = (hasParent ? new Report(report.getParent()) : null);
}
private void add(Map<String, MessageAndConditions> map, String source,
ConditionAndOutcomes conditionAndOutcomes) {
String name = ClassUtils.getShortName(source);
map.put(name, new MessageAndConditions(conditionAndOutcomes));
}

@ -42,7 +42,8 @@ public abstract class AbstractDatabaseInitializer {
private final ResourceLoader resourceLoader;
protected AbstractDatabaseInitializer(DataSource dataSource, ResourceLoader resourceLoader) {
protected AbstractDatabaseInitializer(DataSource dataSource,
ResourceLoader resourceLoader) {
Assert.notNull(dataSource, "DataSource must not be null");
Assert.notNull(resourceLoader, "ResourceLoader must not be null");
this.dataSource = dataSource;
@ -51,17 +52,18 @@ public abstract class AbstractDatabaseInitializer {
@PostConstruct
protected void initialize() {
if (isEnabled()) {
ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
String schemaLocation = getSchemaLocation();
if (schemaLocation.contains(PLATFORM_PLACEHOLDER)) {
String platform = getDatabaseName();
schemaLocation = schemaLocation.replace(PLATFORM_PLACEHOLDER, platform);
}
populator.addScript(this.resourceLoader.getResource(schemaLocation));
populator.setContinueOnError(true);
DatabasePopulatorUtils.execute(populator, this.dataSource);
if (!isEnabled()) {
return;
}
ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
String schemaLocation = getSchemaLocation();
if (schemaLocation.contains(PLATFORM_PLACEHOLDER)) {
String platform = getDatabaseName();
schemaLocation = schemaLocation.replace(PLATFORM_PLACEHOLDER, platform);
}
populator.addScript(this.resourceLoader.getResource(schemaLocation));
populator.setContinueOnError(true);
DatabasePopulatorUtils.execute(populator, this.dataSource);
}
protected abstract boolean isEnabled();
@ -70,11 +72,10 @@ public abstract class AbstractDatabaseInitializer {
protected String getDatabaseName() {
try {
String databaseProductName = JdbcUtils.extractDatabaseMetaData(
this.dataSource, "getDatabaseProductName").toString();
databaseProductName = JdbcUtils.commonDatabaseName(databaseProductName);
DatabaseDriver databaseDriver = DatabaseDriver.fromProductName(
databaseProductName);
String productName = JdbcUtils.commonDatabaseName(JdbcUtils
.extractDatabaseMetaData(this.dataSource, "getDatabaseProductName")
.toString());
DatabaseDriver databaseDriver = DatabaseDriver.fromProductName(productName);
if (databaseDriver == DatabaseDriver.UNKNOWN) {
throw new IllegalStateException("Unable to detect database type");
}

@ -32,8 +32,8 @@ public class BatchDatabaseInitializer extends AbstractDatabaseInitializer {
private final BatchProperties properties;
public BatchDatabaseInitializer(DataSource dataSource,
ResourceLoader resourceLoader, BatchProperties properties) {
public BatchDatabaseInitializer(DataSource dataSource, ResourceLoader resourceLoader,
BatchProperties properties) {
super(dataSource, resourceLoader);
Assert.notNull(properties, "BatchProperties must not be null");
this.properties = properties;

@ -65,8 +65,7 @@ public class RepositoryRestProperties {
/**
* Strategy to use to determine which repositories get exposed.
*/
private RepositoryDetectionStrategies detectionStrategy =
RepositoryDetectionStrategies.DEFAULT;
private RepositoryDetectionStrategies detectionStrategy = RepositoryDetectionStrategies.DEFAULT;
/**
* Content type to use as a default when none is specified.

@ -44,7 +44,7 @@ public class DataSourceBuilder {
private static final String[] DATA_SOURCE_TYPE_NAMES = new String[] {
"org.apache.tomcat.jdbc.pool.DataSource",
"com.zaxxer.hikari.HikariDataSource",
"org.apache.commons.dbcp.BasicDataSource", //deprecated
"org.apache.commons.dbcp.BasicDataSource", // deprecated
"org.apache.commons.dbcp2.BasicDataSource" };
private Class<? extends DataSource> type;

@ -41,7 +41,7 @@ import org.springframework.jms.support.destination.DestinationResolver;
* @author Stephane Nicoll
*/
@Configuration
@ConditionalOnClass({Message.class, JmsTemplate.class})
@ConditionalOnClass({ Message.class, JmsTemplate.class })
@ConditionalOnBean(ConnectionFactory.class)
@EnableConfigurationProperties(JmsProperties.class)
@Import(JmsAnnotationDrivenConfiguration.class)

@ -135,8 +135,8 @@ public class JmsProperties {
public static class Template {
/**
* Default destination to use on send/receive operations that do not
* have a destination parameter.
* Default destination to use on send/receive operations that do not have a
* destination parameter.
*/
private String defaultDestination;
@ -156,16 +156,14 @@ public class JmsProperties {
private Integer priority;
/**
* Time-to-live of a message when sending in milliseconds. Enable
* QoS when set.
* Time-to-live of a message when sending in milliseconds. Enable QoS when set.
*/
private Long timeToLive;
/**
* Enable explicit QoS when sending a message. When enabled, the
* delivery mode, priority and time-to-live properties will be
* used when sending a message. QoS is automatically enabled when
* at least one of those settings is customized.
* Enable explicit QoS when sending a message. When enabled, the delivery mode,
* priority and time-to-live properties will be used when sending a message. QoS
* is automatically enabled when at least one of those settings is customized.
*/
private Boolean qosEnabled;
@ -291,8 +289,8 @@ public class JmsProperties {
NON_PERSISTENT(1),
/*
* Instructs the JMS provider to log the message to stable storage as part of
* the client's send operation.
* Instructs the JMS provider to log the message to stable storage as part of the
* client's send operation.
*/
PERSISTENT(2);

@ -658,15 +658,15 @@ public class ServerProperties
private Charset uriEncoding;
/**
* Maximum number of connections that the server will accept and process
* at any given time. Once the limit has been reached, the operating system
* may still accept connections based on the "acceptCount" property.
* Maximum number of connections that the server will accept and process at any
* given time. Once the limit has been reached, the operating system may still
* accept connections based on the "acceptCount" property.
*/
private int maxConnections = 0;
/**
* Maximum queue length for incoming connection requests when all possible
* request processing threads are in use.
* Maximum queue length for incoming connection requests when all possible request
* processing threads are in use.
*/
private int acceptCount = 0;
@ -827,34 +827,37 @@ public class ServerProperties
public void customize(Connector connector) {
ProtocolHandler handler = connector.getProtocolHandler();
if (handler instanceof AbstractProtocol) {
AbstractProtocol protocol = (AbstractProtocol) handler;
AbstractProtocol<?> protocol = (AbstractProtocol<?>) handler;
protocol.setBacklog(Tomcat.this.acceptCount);
}
}
});
}
private void customizeMaxConnections(TomcatEmbeddedServletContainerFactory factory) {
private void customizeMaxConnections(
TomcatEmbeddedServletContainerFactory factory) {
factory.addConnectorCustomizers(new TomcatConnectorCustomizer() {
@Override
public void customize(Connector connector) {
ProtocolHandler handler = connector.getProtocolHandler();
if (handler instanceof AbstractProtocol) {
AbstractProtocol protocol = (AbstractProtocol) handler;
AbstractProtocol<?> protocol = (AbstractProtocol<?>) handler;
protocol.setMaxConnections(Tomcat.this.maxConnections);
}
}
});
}
private void customizeConnectionTimeout(
TomcatEmbeddedServletContainerFactory factory, int connectionTimeout) {
for (Connector connector : factory.getAdditionalTomcatConnectors()) {
if (connector.getProtocolHandler() instanceof AbstractProtocol) {
AbstractProtocol<?> handler = (AbstractProtocol<?>) connector
.getProtocolHandler();
handler.setConnectionTimeout(connectionTimeout);
ProtocolHandler handler = connector.getProtocolHandler();
if (handler instanceof AbstractProtocol) {
AbstractProtocol<?> protocol = (AbstractProtocol<?>) handler;
protocol.setConnectionTimeout(connectionTimeout);
}
}
}
@ -1108,6 +1111,7 @@ public class ServerProperties
JettyEmbeddedServletContainerFactory factory,
final int connectionTimeout) {
factory.addServerCustomizers(new JettyServerCustomizer() {
@Override
public void customize(Server server) {
for (org.eclipse.jetty.server.Connector connector : server
@ -1118,6 +1122,7 @@ public class ServerProperties
}
}
}
});
}

@ -19,7 +19,6 @@ package org.springframework.boot.autoconfigure.data.cassandra;
import java.util.Set;
import com.datastax.driver.core.Session;
import org.junit.After;
import org.junit.Test;

@ -191,7 +191,8 @@ public class NoSuchBeanDefinitionFailureAnalyzerTests {
private void assertClassDisabled(FailureAnalysis analysis, String description,
String methodName) {
String expected = String.format("Bean method '%s' not loaded because", methodName);
String expected = String.format("Bean method '%s' not loaded because",
methodName);
assertThat(analysis.getDescription()).contains(expected);
assertThat(analysis.getDescription()).contains(description);
}

@ -141,8 +141,8 @@ public class DataSourceAutoConfigurationTests {
@Deprecated
public void commonsDbcpIsFallback() throws Exception {
org.apache.commons.dbcp.BasicDataSource dataSource = autoConfigureDataSource(
org.apache.commons.dbcp.BasicDataSource.class,
"org.apache.tomcat", "com.zaxxer.hikari");
org.apache.commons.dbcp.BasicDataSource.class, "org.apache.tomcat",
"com.zaxxer.hikari");
assertThat(dataSource.getUrl()).isEqualTo("jdbc:hsqldb:mem:testdb");
}
@ -150,8 +150,8 @@ public class DataSourceAutoConfigurationTests {
@Deprecated
public void commonsDbcpValidatesConnectionByDefault() {
org.apache.commons.dbcp.BasicDataSource dataSource = autoConfigureDataSource(
org.apache.commons.dbcp.BasicDataSource.class,
"org.apache.tomcat", "com.zaxxer.hikari");
org.apache.commons.dbcp.BasicDataSource.class, "org.apache.tomcat",
"com.zaxxer.hikari");
assertThat(dataSource.getTestOnBorrow()).isTrue();
assertThat(dataSource.getValidationQuery())
.isEqualTo(DatabaseDriver.HSQLDB.getValidationQuery());

@ -259,8 +259,7 @@ public class JmsAutoConfigurationTests {
"spring.jms.template.default-destination=testQueue",
"spring.jms.template.delivery-delay=500",
"spring.jms.template.delivery-mode=non-persistent",
"spring.jms.template.priority=6",
"spring.jms.template.time-to-live=6000",
"spring.jms.template.priority=6", "spring.jms.template.time-to-live=6000",
"spring.jms.template.receive-timeout=2000");
JmsTemplate jmsTemplate = this.context.getBean(JmsTemplate.class);
assertThat(jmsTemplate.getMessageConverter())

@ -444,9 +444,9 @@ public class ServerPropertiesTests {
TomcatEmbeddedServletContainerFactory container = new TomcatEmbeddedServletContainerFactory();
this.properties.customize(container);
TomcatEmbeddedServletContainer embeddedContainer =
(TomcatEmbeddedServletContainer) container.getEmbeddedServletContainer();
assertThat(((AbstractProtocol) embeddedContainer.getTomcat().getConnector()
TomcatEmbeddedServletContainer embeddedContainer = (TomcatEmbeddedServletContainer) container
.getEmbeddedServletContainer();
assertThat(((AbstractProtocol<?>) embeddedContainer.getTomcat().getConnector()
.getProtocolHandler()).getBacklog()).isEqualTo(10);
}
@ -458,9 +458,9 @@ public class ServerPropertiesTests {
TomcatEmbeddedServletContainerFactory container = new TomcatEmbeddedServletContainerFactory();
this.properties.customize(container);
TomcatEmbeddedServletContainer embeddedContainer =
(TomcatEmbeddedServletContainer) container.getEmbeddedServletContainer();
assertThat(((AbstractProtocol) embeddedContainer.getTomcat().getConnector()
TomcatEmbeddedServletContainer embeddedContainer = (TomcatEmbeddedServletContainer) container
.getEmbeddedServletContainer();
assertThat(((AbstractProtocol<?>) embeddedContainer.getTomcat().getConnector()
.getProtocolHandler()).getMaxConnections()).isEqualTo(5);
}

@ -56,8 +56,7 @@ public class WarCommandIT {
assertThat(invocation.getOutput()).contains("Tomcat started");
assertThat(invocation.getOutput())
.contains("/WEB-INF/lib-provided/tomcat-embed-core");
assertThat(invocation.getOutput())
.contains("WEB-INF/classes!/root.properties");
assertThat(invocation.getOutput()).contains("WEB-INF/classes!/root.properties");
process.destroy();
}

@ -289,10 +289,9 @@ abstract class ArchiveCommand extends OptionParsingCommand {
return libraries;
}
protected void writeClasspathEntry(JarWriter writer,
MatchedResource entry) throws IOException {
writer.writeEntry(entry.getName(),
new FileInputStream(entry.getFile()));
protected void writeClasspathEntry(JarWriter writer, MatchedResource entry)
throws IOException {
writer.writeEntry(entry.getName(), new FileInputStream(entry.getFile()));
}
protected abstract LibraryScope getLibraryScope(File file);

@ -18,7 +18,6 @@ package sample.hibernate52.service;
import org.junit.Test;
import org.junit.runner.RunWith;
import sample.hibernate52.domain.City;
import sample.hibernate52.service.CityRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

@ -24,8 +24,6 @@ import sample.hibernate52.domain.Hotel;
import sample.hibernate52.domain.HotelSummary;
import sample.hibernate52.domain.Rating;
import sample.hibernate52.domain.RatingCount;
import sample.hibernate52.service.CityRepository;
import sample.hibernate52.service.HotelRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

@ -23,7 +23,6 @@ import org.hamcrest.TypeSafeMatcher;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import sample.web.thymeleaf3.SampleWebThymeleaf3Application;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;

@ -29,7 +29,7 @@ import org.springframework.context.annotation.Configuration;
* the starter.
*
* @author Stephane Nicoll
* @since 1.4.0
* @since 1.5.0
*/
@Configuration
@Deprecated
@ -40,10 +40,8 @@ public class RemoteShellStarterDeprecatedWarningAutoConfiguration {
@PostConstruct
public void logWarning() {
logger.warn("spring-boot-starter-remote-shell is deprecated since Spring Boot " +
"1.5 and will be removed in Spring Boot 2.0");
logger.warn("spring-boot-starter-remote-shell is deprecated since Spring Boot "
+ "1.5 and will be removed in Spring Boot 2.0");
}
}

@ -42,7 +42,6 @@ import org.springframework.boot.configurationsample.lombok.LombokInnerClassPrope
import org.springframework.boot.configurationsample.lombok.LombokSimpleDataProperties;
import org.springframework.boot.configurationsample.lombok.LombokSimpleProperties;
import org.springframework.boot.configurationsample.lombok.SimpleLombokPojo;
import org.springframework.boot.configurationsample.method.DeprecatedClassMethodConfig;
import org.springframework.boot.configurationsample.method.DeprecatedMethodConfig;
import org.springframework.boot.configurationsample.method.EmptyTypeMethodConfig;
import org.springframework.boot.configurationsample.method.InvalidMethodConfig;
@ -290,8 +289,7 @@ public class ConfigurationMetadataAnnotationProcessorTests {
public void deprecatedMethodConfig() throws Exception {
Class<DeprecatedMethodConfig> type = DeprecatedMethodConfig.class;
ConfigurationMetadata metadata = compile(type);
assertThat(metadata)
.has(Metadata.withGroup("foo").fromSource(type));
assertThat(metadata).has(Metadata.withGroup("foo").fromSource(type));
assertThat(metadata).has(Metadata.withProperty("foo.name", String.class)
.fromSource(DeprecatedMethodConfig.Foo.class)
.withDeprecation(null, null));
@ -301,16 +299,18 @@ public class ConfigurationMetadataAnnotationProcessorTests {
}
@Test
@SuppressWarnings("deprecation")
public void deprecatedMethodConfigOnClass() throws Exception {
Class<DeprecatedClassMethodConfig> type = DeprecatedClassMethodConfig.class;
Class<?> type = org.springframework.boot.configurationsample.method.DeprecatedClassMethodConfig.class;
ConfigurationMetadata metadata = compile(type);
assertThat(metadata)
.has(Metadata.withGroup("foo").fromSource(type));
assertThat(metadata).has(Metadata.withGroup("foo").fromSource(type));
assertThat(metadata).has(Metadata.withProperty("foo.name", String.class)
.fromSource(DeprecatedClassMethodConfig.Foo.class)
.fromSource(
org.springframework.boot.configurationsample.method.DeprecatedClassMethodConfig.Foo.class)
.withDeprecation(null, null));
assertThat(metadata).has(Metadata.withProperty("foo.flag", Boolean.class)
.fromSource(DeprecatedClassMethodConfig.Foo.class)
.fromSource(
org.springframework.boot.configurationsample.method.DeprecatedClassMethodConfig.Foo.class)
.withDeprecation(null, null));
}

@ -52,6 +52,7 @@ public class DeprecatedClassMethodConfig {
public void setFlag(boolean flag) {
this.flag = flag;
}
}
}

@ -51,23 +51,23 @@ public class RunProcess {
private volatile long endTime;
/**
* Creates new {@link RunProcess} instance for the specified command
* and working directory.
* @param workingDirectory the working directory of the child process or {@code null}
* to run in the working directory of the current Java process
* Creates new {@link RunProcess} instance for the specified command.
* @param command the program to execute and it's arguments
*/
public RunProcess(File workingDirectory, String... command) {
this.workingDirectory = workingDirectory;
this.command = command;
public RunProcess(String... command) {
this(null, command);
}
/**
* Creates new {@link RunProcess} instance for the specified command.
* Creates new {@link RunProcess} instance for the specified working directory and
* command.
* @param workingDirectory the working directory of the child process or {@code null}
* to run in the working directory of the current Java process
* @param command the program to execute and it's arguments
*/
public RunProcess(String... command) {
this(null, command);
public RunProcess(File workingDirectory, String... command) {
this.workingDirectory = workingDirectory;
this.command = command;
}
public int run(boolean waitForProcess, String... args) throws IOException {

@ -149,8 +149,8 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo {
/**
* Flag to indicate if the run processes should be forked. {@code fork} is
* automatically enabled if an agent, jvmArguments or working directory are
* specified, or if devtools is present.
* automatically enabled if an agent, jvmArguments or working directory are specified,
* or if devtools is present.
* @since 1.2
*/
@Parameter(property = "fork")
@ -206,7 +206,7 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo {
}
private boolean hasWorkingDirectorySet() {
return (this.workingDirectory != null);
return this.workingDirectory != null;
}
private void findAgent() {

@ -64,9 +64,11 @@ public class RunMojo extends AbstractRunMojo {
}
@Override
protected void runWithForkedJvm(File workingDirectory, List<String> args) throws MojoExecutionException {
protected void runWithForkedJvm(File workingDirectory, List<String> args)
throws MojoExecutionException {
try {
RunProcess runProcess = new RunProcess(workingDirectory, new JavaExecutable().toString());
RunProcess runProcess = new RunProcess(workingDirectory,
new JavaExecutable().toString());
Runtime.getRuntime()
.addShutdownHook(new Thread(new RunProcessKiller(runProcess)));
int exitCode = runProcess.run(true, args.toArray(new String[args.size()]));

@ -30,9 +30,9 @@ import org.springframework.context.annotation.Configuration;
* standard {@code @Configuration} annotation so that configuration can be found
* automatically (for example in tests).
* <p>
* Application should only ever include <em>one</em>
* {@code @SpringBootConfiguration} and most idiomatic Spring Boot applications
* will inherit it from {@code @SpringBootApplication}.
* Application should only ever include <em>one</em> {@code @SpringBootConfiguration} and
* most idiomatic Spring Boot applications will inherit it from
* {@code @SpringBootApplication}.
*
* @author Phillip Webb
* @since 1.4.0

Loading…
Cancel
Save