Skip to content

Commit fda7fdb

Browse files
Workaround NullAway bug on generic types
It seems <T extends @nullable Object> does not work well in some situations. See uber/NullAway#1075
1 parent 2c08781 commit fda7fdb

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

micrometer-core/src/main/java/io/micrometer/core/instrument/config/MeterRegistryConfigValidator.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717

1818
import io.micrometer.core.instrument.config.validate.Validated;
1919
import io.micrometer.core.instrument.config.validate.ValidationException;
20-
import org.jspecify.annotations.Nullable;
20+
import org.jspecify.annotations.NonNull;
21+
import org.jspecify.annotations.NullUnmarked;
2122

2223
import java.util.Arrays;
2324
import java.util.function.Function;
@@ -55,8 +56,8 @@ public static <M extends MeterRegistryConfig> Validated<?> checkAll(M config,
5556
* @return A function which, given a configuration instance, validates the property.
5657
*/
5758
@SuppressWarnings("unchecked")
58-
public static <M extends MeterRegistryConfig, T extends @Nullable Object> Function<M, Validated<T>> check(
59-
String property, Function<M, T> getter) {
59+
@NullUnmarked public static <M extends @NonNull MeterRegistryConfig, T> Function<M, Validated<T>> check(@NonNull String property,
60+
Function<M, T> getter) {
6061
return config -> {
6162
try {
6263
return Validated.valid(config.prefix() + '.' + property, getter.apply(config));
@@ -68,8 +69,8 @@ public static <M extends MeterRegistryConfig> Validated<?> checkAll(M config,
6869
};
6970
}
7071

71-
public static <M extends MeterRegistryConfig, T extends @Nullable Object> Function<M, Validated<T>> checkRequired(
72-
String property, Function<M, T> getter) {
72+
@NullUnmarked public static <M extends @NonNull MeterRegistryConfig, T> Function<M, Validated<T>> checkRequired(
73+
@NonNull String property, Function<M, T> getter) {
7374
return check(property, getter).andThen(Validated::required);
7475
}
7576

0 commit comments

Comments
 (0)