Skip to content

Commit f40b086

Browse files
dreis2211wilkinsona
authored andcommitted
Optimize JarEntry construction
This commit avoids calling the underlying ZipEntry.setExtra() method that is not very inline friendly in cases where there is no extra information to be set. See gh-16620
1 parent fd14cd0 commit f40b086

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/CentralDirectoryFileHeader.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,10 @@ public byte[] getExtra() {
153153
return this.extra;
154154
}
155155

156+
public boolean hasExtra() {
157+
return this.extra.length > 0;
158+
}
159+
156160
public AsciiBytes getComment() {
157161
return this.comment;
158162
}

spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarEntry.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ class JarEntry extends java.util.jar.JarEntry implements FileHeader {
5656
setComment(header.getComment().toString());
5757
setSize(header.getSize());
5858
setTime(header.getTime());
59-
setExtra(header.getExtra());
59+
if (header.hasExtra()) {
60+
setExtra(header.getExtra());
61+
}
6062
}
6163

6264
AsciiBytes getAsciiBytesName() {

0 commit comments

Comments
 (0)