Skip to content

Enforce ordering when ObjectProvider is used #18333

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
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 @@ -68,6 +68,8 @@ static class DataSourcePoolMetadataMetricsConfiguration {
@Autowired
void bindDataSourcesToRegistry(Map<String, DataSource> dataSources, MeterRegistry registry,
ObjectProvider<DataSourcePoolMetadataProvider> metadataProviders) {
// doesn't matter the ordering here since they are usually distinct and are
// used as first match wins basis.
List<DataSourcePoolMetadataProvider> metadataProvidersList = metadataProviders.stream()
.collect(Collectors.toList());
dataSources.forEach(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public SpringApplicationAdminMXBeanRegistrar springApplicationAdminRegistrar(
ObjectProvider<MBeanExporter> mbeanExporters, Environment environment) throws MalformedObjectNameException {
String jmxName = environment.getProperty(JMX_NAME_PROPERTY, DEFAULT_JMX_NAME);
if (mbeanExporters != null) { // Make sure to not register that MBean twice
// ordering is not important for exporters, thus just iterate them
for (MBeanExporter mbeanExporter : mbeanExporters) {
mbeanExporter.addExcludedBean(jmxName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ public Flyway flyway(FlywayProperties properties, DataSourceProperties dataSourc
configureCallbacks(configuration, orderedCallbacks);
fluentConfigurationCustomizers.orderedStream().forEach((customizer) -> customizer.customize(configuration));
configureFlywayCallbacks(configuration, orderedCallbacks);
// flyway orders migrations by itself with their versions; thus use normal
// stream to collect them
List<JavaMigration> migrations = javaMigrations.stream().collect(Collectors.toList());
configureJavaMigrations(configuration, migrations);
return configuration.load();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.springframework.boot.autoconfigure.task;

import java.util.concurrent.Executor;
import java.util.stream.Collectors;

import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
Expand Down Expand Up @@ -67,7 +68,7 @@ public TaskExecutorBuilder taskExecutorBuilder(TaskExecutionProperties propertie
builder = builder.awaitTermination(shutdown.isAwaitTermination());
builder = builder.awaitTerminationPeriod(shutdown.getAwaitTerminationPeriod());
builder = builder.threadNamePrefix(properties.getThreadNamePrefix());
builder = builder.customizers(taskExecutorCustomizers);
builder = builder.customizers(taskExecutorCustomizers.orderedStream().collect(Collectors.toList()));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

builder = builder.taskDecorator(taskDecorator.getIfUnique());
return builder;
}
Expand Down