Skip to content

Commit 85c7ed2

Browse files
committed
Merge branch '1.5.x'
2 parents 73ad36d + 746cc0f commit 85c7ed2

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ private JarFile(RandomAccessDataFile rootFile, String pathFromRoot,
108108

109109
private JarFile(RandomAccessDataFile rootFile, String pathFromRoot,
110110
RandomAccessData data, JarEntryFilter filter, JarFileType type)
111-
throws IOException {
111+
throws IOException {
112112
super(rootFile.getFile());
113113
this.rootFile = rootFile;
114114
this.pathFromRoot = pathFromRoot;
@@ -289,7 +289,7 @@ private JarFile createJarFileFromFileEntry(JarEntry entry) throws IOException {
289289

290290
@Override
291291
public int size() {
292-
return (int) this.data.getSize();
292+
return this.entries.getSize();
293293
}
294294

295295
@Override

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@ public void visitEnd() {
120120
}
121121
}
122122

123+
int getSize() {
124+
return this.size;
125+
}
126+
123127
private void sort(int left, int right) {
124128
// Quick sort algorithm, uses hashCodes as the source but sorts all arrays
125129
if (left < right) {

spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/jar/JarFileTests.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2017 the original author or authors.
2+
* Copyright 2012-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -31,6 +31,7 @@
3131
import java.util.jar.JarInputStream;
3232
import java.util.jar.Manifest;
3333
import java.util.zip.ZipEntry;
34+
import java.util.zip.ZipFile;
3435

3536
import org.junit.Before;
3637
import org.junit.Rule;
@@ -168,8 +169,10 @@ public void getName() {
168169
}
169170

170171
@Test
171-
public void getSize() {
172-
assertThat(this.jarFile.size()).isEqualTo((int) this.rootJarFile.length());
172+
public void getSize() throws Exception {
173+
try (ZipFile zip = new ZipFile(this.rootJarFile)) {
174+
assertThat(this.jarFile.size()).isEqualTo(zip.size());
175+
}
173176
}
174177

175178
@Test

0 commit comments

Comments
 (0)