diff --git a/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/filewatch/FileSystemWatcher.java b/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/filewatch/FileSystemWatcher.java index 01675086a2..01bcb1b651 100644 --- a/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/filewatch/FileSystemWatcher.java +++ b/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/filewatch/FileSystemWatcher.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2020 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. @@ -124,7 +124,7 @@ public class FileSystemWatcher { */ public void addSourceFolder(File folder) { Assert.notNull(folder, "Folder must not be null"); - Assert.isTrue(!folder.isFile(), "Folder '" + folder + "' must not be a file"); + Assert.isTrue(!folder.isFile(), () -> "Folder '" + folder + "' must not be a file"); synchronized (this.monitor) { checkNotStarted(); this.folders.put(folder, null); diff --git a/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/filewatch/FolderSnapshot.java b/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/filewatch/FolderSnapshot.java index 52d49c2eb5..3838ccca21 100644 --- a/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/filewatch/FolderSnapshot.java +++ b/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/filewatch/FolderSnapshot.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2020 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. @@ -51,7 +51,7 @@ class FolderSnapshot { */ FolderSnapshot(File folder) { Assert.notNull(folder, "Folder must not be null"); - Assert.isTrue(!folder.isFile(), "Folder '" + folder + "' must not be a file"); + Assert.isTrue(!folder.isFile(), () -> "Folder '" + folder + "' must not be a file"); this.folder = folder; this.time = new Date(); Set files = new LinkedHashSet<>(); diff --git a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/build/ApiVersion.java b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/build/ApiVersion.java index 27e97c1029..fc03474503 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/build/ApiVersion.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/build/ApiVersion.java @@ -121,7 +121,7 @@ final class ApiVersion { static ApiVersion parse(String value) { Assert.hasText(value, "Value must not be empty"); Matcher matcher = PATTERN.matcher(value); - Assert.isTrue(matcher.matches(), "Malformed version number '" + value + "'"); + Assert.isTrue(matcher.matches(), () -> "Malformed version number '" + value + "'"); try { int major = Integer.parseInt(matcher.group(1)); int minor = Integer.parseInt(matcher.group(2)); diff --git a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/build/BuildOwner.java b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/build/BuildOwner.java index 372da10ecf..e1f8283a2c 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/build/BuildOwner.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/build/BuildOwner.java @@ -49,7 +49,7 @@ class BuildOwner implements Owner { private long getValue(Map env, String name) { String value = env.get(name); - Assert.state(StringUtils.hasText(value), "Missing '" + name + "' value from the builder environment"); + Assert.state(StringUtils.hasText(value), () -> "Missing '" + name + "' value from the builder environment"); try { return Long.parseLong(value); } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/build/BuilderMetadata.java b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/build/BuilderMetadata.java index 3d63fa7c69..4e5ee2b59f 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/build/BuilderMetadata.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/build/BuilderMetadata.java @@ -123,7 +123,7 @@ class BuilderMetadata extends MappedObject { Assert.notNull(imageConfig, "ImageConfig must not be null"); Map labels = imageConfig.getLabels(); String json = (labels != null) ? labels.get(LABEL_NAME) : null; - Assert.notNull(json, "No '" + LABEL_NAME + "' label found in image config"); + Assert.notNull(json, () -> "No '" + LABEL_NAME + "' label found in image config"); return fromJson(json); } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/build/StackId.java b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/build/StackId.java index 30d9f974fa..ad5c754122 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/build/StackId.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/build/StackId.java @@ -77,7 +77,7 @@ class StackId { private static StackId fromImageConfig(ImageConfig imageConfig) { Map labels = imageConfig.getLabels(); String value = (labels != null) ? labels.get(LABEL_NAME) : null; - Assert.state(StringUtils.hasText(value), "Missing '" + LABEL_NAME + "' stack label"); + Assert.state(StringUtils.hasText(value), () -> "Missing '" + LABEL_NAME + "' stack label"); return new StackId(value); } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/type/ImageReference.java b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/type/ImageReference.java index fe9f064343..ab42cde7e9 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/type/ImageReference.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/type/ImageReference.java @@ -151,7 +151,7 @@ public final class ImageReference { * @throws IllegalStateException if the image reference contains a digest */ public ImageReference inTaggedForm() { - Assert.state(this.digest == null, "Image reference '" + this + "' cannot contain a digest"); + Assert.state(this.digest == null, () -> "Image reference '" + this + "' cannot contain a digest"); return new ImageReference(this.name, (this.tag != null) ? this.tag : LATEST, this.digest); } @@ -163,7 +163,7 @@ public final class ImageReference { */ public static ImageReference forJarFile(File jarFile) { String filename = jarFile.getName(); - Assert.isTrue(filename.toLowerCase().endsWith(".jar"), "File '" + jarFile + "' is not a JAR"); + Assert.isTrue(filename.toLowerCase().endsWith(".jar"), () -> "File '" + jarFile + "' is not a JAR"); filename = filename.substring(0, filename.length() - 4); int firstDot = filename.indexOf('.'); if (firstDot == -1) { diff --git a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/type/LayerId.java b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/type/LayerId.java index ac3041e670..bec2d83f63 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/type/LayerId.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/type/LayerId.java @@ -85,7 +85,7 @@ public final class LayerId { public static LayerId of(String value) { Assert.hasText(value, "Value must not be empty"); int i = value.indexOf(':'); - Assert.isTrue(i >= 0, "Invalid layer ID '" + value + "'"); + Assert.isTrue(i >= 0, () -> "Invalid layer ID '" + value + "'"); return new LayerId(value, value.substring(0, i), value.substring(i + 1)); } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/type/VolumeName.java b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/type/VolumeName.java index bc522c899f..8a01d88a18 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/type/VolumeName.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/type/VolumeName.java @@ -124,7 +124,8 @@ public final class VolumeName { } private static String asHexString(byte[] digest, int digestLength) { - Assert.isTrue(digestLength <= digest.length, "DigestLength must be less than or equal to " + digest.length); + Assert.isTrue(digestLength <= digest.length, + () -> "DigestLength must be less than or equal to " + digest.length); byte[] shortDigest = new byte[6]; System.arraycopy(digest, 0, shortDigest, 0, shortDigest.length); return String.format("%0" + digestLength + "x", new BigInteger(1, shortDigest)); diff --git a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/json/MappedObject.java b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/json/MappedObject.java index 83e83408e9..1e51ef5e4b 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/json/MappedObject.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/json/MappedObject.java @@ -200,7 +200,7 @@ public class MappedObject { if (declaringClass == Object.class) { method.invoke(proxy, args); } - Assert.state(args == null || args.length == 0, "Unsupported method " + method); + Assert.state(args == null || args.length == 0, () -> "Unsupported method " + method); String name = getName(method.getName()); Class type = method.getReturnType(); return valueForProperty(name, type); diff --git a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/socket/BsdDomainSocket.java b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/socket/BsdDomainSocket.java index dd3525b3ed..4fdfeea642 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/socket/BsdDomainSocket.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/socket/BsdDomainSocket.java @@ -65,7 +65,7 @@ class BsdDomainSocket extends DomainSocket { public byte[] sunPath = new byte[MAX_PATH_LENGTH]; private SockaddrUn(byte sunFamily, byte[] path) { - Assert.isTrue(path.length < MAX_PATH_LENGTH, "Path cannot exceed " + MAX_PATH_LENGTH + " bytes"); + Assert.isTrue(path.length < MAX_PATH_LENGTH, () -> "Path cannot exceed " + MAX_PATH_LENGTH + " bytes"); System.arraycopy(path, 0, this.sunPath, 0, path.length); this.sunPath[path.length] = 0; this.sunLen = (byte) (fieldOffset("sunPath") + path.length); diff --git a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/socket/LinuxDomainSocket.java b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/socket/LinuxDomainSocket.java index b99f7ddd0c..24950d6c9f 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/socket/LinuxDomainSocket.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/socket/LinuxDomainSocket.java @@ -63,7 +63,7 @@ class LinuxDomainSocket extends DomainSocket { public byte[] sunPath = new byte[MAX_PATH_LENGTH]; private SockaddrUn(byte sunFamily, byte[] path) { - Assert.isTrue(path.length < MAX_PATH_LENGTH, "Path cannot exceed " + MAX_PATH_LENGTH + " bytes"); + Assert.isTrue(path.length < MAX_PATH_LENGTH, () -> "Path cannot exceed " + MAX_PATH_LENGTH + " bytes"); System.arraycopy(path, 0, this.sunPath, 0, path.length); this.sunPath[path.length] = 0; this.sunFamily = sunFamily; diff --git a/spring-boot-project/spring-boot-tools/spring-boot-jarmode-layertools/src/main/java/org/springframework/boot/jarmode/layertools/IndexedLayers.java b/spring-boot-project/spring-boot-tools/spring-boot-jarmode-layertools/src/main/java/org/springframework/boot/jarmode/layertools/IndexedLayers.java index 6b5f5a384a..f09e0d3f22 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-jarmode-layertools/src/main/java/org/springframework/boot/jarmode/layertools/IndexedLayers.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-jarmode-layertools/src/main/java/org/springframework/boot/jarmode/layertools/IndexedLayers.java @@ -69,7 +69,7 @@ class IndexedLayers implements Layers { Matcher matcher = LAYER_PATTERN.matcher(name); if (matcher.matches()) { String layer = matcher.group(1); - Assert.state(this.layers.contains(layer), "Unexpected layer '" + layer + "'"); + Assert.state(this.layers.contains(layer), () -> "Unexpected layer '" + layer + "'"); return layer; } return this.layers.contains(APPLICATION_LAYER) ? APPLICATION_LAYER : SPRING_BOOT_APPLICATION_LAYER; diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/ImagePackager.java b/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/ImagePackager.java index dad74aee02..9553cfc23f 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/ImagePackager.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/ImagePackager.java @@ -52,8 +52,8 @@ public class ImagePackager extends Packager { private void packageImage(Libraries libraries, AbstractJarWriter writer) throws IOException { File source = isAlreadyPackaged() ? getBackupFile() : getSource(); - Assert.state(source.exists() && source.isFile(), "Unable to read jar file " + source); - Assert.state(!isAlreadyPackaged(source), "Repackaged jar file " + source + " cannot be exported"); + Assert.state(source.exists() && source.isFile(), () -> "Unable to read jar file " + source); + Assert.state(!isAlreadyPackaged(source), () -> "Repackaged jar file " + source + " cannot be exported"); try (JarFile sourceJar = new JarFile(source)) { write(sourceJar, libraries, writer); } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/Layer.java b/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/Layer.java index 0f87ba4eeb..484bc2286c 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/Layer.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/Layer.java @@ -40,9 +40,9 @@ public class Layer { */ public Layer(String name) { Assert.hasText(name, "Name must not be empty"); - Assert.isTrue(PATTERN.matcher(name).matches(), "Malformed layer name '" + name + "'"); + Assert.isTrue(PATTERN.matcher(name).matches(), () -> "Malformed layer name '" + name + "'"); Assert.isTrue(!name.equalsIgnoreCase("ext") && !name.toLowerCase().startsWith("springboot"), - "Layer name '" + name + "' is reserved"); + () -> "Layer name '" + name + "' is reserved"); this.name = name; } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/Packager.java b/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/Packager.java index 5b6cb96b5b..5509b6e62e 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/Packager.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/Packager.java @@ -413,7 +413,7 @@ public abstract class Packager { private String transformName(String name) { if (this.layout instanceof LayeredLayout) { Layer layer = this.layers.getLayer(name); - Assert.state(layer != null, "Invalid 'null' layer from " + this.layers.getClass().getName()); + Assert.state(layer != null, () -> "Invalid 'null' layer from " + this.layers.getClass().getName()); return ((LayeredLayout) this.layout).getRepackagedClassesLocation(layer) + name; } return this.layout.getRepackagedClassesLocation() + name; @@ -455,7 +455,7 @@ public abstract class Packager { if (location != null) { String path = location + library.getName(); Library existing = this.libraries.putIfAbsent(path, library); - Assert.state(existing == null, "Duplicate library " + library.getName()); + Assert.state(existing == null, () -> "Duplicate library " + library.getName()); } } @@ -464,7 +464,7 @@ public abstract class Packager { if (layout instanceof LayeredLayout) { Layers layers = Packager.this.layers; Layer layer = layers.getLayer(library); - Assert.state(layer != null, "Invalid 'null' library layer from " + layers.getClass().getName()); + Assert.state(layer != null, () -> "Invalid 'null' library layer from " + layers.getClass().getName()); return ((LayeredLayout) layout).getLibraryLocation(library.getName(), library.getScope(), layer); } return layout.getLibraryLocation(library.getName(), library.getScope()); @@ -479,7 +479,7 @@ public abstract class Packager { @Override public String sha1Hash(String name) throws IOException { Library library = this.libraries.get(name); - Assert.notNull(library, "No library found for entry name '" + name + "'"); + Assert.notNull(library, () -> "No library found for entry name '" + name + "'"); return Digest.sha1(library::openStream); } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/PropertiesLauncher.java b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/PropertiesLauncher.java index a6dff5ae17..110ab7dbc7 100755 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/PropertiesLauncher.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/PropertiesLauncher.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2020 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. @@ -371,7 +371,7 @@ public class PropertiesLauncher extends Launcher { if (classLoader == null) { classLoader = newClassLoader(type, NO_PARAMS); } - Assert.notNull(classLoader, "Unable to create class loader for " + className); + Assert.notNull(classLoader, () -> "Unable to create class loader for " + className); return classLoader; } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/classpath/ModifiedClassPathExtension.java b/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/classpath/ModifiedClassPathExtension.java index 065ac45d19..0664e9d058 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/classpath/ModifiedClassPathExtension.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/classpath/ModifiedClassPathExtension.java @@ -118,7 +118,7 @@ class ModifiedClassPathExtension implements InvocationInterceptor { } } } - Assert.state(method != null, "Unable to find " + testClass + "." + testMethodName); + Assert.state(method != null, () -> "Unable to find " + testClass + "." + testMethodName); return method; }