Commit 29c3be35 authored by Phillip Webb's avatar Phillip Webb

Polish

parent 306c79f0
/* /*
* Copyright 2012-2017 the original author or authors. * Copyright 2012-2018 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.
......
...@@ -95,7 +95,7 @@ public class ControllerEndpointHandlerMapping extends RequestMappingHandlerMappi ...@@ -95,7 +95,7 @@ public class ControllerEndpointHandlerMapping extends RequestMappingHandlerMappi
ExposableControllerEndpoint endpoint, RequestMappingInfo mapping) { ExposableControllerEndpoint endpoint, RequestMappingInfo mapping) {
Set<PathPattern> patterns = mapping.getPatternsCondition().getPatterns(); Set<PathPattern> patterns = mapping.getPatternsCondition().getPatterns();
if (patterns.isEmpty()) { if (patterns.isEmpty()) {
patterns = new HashSet<PathPattern>( patterns = new HashSet<>(
Arrays.asList(getPathPatternParser().parse(""))); Arrays.asList(getPathPatternParser().parse("")));
} }
PathPattern[] endpointMappedPatterns = patterns.stream() PathPattern[] endpointMappedPatterns = patterns.stream()
......
...@@ -77,7 +77,7 @@ final class TraceableHttpServletRequest implements TraceableRequest { ...@@ -77,7 +77,7 @@ final class TraceableHttpServletRequest implements TraceableRequest {
} }
private List<String> toList(Enumeration<String> enumeration) { private List<String> toList(Enumeration<String> enumeration) {
List<String> list = new ArrayList<String>(); List<String> list = new ArrayList<>();
while (enumeration.hasMoreElements()) { while (enumeration.hasMoreElements()) {
list.add(enumeration.nextElement()); list.add(enumeration.nextElement());
} }
......
...@@ -358,8 +358,7 @@ public final class ConditionMessage { ...@@ -358,8 +358,7 @@ public final class ConditionMessage {
* @return a built {@link ConditionMessage} * @return a built {@link ConditionMessage}
*/ */
public ConditionMessage items(Style style, Object... items) { public ConditionMessage items(Style style, Object... items) {
return items(style, return items(style, items == null ? null : Arrays.asList(items));
items == null ? null : Arrays.asList(items));
} }
/** /**
......
/* /*
* Copyright 2012-2017 the original author or authors. * Copyright 2012-2018 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.
......
...@@ -250,11 +250,11 @@ public class SessionAutoConfiguration { ...@@ -250,11 +250,11 @@ public class SessionAutoConfiguration {
if (storeType != StoreType.NONE if (storeType != StoreType.NONE
&& this.sessionRepositoryProvider.getIfAvailable() == null) { && this.sessionRepositoryProvider.getIfAvailable() == null) {
if (storeType != null) { if (storeType != null) {
throw new SessionRepositoryUnavailableException("No session " throw new SessionRepositoryUnavailableException(
+ "repository could be auto-configured, check your " "No session repository could be auto-configured, check your "
+ "configuration (session store type is '" + "configuration (session store type is '"
+ storeType.name().toLowerCase(Locale.ENGLISH) + storeType.name().toLowerCase(Locale.ENGLISH) + "')",
+ "')", storeType); storeType);
} }
} }
} }
......
/* /*
* Copyright 2012-2017 the original author or authors. * Copyright 2012-2018 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.
......
...@@ -86,18 +86,14 @@ public class MessageSourceAutoConfigurationTests { ...@@ -86,18 +86,14 @@ public class MessageSourceAutoConfigurationTests {
@Test @Test
public void testCacheDurationNoUnit() { public void testCacheDurationNoUnit() {
this.contextRunner this.contextRunner.withPropertyValues("spring.messages.basename:test/messages",
.withPropertyValues("spring.messages.basename:test/messages", "spring.messages.cache-duration=10").run(assertCache(10 * 1000));
"spring.messages.cache-duration=10")
.run(assertCache(10 * 1000));
} }
@Test @Test
public void testCacheDurationWithUnit() { public void testCacheDurationWithUnit() {
this.contextRunner this.contextRunner.withPropertyValues("spring.messages.basename:test/messages",
.withPropertyValues("spring.messages.basename:test/messages", "spring.messages.cache-duration=1m").run(assertCache(60 * 1000));
"spring.messages.cache-duration=1m")
.run(assertCache(60 * 1000));
} }
private ContextConsumer<AssertableApplicationContext> assertCache(long expected) { private ContextConsumer<AssertableApplicationContext> assertCache(long expected) {
......
...@@ -47,7 +47,8 @@ public class RedisAutoConfigurationJedisTests { ...@@ -47,7 +47,8 @@ public class RedisAutoConfigurationJedisTests {
@Test @Test
public void testOverrideRedisConfiguration() { public void testOverrideRedisConfiguration() {
this.contextRunner.withPropertyValues("spring.redis.host:foo", "spring.redis.database:1") this.contextRunner
.withPropertyValues("spring.redis.host:foo", "spring.redis.database:1")
.run((context) -> { .run((context) -> {
JedisConnectionFactory cf = context JedisConnectionFactory cf = context
.getBean(JedisConnectionFactory.class); .getBean(JedisConnectionFactory.class);
...@@ -60,10 +61,12 @@ public class RedisAutoConfigurationJedisTests { ...@@ -60,10 +61,12 @@ public class RedisAutoConfigurationJedisTests {
@Test @Test
public void testCustomizeRedisConfiguration() { public void testCustomizeRedisConfiguration() {
this.contextRunner.withUserConfiguration(CustomConfiguration.class).run((context) -> { this.contextRunner.withUserConfiguration(CustomConfiguration.class)
JedisConnectionFactory cf = context.getBean(JedisConnectionFactory.class); .run((context) -> {
assertThat(cf.isUseSsl()).isTrue(); JedisConnectionFactory cf = context
}); .getBean(JedisConnectionFactory.class);
assertThat(cf.isUseSsl()).isTrue();
});
} }
@Test @Test
...@@ -99,7 +102,8 @@ public class RedisAutoConfigurationJedisTests { ...@@ -99,7 +102,8 @@ public class RedisAutoConfigurationJedisTests {
@Test @Test
public void testPasswordInUrlWithColon() { public void testPasswordInUrlWithColon() {
this.contextRunner.withPropertyValues("spring.redis.url:redis://:pass:word@example:33") this.contextRunner
.withPropertyValues("spring.redis.url:redis://:pass:word@example:33")
.run((context) -> { .run((context) -> {
assertThat( assertThat(
context.getBean(JedisConnectionFactory.class).getHostName()) context.getBean(JedisConnectionFactory.class).getHostName())
......
...@@ -72,8 +72,8 @@ public class MustacheAutoConfigurationReactiveIntegrationTests { ...@@ -72,8 +72,8 @@ public class MustacheAutoConfigurationReactiveIntegrationTests {
} }
@Configuration @Configuration
@Import({ ReactiveWebServerFactoryAutoConfiguration.class, WebFluxAutoConfiguration.class, @Import({ ReactiveWebServerFactoryAutoConfiguration.class,
HttpHandlerAutoConfiguration.class, WebFluxAutoConfiguration.class, HttpHandlerAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class }) PropertyPlaceholderAutoConfiguration.class })
@Controller @Controller
public static class Application { public static class Application {
......
...@@ -42,8 +42,7 @@ public class ReactiveWebServerFactoryCustomizerTests { ...@@ -42,8 +42,7 @@ public class ReactiveWebServerFactoryCustomizerTests {
@Before @Before
public void setup() { public void setup() {
this.customizer = new ReactiveWebServerFactoryCustomizer( this.customizer = new ReactiveWebServerFactoryCustomizer(this.properties);
this.properties);
} }
@Test @Test
......
...@@ -62,8 +62,7 @@ public class ServletWebServerFactoryCustomizerTests { ...@@ -62,8 +62,7 @@ public class ServletWebServerFactoryCustomizerTests {
@Before @Before
public void setup() { public void setup() {
MockitoAnnotations.initMocks(this); MockitoAnnotations.initMocks(this);
this.customizer = new ServletWebServerFactoryCustomizer( this.customizer = new ServletWebServerFactoryCustomizer(this.properties);
this.properties);
} }
@Test @Test
......
/* /*
* Copyright 2012-2017 the original author or authors. * Copyright 2012-2018 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.
......
...@@ -129,9 +129,10 @@ abstract class ArchiveCommand extends OptionParsingCommand { ...@@ -129,9 +129,10 @@ abstract class ArchiveCommand extends OptionParsingCommand {
File output = new File((String) nonOptionArguments.remove(0)); File output = new File((String) nonOptionArguments.remove(0));
Assert.isTrue( Assert.isTrue(
output.getName().toLowerCase(Locale.ENGLISH).endsWith("." + this.type), output.getName().toLowerCase(Locale.ENGLISH)
"The output '" + output + "' is not a " + this.type.toUpperCase( .endsWith("." + this.type),
Locale.ENGLISH) + " file."); "The output '" + output + "' is not a "
+ this.type.toUpperCase(Locale.ENGLISH) + " file.");
deleteIfExists(output); deleteIfExists(output);
GroovyCompiler compiler = createCompiler(options); GroovyCompiler compiler = createCompiler(options);
......
...@@ -324,9 +324,8 @@ public class AetherGrapeEngine implements GrapeEngine { ...@@ -324,9 +324,8 @@ public class AetherGrapeEngine implements GrapeEngine {
} }
private DependencyRequest getDependencyRequest(CollectRequest collectRequest) { private DependencyRequest getDependencyRequest(CollectRequest collectRequest) {
return new DependencyRequest(collectRequest, return new DependencyRequest(collectRequest, DependencyFilterUtils
DependencyFilterUtils.classpathFilter(JavaScopes.COMPILE, .classpathFilter(JavaScopes.COMPILE, JavaScopes.RUNTIME));
JavaScopes.RUNTIME));
} }
private void addManagedDependencies(DependencyResult result) { private void addManagedDependencies(DependencyResult result) {
......
/* /*
* Copyright 2012-2017 the original author or authors. * Copyright 2012-2018 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-2017 the original author or authors. * Copyright 2012-2018 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.
......
...@@ -48,12 +48,14 @@ public class CloudFoundryCustomContextPathExample { ...@@ -48,12 +48,14 @@ public class CloudFoundryCustomContextPathExample {
return new TomcatServletWebServerFactory() { return new TomcatServletWebServerFactory() {
@Override @Override
protected void prepareContext(Host host, ServletContextInitializer[] initializers) { protected void prepareContext(Host host,
ServletContextInitializer[] initializers) {
super.prepareContext(host, initializers); super.prepareContext(host, initializers);
StandardContext child = new StandardContext(); StandardContext child = new StandardContext();
child.addLifecycleListener(new Tomcat.FixContextListener()); child.addLifecycleListener(new Tomcat.FixContextListener());
child.setPath("/cloudfoundryapplication"); child.setPath("/cloudfoundryapplication");
ServletContainerInitializer initializer = getServletContextInitializer(getContextPath()); ServletContainerInitializer initializer = getServletContextInitializer(
getContextPath());
child.addServletContainerInitializer(initializer, Collections.emptySet()); child.addServletContainerInitializer(initializer, Collections.emptySet());
child.setCrossContext(true); child.setCrossContext(true);
host.addChild(child); host.addChild(child);
...@@ -69,8 +71,10 @@ public class CloudFoundryCustomContextPathExample { ...@@ -69,8 +71,10 @@ public class CloudFoundryCustomContextPathExample {
@Override @Override
public void service(ServletRequest req, ServletResponse res) public void service(ServletRequest req, ServletResponse res)
throws ServletException, IOException { throws ServletException, IOException {
ServletContext context = req.getServletContext().getContext(contextPath); ServletContext context = req.getServletContext()
context.getRequestDispatcher("/cloudfoundryapplication").forward(req, res); .getContext(contextPath);
context.getRequestDispatcher("/cloudfoundryapplication").forward(req,
res);
} }
}; };
......
/* /*
* Copyright 2012-2017 the original author or authors. * Copyright 2012-2018 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.
...@@ -95,13 +95,13 @@ public class MetadataStore { ...@@ -95,13 +95,13 @@ public class MetadataStore {
} }
private FileObject getMetadataResource() throws IOException { private FileObject getMetadataResource() throws IOException {
return this.environment.getFiler() return this.environment.getFiler().getResource(StandardLocation.CLASS_OUTPUT, "",
.getResource(StandardLocation.CLASS_OUTPUT, "", METADATA_PATH); METADATA_PATH);
} }
private FileObject createMetadataResource() throws IOException { private FileObject createMetadataResource() throws IOException {
return this.environment.getFiler() return this.environment.getFiler().createResource(StandardLocation.CLASS_OUTPUT,
.createResource(StandardLocation.CLASS_OUTPUT, "", METADATA_PATH); "", METADATA_PATH);
} }
private InputStream getAdditionalMetadataStream() throws IOException { private InputStream getAdditionalMetadataStream() throws IOException {
......
...@@ -140,9 +140,8 @@ final class JavaPluginAction implements PluginApplicationAction { ...@@ -140,9 +140,8 @@ final class JavaPluginAction implements PluginApplicationAction {
} }
private void configureAdditionalMetadataLocations(Project project) { private void configureAdditionalMetadataLocations(Project project) {
project.afterEvaluate((evaluated) -> project.afterEvaluate((evaluated) -> evaluated.getTasks()
evaluated.getTasks().withType(JavaCompile.class, .withType(JavaCompile.class, this::configureAdditionalMetadataLocations));
this::configureAdditionalMetadataLocations));
} }
private void configureAdditionalMetadataLocations(JavaCompile compile) { private void configureAdditionalMetadataLocations(JavaCompile compile) {
......
...@@ -247,8 +247,8 @@ public class JarWriter implements LoaderClassesWriter, AutoCloseable { ...@@ -247,8 +247,8 @@ public class JarWriter implements LoaderClassesWriter, AutoCloseable {
} }
/** /**
* Perform the actual write of a {@link JarEntry}. All other write methods * Perform the actual write of a {@link JarEntry}. All other write methods delegate to
* delegate to this one. * this one.
* @param entry the entry to write * @param entry the entry to write
* @param entryWriter the entry writer or {@code null} if there is no content * @param entryWriter the entry writer or {@code null} if there is no content
* @param unpackHandler handles possible unpacking for the entry * @param unpackHandler handles possible unpacking for the entry
......
...@@ -208,8 +208,7 @@ public class RepackagerTests { ...@@ -208,8 +208,7 @@ public class RepackagerTests {
repackager.setLayout(new Layouts.None()); repackager.setLayout(new Layouts.None());
repackager.repackage(file, NO_LIBRARIES); repackager.repackage(file, NO_LIBRARIES);
Manifest actualManifest = getManifest(file); Manifest actualManifest = getManifest(file);
assertThat(actualManifest.getMainAttributes().getValue("Main-Class")) assertThat(actualManifest.getMainAttributes().getValue("Main-Class")).isNull();
.isNull();
assertThat(hasLauncherClasses(file)).isFalse(); assertThat(hasLauncherClasses(file)).isFalse();
} }
......
...@@ -108,7 +108,7 @@ public class JarFile extends java.util.jar.JarFile { ...@@ -108,7 +108,7 @@ public class JarFile extends java.util.jar.JarFile {
private JarFile(RandomAccessDataFile rootFile, String pathFromRoot, private JarFile(RandomAccessDataFile rootFile, String pathFromRoot,
RandomAccessData data, JarEntryFilter filter, JarFileType type) RandomAccessData data, JarEntryFilter filter, JarFileType type)
throws IOException { throws IOException {
super(rootFile.getFile()); super(rootFile.getFile());
this.rootFile = rootFile; this.rootFile = rootFile;
this.pathFromRoot = pathFromRoot; this.pathFromRoot = pathFromRoot;
......
...@@ -185,12 +185,13 @@ public abstract class SystemPropertyUtils { ...@@ -185,12 +185,13 @@ public abstract class SystemPropertyUtils {
} }
if (propVal == null) { if (propVal == null) {
// Try with underscores. // Try with underscores.
propVal = System.getenv(key.replace('.', '_')); String name = key.replace('.', '_');
propVal = System.getenv(name);
} }
if (propVal == null) { if (propVal == null) {
// Try uppercase with underscores as well. // Try uppercase with underscores as well.
propVal = System.getenv(key.toUpperCase(Locale.ENGLISH) String name = key.toUpperCase(Locale.ENGLISH).replace('.', '_');
.replace('.', '_')); propVal = System.getenv(name);
} }
if (propVal != null) { if (propVal != null) {
return propVal; return propVal;
......
/* /*
* Copyright 2012-2017 the original author or authors. * Copyright 2012-2018 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.
......
...@@ -110,7 +110,7 @@ public final class LambdaSafe { ...@@ -110,7 +110,7 @@ public final class LambdaSafe {
private Log logger; private Log logger;
private Filter<C, A> filter = new GenericTypeFilter<C, A>(); private Filter<C, A> filter = new GenericTypeFilter<>();
protected LambdaSafeCallback(Class<C> callbackType, A argument, protected LambdaSafeCallback(Class<C> callbackType, A argument,
Object[] additionalArguments) { Object[] additionalArguments) {
...@@ -414,7 +414,7 @@ public final class LambdaSafe { ...@@ -414,7 +414,7 @@ public final class LambdaSafe {
* @return an {@link InvocationResult} * @return an {@link InvocationResult}
*/ */
public static <R> InvocationResult<R> of(R value) { public static <R> InvocationResult<R> of(R value) {
return new InvocationResult<R>(value); return new InvocationResult<>(value);
} }
/** /**
......
/* /*
* Copyright 2012-2016 the original author or authors. * Copyright 2012-2018 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.
...@@ -47,10 +47,12 @@ public class SampleAntApplicationIT { ...@@ -47,10 +47,12 @@ public class SampleAntApplicationIT {
}); });
assertThat(jarFiles).hasSize(1); assertThat(jarFiles).hasSize(1);
Process process = new JavaExecutable().processBuilder("-jar", jarFiles[0].getName()).directory(target).start(); Process process = new JavaExecutable().processBuilder("-jar", jarFiles[0]
.getName()).directory(target).start();
process.waitFor(5, TimeUnit.MINUTES); process.waitFor(5, TimeUnit.MINUTES);
assertThat(process.exitValue()).isEqualTo(0); assertThat(process.exitValue()).isEqualTo(0);
String output = FileCopyUtils.copyToString(new InputStreamReader(process.getInputStream())); String output = FileCopyUtils.copyToString(new InputStreamReader(process
.getInputStream()));
assertThat(output).contains("Spring Boot Ant Example"); assertThat(output).contains("Spring Boot Ant Example");
} }
......
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