Skip to content

Commit 42f50fa

Browse files
committed
Attempt to fix CI failures
Attempt to fix CI failures caused by timezone differences and different JDK versions. See gh-37668
1 parent 5605279 commit 42f50fa

File tree

4 files changed

+15
-21
lines changed

4 files changed

+15
-21
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,8 @@ void streamStreamsEnties() throws IOException {
352352
assertThat(jar.stream().map((entry) -> entry.getName() + ":" + entry.getRealName())).containsExactly(
353353
"META-INF/:META-INF/", "META-INF/MANIFEST.MF:META-INF/MANIFEST.MF",
354354
"multi-release.dat:multi-release.dat",
355-
"META-INF/versions/17/multi-release.dat:META-INF/versions/17/multi-release.dat");
355+
"META-INF/versions/%1$d/multi-release.dat:META-INF/versions/%1$d/multi-release.dat"
356+
.formatted(TestJar.MULTI_JAR_VERSION));
356357
}
357358
}
358359

@@ -361,7 +362,8 @@ void versionedStreamStreamsEntries() throws IOException {
361362
try (NestedJarFile jar = new NestedJarFile(this.file, "multi-release.jar", Runtime.version())) {
362363
assertThat(jar.versionedStream().map((entry) -> entry.getName() + ":" + entry.getRealName()))
363364
.containsExactly("META-INF/:META-INF/", "META-INF/MANIFEST.MF:META-INF/MANIFEST.MF",
364-
"multi-release.dat:META-INF/versions/17/multi-release.dat");
365+
"multi-release.dat:META-INF/versions/%1$d/multi-release.dat"
366+
.formatted(TestJar.MULTI_JAR_VERSION));
365367
}
366368
}
367369

spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/launch/ExplodedArchiveTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ void getManifestReturnsManifest() throws Exception {
8585
}
8686

8787
@Test
88-
void getClassPathUrlsWhenNoPredicartesReturnsUrls() throws Exception {
88+
void getClassPathUrlsWhenNoPredicatesReturnsUrls() throws Exception {
8989
Set<URL> urls = this.archive.getClassPathUrls(Archive.ALL_ENTRIES);
9090
URL[] expectedUrls = TestJar.expectedEntries().stream().map(this::toUrl).toArray(URL[]::new);
9191
assertThat(urls).containsExactlyInAnyOrder(expectedUrls);
@@ -123,7 +123,7 @@ private void createArchive(String directoryName) throws Exception {
123123
Enumeration<JarEntry> entries = jarFile.entries();
124124
while (entries.hasMoreElements()) {
125125
JarEntry entry = entries.nextElement();
126-
File destination = new File(this.rootDirectory.getAbsolutePath() + File.separator + entry.getName());
126+
File destination = new File(this.rootDirectory, entry.getName());
127127
destination.getParentFile().mkdirs();
128128
if (entry.isDirectory()) {
129129
destination.mkdir();

spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/testsupport/TestJar.java

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,9 @@
3535
*/
3636
public abstract class TestJar {
3737

38-
private static final int BASE_VERSION = 8;
39-
40-
private static final int RUNTIME_VERSION;
38+
public static final int MULTI_JAR_VERSION = Runtime.version().feature();
4139

42-
static {
43-
int version;
44-
try {
45-
Object runtimeVersion = Runtime.class.getMethod("version").invoke(null);
46-
version = (int) runtimeVersion.getClass().getMethod("major").invoke(runtimeVersion);
47-
}
48-
catch (Throwable ex) {
49-
version = BASE_VERSION;
50-
}
51-
RUNTIME_VERSION = version;
52-
}
40+
private static final int BASE_VERSION = 8;
5341

5442
public static void create(File file) throws Exception {
5543
create(file, false);
@@ -120,8 +108,9 @@ private static byte[] getNestedJarData(boolean multiRelease) throws Exception {
120108
writeManifest(jarOutputStream, "j2", multiRelease);
121109
if (multiRelease) {
122110
writeEntry(jarOutputStream, "multi-release.dat", BASE_VERSION);
123-
writeEntry(jarOutputStream, String.format("META-INF/versions/%d/multi-release.dat", RUNTIME_VERSION),
124-
RUNTIME_VERSION);
111+
writeEntry(jarOutputStream,
112+
String.format("META-INF/versions/%d/multi-release.dat", MULTI_JAR_VERSION),
113+
MULTI_JAR_VERSION);
125114
}
126115
else {
127116
writeEntry(jarOutputStream, "3.dat", 3);

spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/zip/ZipCentralDirectoryFileHeaderRecordTests.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package org.springframework.boot.loader.zip;
1818

19+
import java.time.ZoneId;
20+
import java.time.ZonedDateTime;
1921
import java.util.zip.ZipEntry;
2022

2123
import org.junit.jupiter.api.Test;
@@ -129,7 +131,8 @@ void copyToCopiesDataToZipEntry() throws Exception {
129131
record.copyTo(dataBlock, 0, entry);
130132
assertThat(entry.getMethod()).isEqualTo(ZipEntry.DEFLATED);
131133
assertThat(entry.getTimeLocal()).hasYear(2007);
132-
assertThat(entry.getTime()).isEqualTo(1172356386000L);
134+
ZonedDateTime expectedTime = ZonedDateTime.of(2007, 02, 24, 14, 33, 06, 0, ZoneId.systemDefault());
135+
assertThat(entry.getTime()).isEqualTo(expectedTime.toEpochSecond() * 1000);
133136
assertThat(entry.getCrc()).isEqualTo(0xFFFFFFFFL);
134137
assertThat(entry.getCompressedSize()).isEqualTo(1);
135138
assertThat(entry.getSize()).isEqualTo(2);

0 commit comments

Comments
 (0)