Skip to content
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
10 changes: 10 additions & 0 deletions .github/actions/build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,16 @@ runs:
COMMERCIAL_REPO_USERNAME: ${{ inputs.commercial-repository-username }}
COMMERCIAL_SNAPSHOT_REPO_URL: ${{ inputs.commercial-snapshot-repository-url }}
run: ./gradlew build
- name: Sanity Check
id: sanity
if: ${{ inputs.publish == 'false' }}
shell: bash
env:
COMMERCIAL_RELEASE_REPO_URL: ${{ inputs.commercial-release-repository-url }}
COMMERCIAL_REPO_PASSWORD: ${{ inputs.commercial-repository-password }}
COMMERCIAL_REPO_USERNAME: ${{ inputs.commercial-repository-username }}
COMMERCIAL_SNAPSHOT_REPO_URL: ${{ inputs.commercial-snapshot-repository-url }}
run: ./gradlew rewriteDryRun -Dorg.gradle.jvmargs=-Xmx12G
- name: Publish
id: publish
if: ${{ inputs.publish == 'true' }}
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/build-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ jobs:
- name: Build
id: build
uses: ./.github/actions/build
- name: Sanity
id: sanity
uses: ./.github/actions/build
- name: Print JVM Thread Dumps When Cancelled
if: cancelled()
uses: ./.github/actions/print-jvm-thread-dumps
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
import org.gradle.api.tasks.Optional;
import org.jspecify.annotations.Nullable;

import static java.util.Collections.emptySet;

