Skip to content

Commit

Permalink
Attempt to fix Windows build failure due to open files
Browse files Browse the repository at this point in the history
  • Loading branch information
philwebb committed Nov 8, 2023
1 parent f9c9f32 commit dbbde18
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -502,8 +502,14 @@ void getLastModifiedReturnsFileModifiedTime() throws Exception {
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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,14 @@ void getLastModifiedReturnsFileModifiedTime() throws Exception {
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) {
Expand Down

0 comments on commit dbbde18

Please sign in to comment.