diff --git a/spring-core-test/src/main/java/org/springframework/aot/agent/InstrumentedMethod.java b/spring-core-test/src/main/java/org/springframework/aot/agent/InstrumentedMethod.java index 153a16e9970..e8147920588 100644 --- a/spring-core-test/src/main/java/org/springframework/aot/agent/InstrumentedMethod.java +++ b/spring-core-test/src/main/java/org/springframework/aot/agent/InstrumentedMethod.java @@ -173,7 +173,6 @@ enum InstrumentedMethod { /** * {@link Class#getField(String)}. */ - @SuppressWarnings("NullAway") CLASS_GETFIELD(Class.class, "getField", HintType.REFLECTION, invocation -> { Field field = invocation.getReturnValue(); @@ -181,7 +180,7 @@ enum InstrumentedMethod { return runtimeHints -> false; } return reflection().onType(field.getDeclaringClass()) - .or(reflection().onField(invocation.getReturnValue())); + .or(reflection().onField(field)); }), /** diff --git a/spring-core/src/main/java/org/springframework/util/ClassUtils.java b/spring-core/src/main/java/org/springframework/util/ClassUtils.java index 5a66d209d5f..c764d681b7e 100644 --- a/spring-core/src/main/java/org/springframework/util/ClassUtils.java +++ b/spring-core/src/main/java/org/springframework/util/ClassUtils.java @@ -558,7 +558,7 @@ public abstract class ClassUtils { * @param clazz the class to check * @return the original class, or a primitive wrapper for the original primitive type */ - @SuppressWarnings("NullAway") + @SuppressWarnings("NullAway") // Dataflow analysis limitation public static Class resolvePrimitiveIfNecessary(Class clazz) { Assert.notNull(clazz, "Class must not be null"); return (clazz.isPrimitive() && clazz != void.class ? primitiveTypeToWrapperMap.get(clazz) : clazz); diff --git a/spring-core/src/main/java/org/springframework/util/InvalidMimeTypeException.java b/spring-core/src/main/java/org/springframework/util/InvalidMimeTypeException.java index 57783de953c..9762e04f508 100644 --- a/spring-core/src/main/java/org/springframework/util/InvalidMimeTypeException.java +++ b/spring-core/src/main/java/org/springframework/util/InvalidMimeTypeException.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 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. @@ -16,12 +16,15 @@ package org.springframework.util; +import org.jspecify.annotations.Nullable; + /** * Exception thrown from {@link MimeTypeUtils#parseMimeType(String)} in case of * encountering an invalid content type specification String. * * @author Juergen Hoeller * @author Rossen Stoyanchev + * @author Sebastien Deleuze * @since 4.0 */ @SuppressWarnings("serial") @@ -35,8 +38,10 @@ public class InvalidMimeTypeException extends IllegalArgumentException { * @param mimeType the offending media type * @param message a detail message indicating the invalid part */ - public InvalidMimeTypeException(String mimeType, String message) { - super("Invalid mime type \"" + mimeType + "\": " + message); + public InvalidMimeTypeException(String mimeType, @Nullable String message) { + super(message == null ? + "Invalid mime type \"" + mimeType + "\"" : + "Invalid mime type \"" + mimeType + "\": " + message); this.mimeType = mimeType; } diff --git a/spring-core/src/main/java/org/springframework/util/MimeTypeUtils.java b/spring-core/src/main/java/org/springframework/util/MimeTypeUtils.java index 06dbca09b3c..0139e1e5c18 100644 --- a/spring-core/src/main/java/org/springframework/util/MimeTypeUtils.java +++ b/spring-core/src/main/java/org/springframework/util/MimeTypeUtils.java @@ -203,7 +203,6 @@ public abstract class MimeTypeUtils { return cachedMimeTypes.get(mimeType); } - @SuppressWarnings("NullAway") private static MimeType parseMimeTypeInternal(String mimeType) { int index = mimeType.indexOf(';'); String fullType = (index >= 0 ? mimeType.substring(0, index) : mimeType).trim(); diff --git a/spring-core/src/main/java/org/springframework/util/NumberUtils.java b/spring-core/src/main/java/org/springframework/util/NumberUtils.java index 8ac49b93967..6cac75f70cd 100644 --- a/spring-core/src/main/java/org/springframework/util/NumberUtils.java +++ b/spring-core/src/main/java/org/springframework/util/NumberUtils.java @@ -236,7 +236,7 @@ public abstract class NumberUtils { * @see #convertNumberToTargetClass * @see #parseNumber(String, Class) */ - @SuppressWarnings("NullAway") + @SuppressWarnings("NullAway") // Dataflow analysis limitation public static T parseNumber( String text, Class targetClass, @Nullable NumberFormat numberFormat) {