/**
* The properties that are written into the {@code build-info.properties} file.
*
Expand Down Expand Up @@ -148,7 +150,7 @@ Map<String, String> getAdditionalIfNotExcluded() {
}

private <T> @Nullable T getIfNotExcluded(Property<T> property, String name, Supplier<@Nullable T> defaultValue) {
if (this.excludes.getOrElse(Collections.emptySet()).contains(name)) {
if (this.excludes.getOrElse(emptySet()).contains(name)) {
return null;
}
if (property.isPresent()) {
Expand All @@ -172,7 +174,7 @@ private Map<String, String> coerceToStringValues(Map<String, Object> input) {

private Map<String, Object> applyExclusions(Map<String, Object> input) {
Map<String, Object> output = new HashMap<>();
Set<String> exclusions = this.excludes.getOrElse(Collections.emptySet());
Set<String> exclusions = this.excludes.getOrElse(emptySet());
input.forEach((key, value) -> {
boolean isExcluded = exclusions.contains(key);
if (!isExcluded) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import org.springframework.boot.loader.tools.LibraryCoordinates;
import org.springframework.boot.loader.tools.LibraryScope;

import static java.util.Collections.emptySet;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.assertArg;
import static org.mockito.BDDMockito.given;
Expand Down Expand Up @@ -200,7 +201,7 @@ void nonIncludedArtifact() throws IOException {
MavenProject mavenProject = mock(MavenProject.class);
given(mavenProject.getArtifact()).willReturn(artifact);
this.artifacts = Collections.singleton(artifact);
new ArtifactsLibraries(this.artifacts, Collections.emptySet(), Collections.singleton(mavenProject), null,
new ArtifactsLibraries(this.artifacts, emptySet(), Collections.singleton(mavenProject), null,
mock(Log.class))
.doWithLibraries((library) -> assertThat(library.isIncluded()).isFalse());
}
Expand Down
3 changes: 3 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

plugins {
id "base"
id "org.openrewrite.rewrite" version "7.23.0" apply false
}

description = "Spring Boot Build"
Expand Down Expand Up @@ -46,3 +47,5 @@ subprojects {
resolutionStrategy.cacheChangingModulesFor 0, "minutes"
}
}

apply from: rootProject.file("gradle/plugins/config/sanity.gradle")
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import java.nio.file.attribute.FileAttribute;
import java.nio.file.attribute.PosixFilePermission;
import java.nio.file.attribute.PosixFilePermissions;
import java.util.Collections;
import java.util.Set;

import org.junit.jupiter.api.Test;
Expand All @@ -32,6 +31,7 @@
import org.junit.jupiter.api.condition.OS;
import org.junit.jupiter.api.io.TempDir;

import static java.util.Collections.emptySet;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIOException;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
Expand Down Expand Up @@ -86,7 +86,7 @@ void posixPermissionsToUmask() {

@Test
void posixPermissionsToUmaskWithEmptyPermissions() {
Set<PosixFilePermission> permissions = Collections.emptySet();
Set<PosixFilePermission> permissions = emptySet();
assertThat(FilePermissions.posixPermissionsToUmask(permissions)).isZero();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@

package org.springframework.boot.configurationprocessor.fieldvalues.javac;

import java.util.Collections;
import java.util.Set;

import javax.lang.model.element.Modifier;

import static java.util.Collections.emptySet;

/**
* Reflection based access to {@code com.sun.source.tree.VariableTree}.
*
Expand Down Expand Up @@ -49,7 +50,7 @@ ExpressionTree getInitializer() throws Exception {
Set<Modifier> getModifierFlags() throws Exception {
Object modifiers = findMethod("getModifiers").invoke(getInstance());
if (modifiers == null) {
return Collections.emptySet();
return emptySet();
}
return (Set<Modifier>) findMethod(findClass("com.sun.source.tree.ModifiersTree"), "getFlags").invoke(modifiers);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;

import static java.util.Collections.emptySet;

/**
* {@link DeferredImportSelector} to handle {@link EnableAutoConfiguration
* auto-configuration}. This class can also be subclassed if a custom variant of
Expand Down Expand Up @@ -546,7 +548,7 @@ protected static class AutoConfigurationEntry {

private AutoConfigurationEntry() {
this.configurations = Collections.emptyList();
this.exclusions = Collections.emptySet();
this.exclusions = emptySet();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
import org.springframework.core.type.classreading.MetadataReaderFactory;
import org.springframework.util.Assert;

import static java.util.Collections.emptySet;

/**
* Sort {@link EnableAutoConfiguration auto-configuration} classes into priority order by
* reading {@link AutoConfigureOrder @AutoConfigureOrder},
Expand Down Expand Up @@ -226,7 +228,7 @@ private Set<String> getClassNames(String metadataKey, Class<? extends Annotation

private Set<String> getSet(String metadataKey) {
Assert.state(this.autoConfigurationMetadata != null, "'autoConfigurationMetadata' must not be null");
return this.autoConfigurationMetadata.getSet(this.className, metadataKey, Collections.emptySet());
return this.autoConfigurationMetadata.getSet(this.className, metadataKey, emptySet());
}

private Set<String> applyReplacements(Set<String> values) {
Expand Down Expand Up @@ -265,7 +267,7 @@ private Set<String> getAnnotationValue(Class<?> annotation) {
Map<String, @Nullable Object> attributes = getAnnotationMetadata()
.getAnnotationAttributes(annotation.getName(), true);
if (attributes == null) {
return Collections.emptySet();
return emptySet();
}
Set<String> result = new LinkedHashSet<>();
String[] value = (String[]) attributes.get("value");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@
import org.springframework.util.ReflectionUtils;
import org.springframework.util.StringUtils;

import static java.util.Collections.emptySet;

/**
* {@link Condition} that checks for the presence or absence of specific beans.
*
Expand Down Expand Up @@ -315,7 +317,7 @@ private Set<String> getNamesOfBeansIgnoredByType(ListableBeanFactory beanFactory
.keySet();
result = addAll(result, ignoredNames);
}
return (result != null) ? result : Collections.emptySet();
return (result != null) ? result : emptySet();
}

private Map<String, @Nullable BeanDefinition> getBeanDefinitionsForType(ListableBeanFactory beanFactory,
Expand Down Expand Up @@ -607,7 +609,7 @@ protected Set<String> extractTypes(@Nullable MultiValueMap<String, @Nullable Obj
private Set<String> extract(@Nullable MultiValueMap<String, @Nullable Object> attributes,
String... attributeNames) {
if (CollectionUtils.isEmpty(attributes)) {
return Collections.emptySet();
return emptySet();
}
Set<String> result = new LinkedHashSet<>();
for (String attributeName : attributeNames) {
Expand All @@ -621,7 +623,7 @@ else if (value instanceof String string) {
}
}
}
return result.isEmpty() ? Collections.emptySet() : result;
return result.isEmpty() ? emptySet() : result;
}

private void merge(Set<String> result, String... additional) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.springframework.boot.autoconfigure.AutoConfigurationImportListener;
import org.springframework.core.io.support.SpringFactoriesLoader;

import static java.util.Collections.emptySet;
import static org.assertj.core.api.Assertions.assertThat;

/**
Expand Down Expand Up @@ -61,7 +62,7 @@ void shouldBeInSpringFactories() {
@Test
void onAutoConfigurationImportEventShouldRecordCandidates() {
List<String> candidateConfigurations = Collections.singletonList("Test");
Set<String> exclusions = Collections.emptySet();
Set<String> exclusions = emptySet();
AutoConfigurationImportEvent event = new AutoConfigurationImportEvent(this, candidateConfigurations,
exclusions);
this.listener.onAutoConfigurationImportEvent(event);
Expand All @@ -83,7 +84,7 @@ void onAutoConfigurationImportEventShouldRecordExclusions() {
@Test
void onAutoConfigurationImportEventShouldApplyExclusionsGlobally() {
AutoConfigurationImportEvent event = new AutoConfigurationImportEvent(this, Arrays.asList("First", "Second"),
Collections.emptySet());
emptySet());
this.listener.onAutoConfigurationImportEvent(event);
AutoConfigurationImportEvent anotherEvent = new AutoConfigurationImportEvent(this, Collections.emptyList(),
Collections.singleton("First"));
Expand All @@ -99,7 +100,7 @@ void onAutoConfigurationImportEventShouldApplyExclusionsGloballyWhenExclusionIsA
Collections.singleton("First"));
this.listener.onAutoConfigurationImportEvent(excludeEvent);
AutoConfigurationImportEvent event = new AutoConfigurationImportEvent(this, Arrays.asList("First", "Second"),
Collections.emptySet());
emptySet());
this.listener.onAutoConfigurationImportEvent(event);
ConditionEvaluationReport report = ConditionEvaluationReport.get(this.beanFactory);
assertThat(report.getUnconditionalClasses()).containsExactly("Second");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import org.springframework.core.io.ClassPathResource;
import org.springframework.util.FileCopyUtils;

import static java.util.Collections.emptySet;
import static org.assertj.core.api.Assertions.assertThat;

/**
Expand Down Expand Up @@ -74,7 +75,7 @@ void runLifecycle() throws IOException {
File composeFile = createComposeFile("redis-compose.yaml");
String projectName = UUID.randomUUID().toString();
DockerCli cli = new DockerCli(null, new DockerComposeOptions(DockerComposeFile.of(composeFile),
Collections.emptySet(), List.of("--project-name=" + projectName)));
emptySet(), List.of("--project-name=" + projectName)));
try {
// Verify that no services are running (this is a fresh compose project)
List<DockerCliComposePsResponse> ps = cli.run(new ComposePs());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
import org.springframework.core.log.LogMessage;
import org.springframework.util.CollectionUtils;

import static java.util.Collections.emptySet;

/**
* Wrapper around {@code docker} and {@code docker-compose} command line tools.
*
Expand Down Expand Up @@ -212,7 +214,7 @@ record DockerComposeOptions(@Nullable DockerComposeFile composeFile, Set<String>
DockerComposeOptions(@Nullable DockerComposeFile composeFile, @Nullable Set<String> activeProfiles,
@Nullable List<String> arguments) {
this.composeFile = composeFile;
this.activeProfiles = (activeProfiles != null) ? activeProfiles : Collections.emptySet();
this.activeProfiles = (activeProfiles != null) ? activeProfiles : emptySet();
this.arguments = (arguments != null) ? arguments : Collections.emptyList();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package org.springframework.boot.test.context.filter.annotation;

import java.lang.annotation.Annotation;
import java.util.Collections;
import java.util.HashSet;
import java.util.Locale;
import java.util.Set;
Expand All @@ -29,6 +28,8 @@
import org.springframework.core.annotation.MergedAnnotations.SearchStrategy;
import org.springframework.util.Assert;

import static java.util.Collections.emptySet;

/**
* {@link AnnotationCustomizableTypeExcludeFilter} that can be used to any test annotation
* that uses the standard {@code includeFilters}, {@code excludeFilters} and
Expand Down Expand Up @@ -87,12 +88,12 @@ protected final Set<Class<?>> getDefaultIncludes() {
}

protected Set<Class<?>> getKnownIncludes() {
return Collections.emptySet();
return emptySet();
}

@Override
protected Set<Class<?>> getComponentIncludes() {
return Collections.emptySet();
return emptySet();
}

@SuppressWarnings("unchecked")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package org.springframework.boot.testcontainers.service.connection;

import java.lang.annotation.Annotation;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.Set;

Expand All @@ -37,6 +36,8 @@
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;

import static java.util.Collections.emptySet;

/**
* {@link SslBundle} source created from annotations. Used as a cache key and as a
* {@link SslBundle} factory.
Expand Down Expand Up @@ -141,7 +142,7 @@ record SslBundleSource(@Nullable Ssl ssl, @Nullable PemKeyStore pemKeyStore, @Nu
private static <A extends Annotation> @Nullable A getAnnotation(@Nullable ListableBeanFactory beanFactory,
@Nullable String beanName, @Nullable MergedAnnotations annotations, Class<A> annotationType) {
Set<A> found = (beanFactory != null && beanName != null)
? beanFactory.findAllAnnotationsOnBean(beanName, annotationType, false) : Collections.emptySet();
? beanFactory.findAllAnnotationsOnBean(beanName, annotationType, false) : emptySet();
if (annotations != null) {
found = new LinkedHashSet<>(found);
annotations.stream(annotationType).map(MergedAnnotation::synthesize).forEach(found::add);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@
import org.springframework.util.function.ThrowingConsumer;
import org.springframework.util.function.ThrowingSupplier;

import static java.util.Collections.emptySet;

/**
* Class that can be used to bootstrap and launch a Spring application from a Java main
* method. By default class will perform the following steps to bootstrap your
Expand Down Expand Up @@ -234,7 +236,7 @@ public class SpringApplication {

private final List<BootstrapRegistryInitializer> bootstrapRegistryInitializers;

private Set<String> additionalProfiles = Collections.emptySet();
private Set<String> additionalProfiles = emptySet();

private boolean isCustomEnvironment;

Expand Down Expand Up @@ -1431,7 +1433,7 @@ public static int exit(ApplicationContext context, ExitCodeGenerator... exitCode
*/
public static SpringApplication.Augmented from(ThrowingConsumer<String[]> main) {
Assert.notNull(main, "'main' must not be null");
return new Augmented(main, Collections.emptySet(), Collections.emptySet());
return new Augmented(main, emptySet(), emptySet());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
import org.springframework.core.env.PropertySource;
import org.springframework.util.Assert;

import static java.util.Collections.emptySet;

/**
* Configuration data that has been loaded from a {@link ConfigDataResource} and may
* ultimately contribute {@link PropertySource property sources} to Spring's
Expand All @@ -51,7 +53,7 @@ public final class ConfigData {
/**
* A {@link ConfigData} instance that contains no data.
*/
public static final ConfigData EMPTY = new ConfigData(Collections.emptySet());
public static final ConfigData EMPTY = new ConfigData(emptySet());

/**
* Create a new {@link ConfigData} instance with the same options applied to each
Expand Down Expand Up @@ -177,7 +179,7 @@ public static final class Options {
/**
* No options.
*/
public static final Options NONE = new Options(Collections.emptySet());
public static final Options NONE = new Options(emptySet());

private final Set<Option> options;

Expand Down
Loading