Don't close jar files early

Update `JarFile` and related classes so that `close()` is not longer
called early.

Prior to this commit, we would always immediately close the underlying
jar file to prevent file locking issues with our build. This causes
issues on certain JVMs when they attempt to verify a signed jar.

The file lock issues have now been solved by returning a custom input
stream from `JarUrlConnection` which captures and delegates the close
method.

Fixes gh-29356
This commit is contained in:
Phillip Webb
2022-06-14 20:46:51 -07:00
parent 49b71005de
commit b42f056ddb
9 changed files with 158 additions and 28 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -61,6 +61,7 @@ class JarFileWrapperTests {
@AfterEach
void cleanup() throws Exception {
this.parent.close();
this.wrapper.close();
}
private File createTempJar(File temp) throws IOException {