From 757a0c2664766b375b46203da2039b3201ce4a96 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Tue, 26 Jul 2022 10:34:18 +0100 Subject: [PATCH 1/2] Update copyright year of changed files --- .../classpath/CheckClasspathForProhibitedDependencies.java | 2 +- .../org/springframework/boot/build/mavenplugin/MavenExec.java | 2 +- .../optional/OptionalDependenciesPluginIntegrationTests.java | 2 +- .../boot/build/testing/TestFailuresPluginIntegrationTests.java | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/buildSrc/src/main/java/org/springframework/boot/build/classpath/CheckClasspathForProhibitedDependencies.java b/buildSrc/src/main/java/org/springframework/boot/build/classpath/CheckClasspathForProhibitedDependencies.java index fa84f09755..c64c543d45 100644 --- a/buildSrc/src/main/java/org/springframework/boot/build/classpath/CheckClasspathForProhibitedDependencies.java +++ b/buildSrc/src/main/java/org/springframework/boot/build/classpath/CheckClasspathForProhibitedDependencies.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/buildSrc/src/main/java/org/springframework/boot/build/mavenplugin/MavenExec.java b/buildSrc/src/main/java/org/springframework/boot/build/mavenplugin/MavenExec.java index 4a0a6b8d7b..cf84ec81ea 100644 --- a/buildSrc/src/main/java/org/springframework/boot/build/mavenplugin/MavenExec.java +++ b/buildSrc/src/main/java/org/springframework/boot/build/mavenplugin/MavenExec.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/buildSrc/src/test/java/org/springframework/boot/build/optional/OptionalDependenciesPluginIntegrationTests.java b/buildSrc/src/test/java/org/springframework/boot/build/optional/OptionalDependenciesPluginIntegrationTests.java index 6f9afc4bf9..3482b3d97b 100644 --- a/buildSrc/src/test/java/org/springframework/boot/build/optional/OptionalDependenciesPluginIntegrationTests.java +++ b/buildSrc/src/test/java/org/springframework/boot/build/optional/OptionalDependenciesPluginIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/buildSrc/src/test/java/org/springframework/boot/build/testing/TestFailuresPluginIntegrationTests.java b/buildSrc/src/test/java/org/springframework/boot/build/testing/TestFailuresPluginIntegrationTests.java index b0e11fbee5..a3088d59e6 100644 --- a/buildSrc/src/test/java/org/springframework/boot/build/testing/TestFailuresPluginIntegrationTests.java +++ b/buildSrc/src/test/java/org/springframework/boot/build/testing/TestFailuresPluginIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. From 4bcec6e0ee27107ce0711c97e79bbd4ed9ce9ec5 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Tue, 26 Jul 2022 10:50:01 +0100 Subject: [PATCH 2/2] Polish --- .../jmx/JmxEndpointAutoConfigurationTests.java | 15 ++++++++++----- .../buildpack/platform/build/ImageBuildpack.java | 15 ++++----------- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/jmx/JmxEndpointAutoConfigurationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/jmx/JmxEndpointAutoConfigurationTests.java index e963d0a921..7c077dd36e 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/jmx/JmxEndpointAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/jmx/JmxEndpointAutoConfigurationTests.java @@ -37,6 +37,8 @@ import org.springframework.boot.actuate.endpoint.jmx.annotation.JmxEndpointDisco import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.jmx.JmxAutoConfiguration; import org.springframework.boot.test.context.runner.ApplicationContextRunner; +import org.springframework.boot.test.context.runner.ContextConsumer; +import org.springframework.context.ConfigurableApplicationContext; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; @@ -52,6 +54,9 @@ import static org.mockito.Mockito.times; */ class JmxEndpointAutoConfigurationTests { + private static final ContextConsumer NO_OPERATION = (context) -> { + }; + private final ApplicationContextRunner contextRunner = new ApplicationContextRunner() .withConfiguration(AutoConfigurations.of(EndpointAutoConfiguration.class, JmxAutoConfiguration.class, JmxEndpointAutoConfiguration.class)) @@ -90,11 +95,11 @@ class JmxEndpointAutoConfigurationTests { given(this.mBeanServer.queryNames(any(), any())) .willReturn(new HashSet<>(Arrays.asList(new ObjectName("test:test=test")))); ArgumentCaptor objectName = ArgumentCaptor.forClass(ObjectName.class); - this.contextRunner.withPropertyValues("spring.jmx.enabled=true").with(mockMBeanServer()).run((parent) -> { - this.contextRunner.withPropertyValues("spring.jmx.enabled=true").withParent(parent).run((child) -> { - }); - this.contextRunner.withPropertyValues("spring.jmx.enabled=true").withParent(parent).run((child) -> { - }); + ApplicationContextRunner jmxEnabledContextRunner = this.contextRunner + .withPropertyValues("spring.jmx.enabled=true"); + jmxEnabledContextRunner.with(mockMBeanServer()).run((parent) -> { + jmxEnabledContextRunner.withParent(parent).run(NO_OPERATION); + jmxEnabledContextRunner.withParent(parent).run(NO_OPERATION); }); then(this.mBeanServer).should(times(3)).registerMBean(any(Object.class), objectName.capture()); Set uniqueValues = new HashSet<>(objectName.getAllValues()); diff --git a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/build/ImageBuildpack.java b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/build/ImageBuildpack.java index c52bed9129..8220e2294f 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/build/ImageBuildpack.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/build/ImageBuildpack.java @@ -61,12 +61,8 @@ final class ImageBuildpack implements Buildpack { Image image = context.fetchImage(reference, ImageType.BUILDPACK); BuildpackMetadata buildpackMetadata = BuildpackMetadata.fromImage(image); this.coordinates = BuildpackCoordinates.fromBuildpackMetadata(buildpackMetadata); - if (!buildpackExistsInBuilder(context, image.getLayers())) { - this.exportedLayers = new ExportedLayers(context, reference); - } - else { - this.exportedLayers = null; - } + this.exportedLayers = (!buildpackExistsInBuilder(context, image.getLayers())) + ? new ExportedLayers(context, reference) : null; } catch (IOException | DockerEngineException ex) { throw new IllegalArgumentException("Error pulling buildpack image '" + reference + "'", ex); @@ -76,11 +72,8 @@ final class ImageBuildpack implements Buildpack { private boolean buildpackExistsInBuilder(BuildpackResolverContext context, List imageLayers) { BuildpackLayerDetails buildpackLayerDetails = context.getBuildpackLayersMetadata() .getBuildpack(this.coordinates.getId(), this.coordinates.getVersion()); - if (buildpackLayerDetails != null) { - String layerDiffId = buildpackLayerDetails.getLayerDiffId(); - return imageLayers.stream().map(LayerId::toString).anyMatch((layerId) -> layerId.equals(layerDiffId)); - } - return false; + String layerDiffId = (buildpackLayerDetails != null) ? buildpackLayerDetails.getLayerDiffId() : null; + return (layerDiffId != null) && imageLayers.stream().map(LayerId::toString).anyMatch(layerDiffId::equals); } @Override