Attempt to fix Windows build failure due to open files

See gh-38204
This commit is contained in:
Phillip Webb
2023-11-08 07:02:35 -08:00
parent f9c9f3228d
commit dbbde18d41
2 changed files with 16 additions and 5 deletions

View File

@@ -502,8 +502,14 @@ class JarUrlConnectionTests {
void getLastModifiedHeaderReturnsFileModifiedTime() throws IOException {
JarUrlConnection connection = JarUrlConnection.open(this.url);
URLConnection fileConnection = this.file.toURI().toURL().openConnection();
assertThat(connection.getHeaderFieldDate("last-modified", 0)).isEqualTo(withoutNanos(this.file.lastModified()))
.isEqualTo(fileConnection.getHeaderFieldDate("last-modified", 0));
try {
assertThat(connection.getHeaderFieldDate("last-modified", 0))
.isEqualTo(withoutNanos(this.file.lastModified()))
.isEqualTo(fileConnection.getHeaderFieldDate("last-modified", 0));
}
finally {
fileConnection.getInputStream().close();
}
}
private long withoutNanos(long epochMilli) {

View File

@@ -162,9 +162,14 @@ class NestedUrlConnectionTests {
void getLastModifiedHeaderReturnsFileModifiedTime() throws IOException {
NestedUrlConnection connection = new NestedUrlConnection(this.url);
URLConnection fileConnection = this.jarFile.toURI().toURL().openConnection();
assertThat(connection.getHeaderFieldDate("last-modified", 0))
.isEqualTo(withoutNanos(this.jarFile.lastModified()))
.isEqualTo(fileConnection.getHeaderFieldDate("last-modified", 0));
try {
assertThat(connection.getHeaderFieldDate("last-modified", 0))
.isEqualTo(withoutNanos(this.jarFile.lastModified()))
.isEqualTo(fileConnection.getHeaderFieldDate("last-modified", 0));
}
finally {
fileConnection.getInputStream().close();
}
}
private long withoutNanos(long epochMilli) {