Skip to content

Commit

Permalink
Merge branch '2.6.x' into 2.7.x
Browse files Browse the repository at this point in the history
  • Loading branch information
philwebb committed Jul 26, 2022
2 parents ac3f552 + 4bcec6e commit 3931e82
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
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;
Expand All @@ -52,6 +54,9 @@
*/
class JmxEndpointAutoConfigurationTests {

private static final ContextConsumer<ConfigurableApplicationContext> NO_OPERATION = (context) -> {
};

private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(EndpointAutoConfiguration.class, JmxAutoConfiguration.class,
JmxEndpointAutoConfiguration.class))
Expand Down Expand Up @@ -90,11 +95,11 @@ void jmxEndpointWithContextHierarchyGeneratesUniqueNamesForEachEndpoint() throws
given(this.mBeanServer.queryNames(any(), any()))
.willReturn(new HashSet<>(Arrays.asList(new ObjectName("test:test=test"))));
ArgumentCaptor<ObjectName> 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<ObjectName> uniqueValues = new HashSet<>(objectName.getAllValues());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,8 @@ private ImageBuildpack(BuildpackResolverContext context, ImageReference imageRef
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);
Expand All @@ -76,11 +72,8 @@ private ImageBuildpack(BuildpackResolverContext context, ImageReference imageRef
private boolean buildpackExistsInBuilder(BuildpackResolverContext context, List<LayerId> 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
Expand Down

0 comments on commit 3931e82

Please sign in to comment.