Nullability refinements and related polishing
See gh-32475
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -42,14 +42,14 @@ final class GeneratedMapUtils {
|
||||
* @param methodName the name of the static method to invoke
|
||||
* @return an unmodifiable map retrieved from a static method
|
||||
*/
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
static Map loadMap(String className, String methodName) {
|
||||
try {
|
||||
Class<?> clazz = ClassUtils.forName(className, null);
|
||||
Method method = ReflectionUtils.findMethod(clazz, methodName);
|
||||
Assert.state(method != null, () -> "No %s() method found in %s".formatted(methodName, className));
|
||||
Map map = (Map) ReflectionUtils.invokeMethod(method, null);
|
||||
return Collections.unmodifiableMap(map);
|
||||
return (map != null ? Collections.unmodifiableMap(map) : Collections.emptyMap());
|
||||
}
|
||||
catch (IllegalStateException ex) {
|
||||
throw ex;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -20,6 +20,7 @@ import org.springframework.aot.generate.ClassNameGenerator;
|
||||
import org.springframework.aot.generate.DefaultGenerationContext;
|
||||
import org.springframework.aot.generate.GeneratedFiles;
|
||||
import org.springframework.aot.hint.RuntimeHints;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Extension of {@link DefaultGenerationContext} with a custom implementation of
|
||||
@@ -30,6 +31,7 @@ import org.springframework.aot.hint.RuntimeHints;
|
||||
*/
|
||||
class TestContextGenerationContext extends DefaultGenerationContext {
|
||||
|
||||
@Nullable
|
||||
private final String featureName;
|
||||
|
||||
|
||||
@@ -41,8 +43,9 @@ class TestContextGenerationContext extends DefaultGenerationContext {
|
||||
* @param generatedFiles the generated files
|
||||
* @param runtimeHints the runtime hints
|
||||
*/
|
||||
TestContextGenerationContext(ClassNameGenerator classNameGenerator, GeneratedFiles generatedFiles,
|
||||
RuntimeHints runtimeHints) {
|
||||
TestContextGenerationContext(
|
||||
ClassNameGenerator classNameGenerator, GeneratedFiles generatedFiles, RuntimeHints runtimeHints) {
|
||||
|
||||
super(classNameGenerator, generatedFiles, runtimeHints);
|
||||
this.featureName = null;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -25,6 +25,7 @@ import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.core.Conventions;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.test.context.TestContext;
|
||||
import org.springframework.test.context.support.AbstractTestExecutionListener;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
@@ -67,6 +68,7 @@ class MicrometerObservationRegistryTestExecutionListener extends AbstractTestExe
|
||||
static final String OBSERVATION_THREAD_LOCAL_ACCESSOR_CLASS_NAME =
|
||||
"io.micrometer.observation.contextpropagation.ObservationThreadLocalAccessor";
|
||||
|
||||
@Nullable
|
||||
private static final String ERROR_MESSAGE;
|
||||
|
||||
static {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -143,7 +143,7 @@ class TestPropertySourceAttributes {
|
||||
}
|
||||
|
||||
private void addPropertiesAndLocations(List<PropertySourceDescriptor> descriptors, String[] properties,
|
||||
Class<?> declaringClass, String encoding, boolean prepend) {
|
||||
Class<?> declaringClass, @Nullable String encoding, boolean prepend) {
|
||||
|
||||
if (hasNoLocations(descriptors) && ObjectUtils.isEmpty(properties)) {
|
||||
String defaultPropertiesFile = detectDefaultPropertiesFile(declaringClass);
|
||||
|
||||
Reference in New Issue
Block a user