Skip to content

Commit 4bcec6e

Browse files
committed
Polish
1 parent 757a0c2 commit 4bcec6e

File tree

2 files changed

+14
-16
lines changed
  • spring-boot-project

2 files changed

+14
-16
lines changed

spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/jmx/JmxEndpointAutoConfigurationTests.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
import org.springframework.boot.autoconfigure.AutoConfigurations;
3838
import org.springframework.boot.autoconfigure.jmx.JmxAutoConfiguration;
3939
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
40+
import org.springframework.boot.test.context.runner.ContextConsumer;
41+
import org.springframework.context.ConfigurableApplicationContext;
4042

4143
import static org.assertj.core.api.Assertions.assertThat;
4244
import static org.mockito.ArgumentMatchers.any;
@@ -52,6 +54,9 @@
5254
*/
5355
class JmxEndpointAutoConfigurationTests {
5456

57+
private static final ContextConsumer<ConfigurableApplicationContext> NO_OPERATION = (context) -> {
58+
};
59+
5560
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
5661
.withConfiguration(AutoConfigurations.of(EndpointAutoConfiguration.class, JmxAutoConfiguration.class,
5762
JmxEndpointAutoConfiguration.class))
@@ -90,11 +95,11 @@ void jmxEndpointWithContextHierarchyGeneratesUniqueNamesForEachEndpoint() throws
9095
given(this.mBeanServer.queryNames(any(), any()))
9196
.willReturn(new HashSet<>(Arrays.asList(new ObjectName("test:test=test"))));
9297
ArgumentCaptor<ObjectName> objectName = ArgumentCaptor.forClass(ObjectName.class);
93-
this.contextRunner.withPropertyValues("spring.jmx.enabled=true").with(mockMBeanServer()).run((parent) -> {
94-
this.contextRunner.withPropertyValues("spring.jmx.enabled=true").withParent(parent).run((child) -> {
95-
});
96-
this.contextRunner.withPropertyValues("spring.jmx.enabled=true").withParent(parent).run((child) -> {
97-
});
98+
ApplicationContextRunner jmxEnabledContextRunner = this.contextRunner
99+
.withPropertyValues("spring.jmx.enabled=true");
100+
jmxEnabledContextRunner.with(mockMBeanServer()).run((parent) -> {
101+
jmxEnabledContextRunner.withParent(parent).run(NO_OPERATION);
102+
jmxEnabledContextRunner.withParent(parent).run(NO_OPERATION);
98103
});
99104
then(this.mBeanServer).should(times(3)).registerMBean(any(Object.class), objectName.capture());
100105
Set<ObjectName> uniqueValues = new HashSet<>(objectName.getAllValues());

spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/build/ImageBuildpack.java

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,8 @@ private ImageBuildpack(BuildpackResolverContext context, ImageReference imageRef
6161
Image image = context.fetchImage(reference, ImageType.BUILDPACK);
6262
BuildpackMetadata buildpackMetadata = BuildpackMetadata.fromImage(image);
6363
this.coordinates = BuildpackCoordinates.fromBuildpackMetadata(buildpackMetadata);
64-
if (!buildpackExistsInBuilder(context, image.getLayers())) {
65-
this.exportedLayers = new ExportedLayers(context, reference);
66-
}
67-
else {
68-
this.exportedLayers = null;
69-
}
64+
this.exportedLayers = (!buildpackExistsInBuilder(context, image.getLayers()))
65+
? new ExportedLayers(context, reference) : null;
7066
}
7167
catch (IOException | DockerEngineException ex) {
7268
throw new IllegalArgumentException("Error pulling buildpack image '" + reference + "'", ex);
@@ -76,11 +72,8 @@ private ImageBuildpack(BuildpackResolverContext context, ImageReference imageRef
7672
private boolean buildpackExistsInBuilder(BuildpackResolverContext context, List<LayerId> imageLayers) {
7773
BuildpackLayerDetails buildpackLayerDetails = context.getBuildpackLayersMetadata()
7874
.getBuildpack(this.coordinates.getId(), this.coordinates.getVersion());
79-
if (buildpackLayerDetails != null) {
80-
String layerDiffId = buildpackLayerDetails.getLayerDiffId();
81-
return imageLayers.stream().map(LayerId::toString).anyMatch((layerId) -> layerId.equals(layerDiffId));
82-
}
83-
return false;
75+
String layerDiffId = (buildpackLayerDetails != null) ? buildpackLayerDetails.getLayerDiffId() : null;
76+
return (layerDiffId != null) && imageLayers.stream().map(LayerId::toString).anyMatch(layerDiffId::equals);
8477
}
8578

8679
@Override

0 commit comments

Comments
 (0)