Skip to content

Polish #42503

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

Polish #42503

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ public void onApplicationEvent(ApplicationEvent event) {

/**
* {@link ContextStorage#addWrapper(java.util.function.Function) Add} the
* {@link ContextStorage} wrapper to ensure that {@link EventPublisher} are propagated
* correctly.
* {@link ContextStorage} wrapper to ensure that {@link EventPublisher
* EventPublishers} are propagated correctly.
*/
public static void addWrapper() {
if (isInstallable() && added.compareAndSet(false, true)) {
Expand All @@ -118,7 +118,7 @@ private static boolean isInstallable() {
*/
static final class Wrapper {

static Wrapper instance = new Wrapper();
static final Wrapper instance = new Wrapper();

private final MultiValueMap<ApplicationContext, EventPublishingContextWrapper> beans = new LinkedMultiValueMap<>();

Expand Down Expand Up @@ -149,13 +149,16 @@ ContextStorage getStorageDelegate(ContextStorage parent) {
ContextStorage delegate = this.storageDelegate;
if (delegate == null) {
synchronized (this) {
delegate = parent;
for (List<EventPublishingContextWrapper> publishers : this.beans.values()) {
for (EventPublishingContextWrapper publisher : publishers) {
delegate = publisher.apply(delegate);
delegate = this.storageDelegate;
if (delegate == null) {
delegate = parent;
for (List<EventPublishingContextWrapper> publishers : this.beans.values()) {
for (EventPublishingContextWrapper publisher : publishers) {
delegate = publisher.apply(delegate);
}
}
this.storageDelegate = delegate;
}
this.storageDelegate = delegate;
}
}
return delegate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ class BaggagePropagationIntegrationTests {
@BeforeEach
@AfterEach
void setup() {
OpenTelemetryEventPublisherBeansApplicationListener.addWrapper();
MDC.clear();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ class DataLdapTestDockerTests {
void connectionCanBeMadeToLdapContainer() {
List<String> cn = this.ldapTemplate.search(LdapQueryBuilder.query().where("objectclass").is("dcObject"),
(AttributesMapper<String>) (attributes) -> attributes.get("dc").get().toString());
assertThat(cn).hasSize(1);
assertThat(cn.get(0)).isEqualTo("example");
assertThat(cn).singleElement().isEqualTo("example");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ class OpenLdapContainerConnectionDetailsFactoryIntegrationTests {
void connectionCanBeMadeToLdapContainer() {
List<String> cn = this.ldapTemplate.search(LdapQueryBuilder.query().where("objectclass").is("dcObject"),
(AttributesMapper<String>) (attributes) -> attributes.get("dc").get().toString());
assertThat(cn).hasSize(1);
assertThat(cn.get(0)).isEqualTo("example");
assertThat(cn).singleElement().isEqualTo("example");
}

@Configuration(proxyBeanMethods = false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public final D getConnectionDetails(ContainerConnectionSource<C> source) {
}

/**
* Return if the give source accepts the connection. By default this method checks
* Return if the given source accepts the connection. By default this method checks
* each connection name.
* @param source the container connection source
* @param requiredContainerType the required container type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ private static String getOrDeduceConnectionName(String connectionName, String co
}

/**
* Return is this source accepts the given connection.
* Return if this source accepts the given connection.
* @param requiredConnectionName the required connection name or {@code null}
* @param requiredContainerType the required container type
* @param requiredConnectionDetailsType the required connection details type
Expand Down