Skip to content

Commit f8b7507

Browse files
committed
Merge branch '3.4.x'
Closes gh-45449
2 parents f892872 + 84ed182 commit f8b7507

File tree

1 file changed

+18
-15
lines changed
  • spring-boot-project/spring-boot-tools/spring-boot-jarmode-tools/src/main/java/org/springframework/boot/jarmode/tools

1 file changed

+18
-15
lines changed

spring-boot-project/spring-boot-tools/spring-boot-jarmode-tools/src/main/java/org/springframework/boot/jarmode/tools/IndexedLayers.java

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ class IndexedLayers implements Layers {
4545

4646
private final Map<String, List<String>> layers = new LinkedHashMap<>();
4747

48-
private final String classesLocation;
48+
private final String indexFileLocation;
4949

50-
IndexedLayers(String indexFile, String classesLocation) {
51-
this.classesLocation = classesLocation;
50+
IndexedLayers(String indexFile, String indexFileLocation) {
51+
this.indexFileLocation = indexFileLocation;
5252
String[] lines = Arrays.stream(indexFile.split("\n"))
5353
.map((line) -> line.replace("\r", ""))
5454
.filter(StringUtils::hasText)
@@ -72,7 +72,7 @@ else if (line.startsWith(" - ")) {
7272

7373
@Override
7474
public String getApplicationLayerName() {
75-
return getLayer(this.classesLocation);
75+
return getLayer(this.indexFileLocation);
7676
}
7777

7878
@Override
@@ -99,18 +99,21 @@ public String getLayer(String name) {
9999
* jar.
100100
*/
101101
static IndexedLayers get(Context context) {
102-
try {
103-
try (JarFile jarFile = new JarFile(context.getArchiveFile())) {
104-
Manifest manifest = jarFile.getManifest();
105-
String location = manifest.getMainAttributes().getValue("Spring-Boot-Layers-Index");
106-
ZipEntry entry = (location != null) ? jarFile.getEntry(location) : null;
107-
if (entry != null) {
108-
String indexFile = StreamUtils.copyToString(jarFile.getInputStream(entry), StandardCharsets.UTF_8);
109-
String classesLocation = manifest.getMainAttributes().getValue("Spring-Boot-Classes");
110-
return new IndexedLayers(indexFile, classesLocation);
111-
}
102+
try (JarFile jarFile = new JarFile(context.getArchiveFile())) {
103+
Manifest manifest = jarFile.getManifest();
104+
if (manifest == null) {
105+
return null;
112106
}
113-
return null;
107+
String indexFileLocation = manifest.getMainAttributes().getValue("Spring-Boot-Layers-Index");
108+
if (indexFileLocation == null) {
109+
return null;
110+
}
111+
ZipEntry entry = jarFile.getEntry(indexFileLocation);
112+
if (entry == null) {
113+
return null;
114+
}
115+
String indexFile = StreamUtils.copyToString(jarFile.getInputStream(entry), StandardCharsets.UTF_8);
116+
return new IndexedLayers(indexFile, indexFileLocation);
114117
}
115118
catch (FileNotFoundException | NoSuchFileException ex) {
116119
return null;

0 commit comments

Comments
 (0)