Merge branch '2.7.x' into 3.0.x

This commit is contained in:
Phillip Webb
2023-02-21 23:15:40 -08:00
1890 changed files with 27173 additions and 21952 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2022 the original author or authors.
* Copyright 2012-2023 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.
@@ -103,7 +103,7 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor
static final String AUTO_CONFIGURATION_ANNOTATION = "org.springframework.boot.autoconfigure.AutoConfiguration";
private static final Set<String> SUPPORTED_OPTIONS = Collections
.unmodifiableSet(Collections.singleton(ADDITIONAL_METADATA_LOCATIONS_OPTION));
.unmodifiableSet(Collections.singleton(ADDITIONAL_METADATA_LOCATIONS_OPTION));
private MetadataStore metadataStore;
@@ -241,8 +241,9 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor
this.metadataEnv.getTypeUtils().getQualifiedName(element.getEnclosingElement()),
element.toString());
if (this.metadataCollector.hasSimilarGroup(group)) {
this.processingEnv.getMessager().printMessage(Kind.ERROR,
"Duplicate @ConfigurationProperties definition for prefix '" + prefix + "'", element);
this.processingEnv.getMessager()
.printMessage(Kind.ERROR,
"Duplicate @ConfigurationProperties definition for prefix '" + prefix + "'", element);
}
else {
this.metadataCollector.add(group);
@@ -260,7 +261,7 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor
this.metadataCollector.add(descriptor.resolveItemMetadata(prefix, this.metadataEnv));
if (descriptor.isNested(this.metadataEnv)) {
TypeElement nestedTypeElement = (TypeElement) this.metadataEnv.getTypeUtils()
.asElement(descriptor.getType());
.asElement(descriptor.getType());
String nestedPrefix = ConfigurationMetadata.nestedPrefix(prefix, descriptor.getName());
processTypeElement(nestedPrefix, nestedTypeElement, source, seen);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2022 the original author or authors.
* Copyright 2012-2023 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.
@@ -275,7 +275,7 @@ class MetadataGenerationEnvironment {
Map<String, Object> getAnnotationElementValues(AnnotationMirror annotation) {
Map<String, Object> values = new LinkedHashMap<>();
annotation.getElementValues()
.forEach((name, value) -> values.put(name.getSimpleName().toString(), getAnnotationValue(value)));
.forEach((name, value) -> values.put(name.getSimpleName().toString(), getAnnotationValue(value)));
return values;
}
@@ -306,8 +306,10 @@ class MetadataGenerationEnvironment {
}
Set<TypeElement> getEndpointAnnotationElements() {
return this.endpointAnnotations.stream().map(this.elements::getTypeElement).filter(Objects::nonNull)
.collect(Collectors.toSet());
return this.endpointAnnotations.stream()
.map(this.elements::getTypeElement)
.filter(Objects::nonNull)
.collect(Collectors.toSet());
}
AnnotationMirror getReadOperationAnnotation(Element element) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2022 the original author or authors.
* Copyright 2012-2023 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.
@@ -100,8 +100,8 @@ public class MetadataStore {
private InputStream getAdditionalMetadataStream() throws IOException {
// Most build systems will have copied the file to the class output location
FileObject fileObject = this.environment.getFiler().getResource(StandardLocation.CLASS_OUTPUT, "",
ADDITIONAL_METADATA_PATH);
FileObject fileObject = this.environment.getFiler()
.getResource(StandardLocation.CLASS_OUTPUT, "", ADDITIONAL_METADATA_PATH);
InputStream inputStream = getMetadataStream(fileObject);
if (inputStream != null) {
return inputStream;
@@ -129,7 +129,7 @@ public class MetadataStore {
return standardLocation;
}
String locations = this.environment.getOptions()
.get(ConfigurationMetadataAnnotationProcessor.ADDITIONAL_METADATA_LOCATIONS_OPTION);
.get(ConfigurationMetadataAnnotationProcessor.ADDITIONAL_METADATA_LOCATIONS_OPTION);
if (locations != null) {
for (String location : locations.split(",")) {
File candidate = new File(location, ADDITIONAL_METADATA_PATH);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2022 the original author or authors.
* Copyright 2012-2023 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.
@@ -234,7 +234,8 @@ class TypeUtils {
if (type.getKind() == TypeKind.DECLARED) {
DeclaredType declaredType = (DeclaredType) type;
DeclaredType freshType = (DeclaredType) this.env.getElementUtils()
.getTypeElement(this.types.asElement(type).toString()).asType();
.getTypeElement(this.types.asElement(type).toString())
.asType();
List<? extends TypeMirror> arguments = declaredType.getTypeArguments();
for (int i = 0; i < arguments.size(); i++) {
TypeMirror specificType = arguments.get(i);
@@ -267,9 +268,12 @@ class TypeUtils {
}
StringBuilder name = new StringBuilder();
name.append(qualifiedName);
name.append("<").append(
type.getTypeArguments().stream().map((t) -> visit(t, descriptor)).collect(Collectors.joining(",")))
.append(">");
name.append("<")
.append(type.getTypeArguments()
.stream()
.map((t) -> visit(t, descriptor))
.collect(Collectors.joining(",")))
.append(">");
return name.toString();
}
@@ -365,14 +369,19 @@ class TypeUtils {
}
TypeMirror resolveGeneric(String parameterName) {
return this.generics.entrySet().stream().filter((e) -> getParameterName(e.getKey()).equals(parameterName))
.findFirst().map(Entry::getValue).orElse(null);
return this.generics.entrySet()
.stream()
.filter((e) -> getParameterName(e.getKey()).equals(parameterName))
.findFirst()
.map(Entry::getValue)
.orElse(null);
}
private void registerIfNecessary(TypeMirror variable, TypeMirror resolution) {
if (variable instanceof TypeVariable typeVariable) {
if (this.generics.keySet().stream()
.noneMatch((candidate) -> getParameterName(candidate).equals(getParameterName(typeVariable)))) {
if (this.generics.keySet()
.stream()
.noneMatch((candidate) -> getParameterName(candidate).equals(getParameterName(typeVariable)))) {
this.generics.put(typeVariable, resolution);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2022 the original author or authors.
* Copyright 2012-2023 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.
@@ -38,8 +38,11 @@ class JsonConverter {
JSONArray toJsonArray(ConfigurationMetadata metadata, ItemType itemType) throws Exception {
JSONArray jsonArray = new JSONArray();
List<ItemMetadata> items = metadata.getItems().stream().filter((item) -> item.isOfItemType(itemType))
.sorted(ITEM_COMPARATOR).toList();
List<ItemMetadata> items = metadata.getItems()
.stream()
.filter((item) -> item.isOfItemType(itemType))
.sorted(ITEM_COMPARATOR)
.toList();
for (ItemMetadata item : items) {
if (item.isOfItemType(itemType)) {
jsonArray.put(toJsonObject(item));
@@ -160,11 +163,11 @@ class JsonConverter {
private static class ItemMetadataComparator implements Comparator<ItemMetadata> {
private static final Comparator<ItemMetadata> GROUP = Comparator.comparing(ItemMetadata::getName)
.thenComparing(ItemMetadata::getSourceType, Comparator.nullsFirst(Comparator.naturalOrder()));
.thenComparing(ItemMetadata::getSourceType, Comparator.nullsFirst(Comparator.naturalOrder()));
private static final Comparator<ItemMetadata> ITEM = Comparator.comparing(ItemMetadataComparator::isDeprecated)
.thenComparing(ItemMetadata::getName)
.thenComparing(ItemMetadata::getSourceType, Comparator.nullsFirst(Comparator.naturalOrder()));
.thenComparing(ItemMetadata::getName)
.thenComparing(ItemMetadata::getSourceType, Comparator.nullsFirst(Comparator.naturalOrder()));
@Override
public int compare(ItemMetadata o1, ItemMetadata o2) {