Reserve layer names for future use
Update layered jar support so that the name `ext` and any name starting `springboot` are reserved. See gh-19767
This commit is contained in:
@@ -41,6 +41,8 @@ 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(!name.equalsIgnoreCase("ext") && !name.toLowerCase().startsWith("springboot"),
|
||||
"Layer name '" + name + "' is reserved");
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
@@ -59,4 +59,14 @@ class LayerTests {
|
||||
assertThat(new Layer("test")).hasToString("test");
|
||||
}
|
||||
|
||||
@Test
|
||||
void createWhenUsingReservedNameThrowsException() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new Layer("ext"))
|
||||
.withMessage("Layer name 'ext' is reserved");
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new Layer("ExT"))
|
||||
.withMessage("Layer name 'ExT' is reserved");
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new Layer("springbootloader"))
|
||||
.withMessage("Layer name 'springbootloader' is reserved");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user