Attempt to fix Windows build failure due to open files
See gh-38204
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user