Skip to content

Commit

Permalink
Ensure that a jar file is closed
Browse files Browse the repository at this point in the history
On Windows we get into trouble if this jar file is left open.  Windows
refuses to delete an open file, which then causes post-test `@TempDir`
cleanup to fail.
  • Loading branch information
liblit committed Aug 5, 2023
1 parent c7cb8ba commit 370a4c5
Showing 1 changed file with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -150,16 +150,18 @@ public void emitTo(Output w) {
}

private void write() throws IllegalStateException, IOException, InvalidClassFileException {
// Write all modified classes
for (ClassInstrumenter ci2 : classInstrumenters) {
if (ci2.isChanged()) {
ClassWriter cw = ci2.emitClass();
instrumenter.outputModifiedClass(ci2, cw);
try {
// Write all modified classes
for (ClassInstrumenter ci2 : classInstrumenters) {
if (ci2.isChanged()) {
ClassWriter cw = ci2.emitClass();
instrumenter.outputModifiedClass(ci2, cw);
}
}
} finally {
// Finally write the instrumented jar
instrumenter.close();
}

// Finally write the instrumented jar
instrumenter.close();
}

private void setValidationInstrumenter() throws IOException {
Expand Down

0 comments on commit 370a4c5

Please sign in to comment.