Skip to content

Commit 5332669

Browse files
committed
Polish
1 parent f8e5b9b commit 5332669

File tree

10 files changed

+24
-26
lines changed

10 files changed

+24
-26
lines changed

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/orm/jpa/HibernateMetricsAutoConfiguration.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2018 the original author or authors.
2+
* Copyright 2012-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -20,6 +20,7 @@
2020
import java.util.Map;
2121

2222
import javax.persistence.EntityManagerFactory;
23+
import javax.persistence.PersistenceException;
2324

2425
import io.micrometer.core.instrument.MeterRegistry;
2526
import io.micrometer.core.instrument.binder.jpa.HibernateMetrics;
@@ -69,8 +70,14 @@ public void bindEntityManagerFactoriesToRegistry(
6970
private void bindEntityManagerFactoryToRegistry(String beanName,
7071
EntityManagerFactory entityManagerFactory) {
7172
String entityManagerFactoryName = getEntityManagerFactoryName(beanName);
72-
new HibernateMetrics(entityManagerFactory, entityManagerFactoryName,
73-
Collections.emptyList()).bindTo(this.registry);
73+
try {
74+
new HibernateMetrics(entityManagerFactory.unwrap(SessionFactory.class),
75+
entityManagerFactoryName, Collections.emptyList())
76+
.bindTo(this.registry);
77+
}
78+
catch (PersistenceException ex) {
79+
// Continue
80+
}
7481
}
7582

7683
/**

spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/JerseyEndpointIntegrationTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public void actuatorEndpointsWhenUserProvidedResourceConfigBeanNotAvailable() {
5656
testJerseyEndpoints(new Class[] { EndpointsConfiguration.class });
5757
}
5858

59-
protected void testJerseyEndpoints(Class[] userConfigurations) {
59+
protected void testJerseyEndpoints(Class<?>[] userConfigurations) {
6060
FilteredClassLoader classLoader = new FilteredClassLoader(
6161
DispatcherServlet.class);
6262
new WebApplicationContextRunner(

spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/MeterRegistryConfigurerIntegrationTests.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2018 the original author or authors.
2+
* Copyright 2012-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -77,9 +77,7 @@ MeterBinder testBinder(Alpha thing) {
7777

7878
@Bean
7979
MeterRegistryCustomizer<?> testCustomizer() {
80-
return (registry) -> {
81-
registry.config().commonTags("testTag", "testValue");
82-
};
80+
return (registry) -> registry.config().commonTags("testTag", "testValue");
8381
}
8482

8583
@Bean

spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/elasticsearch/ElasticsearchJestHealthIndicatorTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2018 the original author or authors.
2+
* Copyright 2012-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -62,6 +62,7 @@ public void elasticsearchIsUp() throws IOException {
6262
}
6363

6464
@Test
65+
@SuppressWarnings("unchecked")
6566
public void elasticsearchWithYellowStatusIsUp() throws IOException {
6667
given(this.jestClient.execute(any(Action.class)))
6768
.willReturn(createJestResult(200, true, "yellow"));

spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/neo4j/Neo4jHealthIndicatorTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public void neo4jUp() {
7777

7878
@Test
7979
public void neo4jDown() {
80-
CypherException cypherException = new CypherException("Error executing Cypher",
80+
CypherException cypherException = new CypherException(
8181
"Neo.ClientError.Statement.SyntaxError",
8282
"Unable to execute invalid Cypher");
8383
given(this.session.query(Neo4jHealthIndicator.CYPHER, Collections.emptyMap()))

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/error/DefaultErrorWebExceptionHandler.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ protected Mono<ServerResponse> renderErrorView(ServerRequest request) {
134134
protected Mono<ServerResponse> renderErrorResponse(ServerRequest request) {
135135
boolean includeStackTrace = isIncludeStackTrace(request, MediaType.ALL);
136136
Map<String, Object> error = getErrorAttributes(request, includeStackTrace);
137-
HttpStatus errorStatus = getHttpStatus(error);
138137
return ServerResponse.status(getHttpStatus(error))
139138
.contentType(MediaType.APPLICATION_JSON_UTF8)
140139
.body(BodyInserters.fromObject(error));

spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/GroovyCompiler.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2018 the original author or authors.
2+
* Copyright 2012-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -307,7 +307,6 @@ public void call(SourceUnit source, GeneratorContext context, ClassNode classNod
307307

308308
private static class MainClass {
309309

310-
@SuppressWarnings("unchecked")
311310
public static ClassNode get(CompilationUnit source) {
312311
return get(source.getAST().getClasses());
313312
}

spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/context/runner/AbstractApplicationContextRunnerTests.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -152,13 +152,9 @@ public void runWithFailedContextShouldReturnFailedAssertableContext() {
152152
@Test
153153
public void runWithClassLoaderShouldSetClassLoaderOnContext() {
154154
get().withClassLoader(new FilteredClassLoader(Gson.class.getPackage().getName()))
155-
.run((context) -> {
156-
assertThatExceptionOfType(ClassNotFoundException.class)
157-
.isThrownBy(() -> {
158-
ClassUtils.forName(Gson.class.getName(),
159-
context.getClassLoader());
160-
});
161-
});
155+
.run((context) -> assertThatExceptionOfType(ClassNotFoundException.class)
156+
.isThrownBy(() -> ClassUtils.forName(Gson.class.getName(),
157+
context.getClassLoader())));
162158
}
163159

164160
@Test

spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootJar.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,8 @@ public BootJar() {
5555
getMainSpec().with(this.bootInf);
5656
this.bootInf.into("classes", classpathFiles(File::isDirectory));
5757
this.bootInf.into("lib", classpathFiles(File::isFile));
58-
this.bootInf.filesMatching("module-info.class", (details) -> {
59-
details.setRelativePath(details.getRelativeSourcePath());
60-
});
58+
this.bootInf.filesMatching("module-info.class",
59+
(details) -> details.setRelativePath(details.getRelativeSourcePath()));
6160
getRootSpec().eachFile((details) -> {
6261
String pathString = details.getRelativePath().getPathString();
6362
if (pathString.startsWith("BOOT-INF/lib/")

spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootWar.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,8 @@ public BootWar() {
5454
(copySpec) -> copySpec.from(
5555
(Callable<Iterable<File>>) () -> (this.providedClasspath != null)
5656
? this.providedClasspath : Collections.emptyList()));
57-
getRootSpec().filesMatching("module-info.class", (details) -> {
58-
details.setRelativePath(details.getRelativeSourcePath());
59-
});
57+
getRootSpec().filesMatching("module-info.class",
58+
(details) -> details.setRelativePath(details.getRelativeSourcePath()));
6059
getRootSpec().eachFile((details) -> {
6160
String pathString = details.getRelativePath().getPathString();
6261
if ((pathString.startsWith("WEB-INF/lib/")

0 commit comments

Comments
 (0)