Browse Source

Improve null-safety of module/spring-boot-devtools

See gh-47263
pull/47415/head
Moritz Halbritter 3 months ago
parent
commit
58e2f9c872
  1. 4
      module/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/classpath/PatternClassPathRestartStrategy.java
  2. 2
      module/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/classloader/ClassLoaderFile.java
  3. 2
      module/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/classloader/ClassLoaderFileRepository.java
  4. 2
      module/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/classloader/ClassLoaderFiles.java

4
module/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/classpath/PatternClassPathRestartStrategy.java

@ -16,6 +16,8 @@
package org.springframework.boot.devtools.classpath; package org.springframework.boot.devtools.classpath;
import org.jspecify.annotations.Nullable;
import org.springframework.boot.devtools.filewatch.ChangedFile; import org.springframework.boot.devtools.filewatch.ChangedFile;
import org.springframework.util.AntPathMatcher; import org.springframework.util.AntPathMatcher;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
@ -37,7 +39,7 @@ public class PatternClassPathRestartStrategy implements ClassPathRestartStrategy
this.excludePatterns = excludePatterns; this.excludePatterns = excludePatterns;
} }
public PatternClassPathRestartStrategy(String excludePatterns) { public PatternClassPathRestartStrategy(@Nullable String excludePatterns) {
this(StringUtils.commaDelimitedListToStringArray(excludePatterns)); this(StringUtils.commaDelimitedListToStringArray(excludePatterns));
} }

2
module/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/classloader/ClassLoaderFile.java

@ -47,7 +47,7 @@ public class ClassLoaderFile implements Serializable {
* @param kind the kind of file * @param kind the kind of file
* @param contents the file contents * @param contents the file contents
*/ */
public ClassLoaderFile(Kind kind, byte[] contents) { public ClassLoaderFile(Kind kind, byte @Nullable [] contents) {
this(kind, System.currentTimeMillis(), contents); this(kind, System.currentTimeMillis(), contents);
} }

2
module/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/classloader/ClassLoaderFileRepository.java

@ -41,6 +41,6 @@ public interface ClassLoaderFileRepository {
* @param name the name of the file * @param name the name of the file
* @return a {@link ClassLoaderFile} or {@code null} * @return a {@link ClassLoaderFile} or {@code null}
*/ */
@Nullable ClassLoaderFile getFile(String name); @Nullable ClassLoaderFile getFile(@Nullable String name);
} }

2
module/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/classloader/ClassLoaderFiles.java

@ -143,7 +143,7 @@ public class ClassLoaderFiles implements ClassLoaderFileRepository, Serializable
} }
@Override @Override
public @Nullable ClassLoaderFile getFile(String name) { public @Nullable ClassLoaderFile getFile(@Nullable String name) {
return this.filesByName.get(name); return this.filesByName.get(name);
} }

Loading…
Cancel
Save