mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-08-29 03:06:45 +08:00
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:
parent
3af4930f75
commit
d5a70688cb
@ -41,6 +41,8 @@ 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"),
|
||||||
|
"Layer name '" + name + "' is reserved");
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,4 +59,14 @@ class LayerTests {
|
|||||||
assertThat(new Layer("test")).hasToString("test");
|
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");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user