parent
9fbaf7611b
commit
d8e2349e47
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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) {
|
public void addSourceFolder(File folder) {
|
||||||
Assert.notNull(folder, "Folder must not be null");
|
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) {
|
synchronized (this.monitor) {
|
||||||
checkNotStarted();
|
checkNotStarted();
|
||||||
this.folders.put(folder, null);
|
this.folders.put(folder, null);
|
||||||
|
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -51,7 +51,7 @@ class FolderSnapshot {
|
||||||
*/
|
*/
|
||||||
FolderSnapshot(File folder) {
|
FolderSnapshot(File folder) {
|
||||||
Assert.notNull(folder, "Folder must not be null");
|
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.folder = folder;
|
||||||
this.time = new Date();
|
this.time = new Date();
|
||||||
Set<FileSnapshot> files = new LinkedHashSet<>();
|
Set<FileSnapshot> files = new LinkedHashSet<>();
|
||||||
|
|
|
@ -121,7 +121,7 @@ final class ApiVersion {
|
||||||
static ApiVersion parse(String value) {
|
static ApiVersion parse(String value) {
|
||||||
Assert.hasText(value, "Value must not be empty");
|
Assert.hasText(value, "Value must not be empty");
|
||||||
Matcher matcher = PATTERN.matcher(value);
|
Matcher matcher = PATTERN.matcher(value);
|
||||||
Assert.isTrue(matcher.matches(), "Malformed version number '" + value + "'");
|
Assert.isTrue(matcher.matches(), () -> "Malformed version number '" + value + "'");
|
||||||
try {
|
try {
|
||||||
int major = Integer.parseInt(matcher.group(1));
|
int major = Integer.parseInt(matcher.group(1));
|
||||||
int minor = Integer.parseInt(matcher.group(2));
|
int minor = Integer.parseInt(matcher.group(2));
|
||||||
|
|
|
@ -49,7 +49,7 @@ class BuildOwner implements Owner {
|
||||||
|
|
||||||
private long getValue(Map<String, String> env, String name) {
|
private long getValue(Map<String, String> env, String name) {
|
||||||
String value = env.get(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 {
|
try {
|
||||||
return Long.parseLong(value);
|
return Long.parseLong(value);
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,7 +123,7 @@ class BuilderMetadata extends MappedObject {
|
||||||
Assert.notNull(imageConfig, "ImageConfig must not be null");
|
Assert.notNull(imageConfig, "ImageConfig must not be null");
|
||||||
Map<String, String> labels = imageConfig.getLabels();
|
Map<String, String> labels = imageConfig.getLabels();
|
||||||
String json = (labels != null) ? labels.get(LABEL_NAME) : null;
|
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);
|
return fromJson(json);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -77,7 +77,7 @@ class StackId {
|
||||||
private static StackId fromImageConfig(ImageConfig imageConfig) {
|
private static StackId fromImageConfig(ImageConfig imageConfig) {
|
||||||
Map<String, String> labels = imageConfig.getLabels();
|
Map<String, String> labels = imageConfig.getLabels();
|
||||||
String value = (labels != null) ? labels.get(LABEL_NAME) : null;
|
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);
|
return new StackId(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -151,7 +151,7 @@ public final class ImageReference {
|
||||||
* @throws IllegalStateException if the image reference contains a digest
|
* @throws IllegalStateException if the image reference contains a digest
|
||||||
*/
|
*/
|
||||||
public ImageReference inTaggedForm() {
|
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);
|
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) {
|
public static ImageReference forJarFile(File jarFile) {
|
||||||
String filename = jarFile.getName();
|
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);
|
filename = filename.substring(0, filename.length() - 4);
|
||||||
int firstDot = filename.indexOf('.');
|
int firstDot = filename.indexOf('.');
|
||||||
if (firstDot == -1) {
|
if (firstDot == -1) {
|
||||||
|
|
|
@ -85,7 +85,7 @@ public final class LayerId {
|
||||||
public static LayerId of(String value) {
|
public static LayerId of(String value) {
|
||||||
Assert.hasText(value, "Value must not be empty");
|
Assert.hasText(value, "Value must not be empty");
|
||||||
int i = value.indexOf(':');
|
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));
|
return new LayerId(value, value.substring(0, i), value.substring(i + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -124,7 +124,8 @@ public final class VolumeName {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String asHexString(byte[] digest, int digestLength) {
|
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];
|
byte[] shortDigest = new byte[6];
|
||||||
System.arraycopy(digest, 0, shortDigest, 0, shortDigest.length);
|
System.arraycopy(digest, 0, shortDigest, 0, shortDigest.length);
|
||||||
return String.format("%0" + digestLength + "x", new BigInteger(1, shortDigest));
|
return String.format("%0" + digestLength + "x", new BigInteger(1, shortDigest));
|
||||||
|
|
|
@ -200,7 +200,7 @@ public class MappedObject {
|
||||||
if (declaringClass == Object.class) {
|
if (declaringClass == Object.class) {
|
||||||
method.invoke(proxy, args);
|
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());
|
String name = getName(method.getName());
|
||||||
Class<?> type = method.getReturnType();
|
Class<?> type = method.getReturnType();
|
||||||
return valueForProperty(name, type);
|
return valueForProperty(name, type);
|
||||||
|
|
|
@ -65,7 +65,7 @@ class BsdDomainSocket extends DomainSocket {
|
||||||
public byte[] sunPath = new byte[MAX_PATH_LENGTH];
|
public byte[] sunPath = new byte[MAX_PATH_LENGTH];
|
||||||
|
|
||||||
private SockaddrUn(byte sunFamily, byte[] path) {
|
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);
|
System.arraycopy(path, 0, this.sunPath, 0, path.length);
|
||||||
this.sunPath[path.length] = 0;
|
this.sunPath[path.length] = 0;
|
||||||
this.sunLen = (byte) (fieldOffset("sunPath") + path.length);
|
this.sunLen = (byte) (fieldOffset("sunPath") + path.length);
|
||||||
|
|
|
@ -63,7 +63,7 @@ class LinuxDomainSocket extends DomainSocket {
|
||||||
public byte[] sunPath = new byte[MAX_PATH_LENGTH];
|
public byte[] sunPath = new byte[MAX_PATH_LENGTH];
|
||||||
|
|
||||||
private SockaddrUn(byte sunFamily, byte[] path) {
|
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);
|
System.arraycopy(path, 0, this.sunPath, 0, path.length);
|
||||||
this.sunPath[path.length] = 0;
|
this.sunPath[path.length] = 0;
|
||||||
this.sunFamily = sunFamily;
|
this.sunFamily = sunFamily;
|
||||||
|
|
|
@ -69,7 +69,7 @@ class IndexedLayers implements Layers {
|
||||||
Matcher matcher = LAYER_PATTERN.matcher(name);
|
Matcher matcher = LAYER_PATTERN.matcher(name);
|
||||||
if (matcher.matches()) {
|
if (matcher.matches()) {
|
||||||
String layer = matcher.group(1);
|
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 layer;
|
||||||
}
|
}
|
||||||
return this.layers.contains(APPLICATION_LAYER) ? APPLICATION_LAYER : SPRING_BOOT_APPLICATION_LAYER;
|
return this.layers.contains(APPLICATION_LAYER) ? APPLICATION_LAYER : SPRING_BOOT_APPLICATION_LAYER;
|
||||||
|
|
|
@ -52,8 +52,8 @@ public class ImagePackager extends Packager {
|
||||||
|
|
||||||
private void packageImage(Libraries libraries, AbstractJarWriter writer) throws IOException {
|
private void packageImage(Libraries libraries, AbstractJarWriter writer) throws IOException {
|
||||||
File source = isAlreadyPackaged() ? getBackupFile() : getSource();
|
File source = isAlreadyPackaged() ? getBackupFile() : getSource();
|
||||||
Assert.state(source.exists() && source.isFile(), "Unable to read jar file " + source);
|
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(!isAlreadyPackaged(source), () -> "Repackaged jar file " + source + " cannot be exported");
|
||||||
try (JarFile sourceJar = new JarFile(source)) {
|
try (JarFile sourceJar = new JarFile(source)) {
|
||||||
write(sourceJar, libraries, writer);
|
write(sourceJar, libraries, writer);
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,9 +40,9 @@ public class Layer {
|
||||||
*/
|
*/
|
||||||
public Layer(String name) {
|
public Layer(String name) {
|
||||||
Assert.hasText(name, "Name must not be empty");
|
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"),
|
Assert.isTrue(!name.equalsIgnoreCase("ext") && !name.toLowerCase().startsWith("springboot"),
|
||||||
"Layer name '" + name + "' is reserved");
|
() -> "Layer name '" + name + "' is reserved");
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -413,7 +413,7 @@ public abstract class Packager {
|
||||||
private String transformName(String name) {
|
private String transformName(String name) {
|
||||||
if (this.layout instanceof LayeredLayout) {
|
if (this.layout instanceof LayeredLayout) {
|
||||||
Layer layer = this.layers.getLayer(name);
|
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 ((LayeredLayout) this.layout).getRepackagedClassesLocation(layer) + name;
|
||||||
}
|
}
|
||||||
return this.layout.getRepackagedClassesLocation() + name;
|
return this.layout.getRepackagedClassesLocation() + name;
|
||||||
|
@ -455,7 +455,7 @@ public abstract class Packager {
|
||||||
if (location != null) {
|
if (location != null) {
|
||||||
String path = location + library.getName();
|
String path = location + library.getName();
|
||||||
Library existing = this.libraries.putIfAbsent(path, library);
|
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) {
|
if (layout instanceof LayeredLayout) {
|
||||||
Layers layers = Packager.this.layers;
|
Layers layers = Packager.this.layers;
|
||||||
Layer layer = layers.getLayer(library);
|
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 ((LayeredLayout) layout).getLibraryLocation(library.getName(), library.getScope(), layer);
|
||||||
}
|
}
|
||||||
return layout.getLibraryLocation(library.getName(), library.getScope());
|
return layout.getLibraryLocation(library.getName(), library.getScope());
|
||||||
|
@ -479,7 +479,7 @@ public abstract class Packager {
|
||||||
@Override
|
@Override
|
||||||
public String sha1Hash(String name) throws IOException {
|
public String sha1Hash(String name) throws IOException {
|
||||||
Library library = this.libraries.get(name);
|
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);
|
return Digest.sha1(library::openStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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) {
|
if (classLoader == null) {
|
||||||
classLoader = newClassLoader(type, NO_PARAMS);
|
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;
|
return classLoader;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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;
|
return method;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue