Merge branch '2.1.x'

pull/16014/head
Andy Wilkinson 6 years ago
commit f2e3e274a8

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2018 the original author or authors. * Copyright 2012-2019 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.
@ -20,6 +20,7 @@ import java.util.Collections;
import java.util.Map; import java.util.Map;
import javax.persistence.EntityManagerFactory; import javax.persistence.EntityManagerFactory;
import javax.persistence.PersistenceException;
import io.micrometer.core.instrument.MeterRegistry; import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.binder.jpa.HibernateMetrics; import io.micrometer.core.instrument.binder.jpa.HibernateMetrics;
@ -65,8 +66,14 @@ public class HibernateMetricsAutoConfiguration {
private void bindEntityManagerFactoryToRegistry(String beanName, private void bindEntityManagerFactoryToRegistry(String beanName,
EntityManagerFactory entityManagerFactory, MeterRegistry registry) { EntityManagerFactory entityManagerFactory, MeterRegistry registry) {
String entityManagerFactoryName = getEntityManagerFactoryName(beanName); String entityManagerFactoryName = getEntityManagerFactoryName(beanName);
new HibernateMetrics(entityManagerFactory, entityManagerFactoryName, try {
Collections.emptyList()).bindTo(registry); new HibernateMetrics(entityManagerFactory.unwrap(SessionFactory.class),
entityManagerFactoryName, Collections.emptyList())
.bindTo(registry);
}
catch (PersistenceException ex) {
// Continue
}
} }
/** /**

@ -56,7 +56,7 @@ public class JerseyEndpointIntegrationTests {
testJerseyEndpoints(new Class[] { EndpointsConfiguration.class }); testJerseyEndpoints(new Class[] { EndpointsConfiguration.class });
} }
protected void testJerseyEndpoints(Class[] userConfigurations) { protected void testJerseyEndpoints(Class<?>[] userConfigurations) {
FilteredClassLoader classLoader = new FilteredClassLoader( FilteredClassLoader classLoader = new FilteredClassLoader(
DispatcherServlet.class); DispatcherServlet.class);
new WebApplicationContextRunner( new WebApplicationContextRunner(

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2018 the original author or authors. * Copyright 2012-2019 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.
@ -77,9 +77,7 @@ public class MeterRegistryConfigurerIntegrationTests {
@Bean @Bean
MeterRegistryCustomizer<?> testCustomizer() { MeterRegistryCustomizer<?> testCustomizer() {
return (registry) -> { return (registry) -> registry.config().commonTags("testTag", "testValue");
registry.config().commonTags("testTag", "testValue");
};
} }
@Bean @Bean

@ -62,6 +62,7 @@ public class ElasticsearchJestHealthIndicatorTests {
} }
@Test @Test
@SuppressWarnings("unchecked")
public void elasticsearchWithYellowStatusIsUp() throws IOException { public void elasticsearchWithYellowStatusIsUp() throws IOException {
given(this.jestClient.execute(any(Action.class))) given(this.jestClient.execute(any(Action.class)))
.willReturn(createJestResult(200, true, "yellow")); .willReturn(createJestResult(200, true, "yellow"));

@ -134,7 +134,6 @@ public class DefaultErrorWebExceptionHandler extends AbstractErrorWebExceptionHa
protected Mono<ServerResponse> renderErrorResponse(ServerRequest request) { protected Mono<ServerResponse> renderErrorResponse(ServerRequest request) {
boolean includeStackTrace = isIncludeStackTrace(request, MediaType.ALL); boolean includeStackTrace = isIncludeStackTrace(request, MediaType.ALL);
Map<String, Object> error = getErrorAttributes(request, includeStackTrace); Map<String, Object> error = getErrorAttributes(request, includeStackTrace);
HttpStatus errorStatus = getHttpStatus(error);
return ServerResponse.status(getHttpStatus(error)) return ServerResponse.status(getHttpStatus(error))
.contentType(MediaType.APPLICATION_JSON_UTF8) .contentType(MediaType.APPLICATION_JSON_UTF8)
.body(BodyInserters.fromObject(error)); .body(BodyInserters.fromObject(error));

@ -202,10 +202,8 @@ public class MessageSourceAutoConfigurationTests {
public void messageSourceWithNonStandardBeanNameIsIgnored() { public void messageSourceWithNonStandardBeanNameIsIgnored() {
this.contextRunner.withPropertyValues("spring.messages.basename:test/messages") this.contextRunner.withPropertyValues("spring.messages.basename:test/messages")
.withUserConfiguration(CustomBeanNameMessageSourceConfiguration.class) .withUserConfiguration(CustomBeanNameMessageSourceConfiguration.class)
.run((context) -> { .run((context) -> assertThat(context.getMessage("foo", null, Locale.US))
assertThat(context.getMessage("foo", null, Locale.US)) .isEqualTo("bar"));
.isEqualTo("bar");
});
} }
@Configuration @Configuration

@ -252,9 +252,8 @@ public class EmbeddedMongoAutoConfigurationTests {
@Bean @Bean
public DownloadConfigBuilderCustomizer testDownloadConfigBuilderCustomizer() { public DownloadConfigBuilderCustomizer testDownloadConfigBuilderCustomizer() {
return (downloadConfigBuilder) -> { return (downloadConfigBuilder) -> downloadConfigBuilder
downloadConfigBuilder.userAgent("Test User Agent"); .userAgent("Test User Agent");
};
} }
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2018 the original author or authors. * Copyright 2012-2019 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.
@ -307,7 +307,6 @@ public class GroovyCompiler {
private static class MainClass { private static class MainClass {
@SuppressWarnings("unchecked")
public static ClassNode get(CompilationUnit source) { public static ClassNode get(CompilationUnit source) {
return get(source.getAST().getClasses()); return get(source.getAST().getClasses());
} }

@ -152,13 +152,9 @@ public abstract class AbstractApplicationContextRunnerTests<T extends AbstractAp
@Test @Test
public void runWithClassLoaderShouldSetClassLoaderOnContext() { public void runWithClassLoaderShouldSetClassLoaderOnContext() {
get().withClassLoader(new FilteredClassLoader(Gson.class.getPackage().getName())) get().withClassLoader(new FilteredClassLoader(Gson.class.getPackage().getName()))
.run((context) -> { .run((context) -> assertThatExceptionOfType(ClassNotFoundException.class)
assertThatExceptionOfType(ClassNotFoundException.class) .isThrownBy(() -> ClassUtils.forName(Gson.class.getName(),
.isThrownBy(() -> { context.getClassLoader())));
ClassUtils.forName(Gson.class.getName(),
context.getClassLoader());
});
});
} }
@Test @Test

@ -92,9 +92,8 @@ public class ConfigurationMetadataDocumentWriter {
List<String> matchingOverrides = overrides.keySet().stream() List<String> matchingOverrides = overrides.keySet().stream()
.filter((overrideKey) -> overrideKey.startsWith(keyPrefix)) .filter((overrideKey) -> overrideKey.startsWith(keyPrefix))
.collect(Collectors.toList()); .collect(Collectors.toList());
matchingOverrides.forEach((match) -> { matchingOverrides.forEach((match) ->
table.addEntry(overrides.remove(match)); table.addEntry(overrides.remove(match)));
});
} }
List<String> matchingKeys = unmappedKeys.stream() List<String> matchingKeys = unmappedKeys.stream()
.filter((key) -> keyPrefixes.stream().anyMatch(key::startsWith)) .filter((key) -> keyPrefixes.stream().anyMatch(key::startsWith))

@ -22,6 +22,9 @@ import java.util.Map;
/** /**
* A base properties class with generics. * A base properties class with generics.
* *
* @param <A> name type
* @param <B> mapping key type
* @param <C> mapping value type
* @author Stephane Nicoll * @author Stephane Nicoll
*/ */
public class AbstractGenericProperties<A, B, C> { public class AbstractGenericProperties<A, B, C> {

@ -19,6 +19,7 @@ package org.springframework.boot.configurationsample.generic;
/** /**
* An intermediate layer that resolves some of the generics from the parent but not all. * An intermediate layer that resolves some of the generics from the parent but not all.
* *
* @param <C> mapping value type
* @author Stephane Nicoll * @author Stephane Nicoll
*/ */
public abstract class AbstractIntermediateGenericProperties<C> public abstract class AbstractIntermediateGenericProperties<C>

@ -21,6 +21,8 @@ import org.springframework.boot.configurationsample.ConfigurationProperties;
/** /**
* Properties with unresolved generic information. * Properties with unresolved generic information.
* *
* @param <B> mapping key type
* @param <C> mapping value type
* @author Stephane Nicoll * @author Stephane Nicoll
*/ */
@ConfigurationProperties("generic") @ConfigurationProperties("generic")

@ -55,9 +55,8 @@ public class BootJar extends Jar implements BootArchive {
getMainSpec().with(this.bootInf); getMainSpec().with(this.bootInf);
this.bootInf.into("classes", classpathFiles(File::isDirectory)); this.bootInf.into("classes", classpathFiles(File::isDirectory));
this.bootInf.into("lib", classpathFiles(File::isFile)); this.bootInf.into("lib", classpathFiles(File::isFile));
this.bootInf.filesMatching("module-info.class", (details) -> { this.bootInf.filesMatching("module-info.class",
details.setRelativePath(details.getRelativeSourcePath()); (details) -> details.setRelativePath(details.getRelativeSourcePath()));
});
getRootSpec().eachFile((details) -> { getRootSpec().eachFile((details) -> {
String pathString = details.getRelativePath().getPathString(); String pathString = details.getRelativePath().getPathString();
if (pathString.startsWith("BOOT-INF/lib/") if (pathString.startsWith("BOOT-INF/lib/")

@ -54,9 +54,8 @@ public class BootWar extends War implements BootArchive {
(copySpec) -> copySpec.from( (copySpec) -> copySpec.from(
(Callable<Iterable<File>>) () -> (this.providedClasspath != null) (Callable<Iterable<File>>) () -> (this.providedClasspath != null)
? this.providedClasspath : Collections.emptyList())); ? this.providedClasspath : Collections.emptyList()));
getRootSpec().filesMatching("module-info.class", (details) -> { getRootSpec().filesMatching("module-info.class",
details.setRelativePath(details.getRelativeSourcePath()); (details) -> details.setRelativePath(details.getRelativeSourcePath()));
});
getRootSpec().eachFile((details) -> { getRootSpec().eachFile((details) -> {
String pathString = details.getRelativePath().getPathString(); String pathString = details.getRelativePath().getPathString();
if ((pathString.startsWith("WEB-INF/lib/") if ((pathString.startsWith("WEB-INF/lib/")

@ -80,6 +80,7 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo {
* @since 1.0 * @since 1.0
* @deprecated since version 2.2. Use agents instead. * @deprecated since version 2.2. Use agents instead.
*/ */
@Deprecated
@Parameter(property = "spring-boot.run.agent") @Parameter(property = "spring-boot.run.agent")
private File[] agent; private File[] agent;
@ -384,7 +385,6 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo {
} }
} }
@SuppressWarnings("deprecation")
private File[] determineAgents() { private File[] determineAgents() {
return (this.agents != null) ? this.agents : this.agent; return (this.agents != null) ? this.agents : this.agent;
} }

@ -128,7 +128,6 @@ public class LogFile {
* @return a {@link LogFile} or {@code null} if the environment didn't contain any * @return a {@link LogFile} or {@code null} if the environment didn't contain any
* suitable properties * suitable properties
*/ */
@SuppressWarnings("deprecation")
public static LogFile get(PropertyResolver propertyResolver) { public static LogFile get(PropertyResolver propertyResolver) {
String file = getLogFileProperty(propertyResolver, FILE_NAME_PROPERTY, String file = getLogFileProperty(propertyResolver, FILE_NAME_PROPERTY,
FILE_PROPERTY); FILE_PROPERTY);

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2018 the original author or authors. * Copyright 2012-2019 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.
@ -38,7 +38,7 @@ public class DefaultApplicationArgumentsTests {
@Test @Test
public void argumentsMustNotBeNull() { public void argumentsMustNotBeNull() {
assertThatIllegalArgumentException() assertThatIllegalArgumentException()
.isThrownBy(() -> new DefaultApplicationArguments(null)) .isThrownBy(() -> new DefaultApplicationArguments((String[]) null))
.withMessageContaining("Args must not be null"); .withMessageContaining("Args must not be null");
} }

Loading…
Cancel
Save