From 590a754c3f8b67597a3342f72865b87476c9773c Mon Sep 17 00:00:00 2001 From: Siebe Krijgsman Date: Thu, 7 Mar 2024 09:44:31 +0100 Subject: [PATCH 1/5] Bump to next snapshot --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 91c73b2..d5a7f11 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.riscure trsfile - 2.2.5 + 2.2.6-SNAPSHOT jar ${project.groupId}:${project.artifactId} From 8bc43fc0262892c89b10904e42b640e4adf61961 Mon Sep 17 00:00:00 2001 From: Tom Hogervorst Date: Wed, 27 Nov 2024 13:46:03 +0100 Subject: [PATCH 2/5] #65: Reproduce issue in test --- src/test/java/TestTraceSet.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/test/java/TestTraceSet.java b/src/test/java/TestTraceSet.java index a865a88..235931c 100644 --- a/src/test/java/TestTraceSet.java +++ b/src/test/java/TestTraceSet.java @@ -663,4 +663,20 @@ void test61ReadLegacyTraceWithoutData() throws IOException, TRSFormatException { assertDoesNotThrow(() -> ts.get(0)); } } + + /** + * Test to reproduce Github issue #65: TRS files remain 'in use' after they have been closed + * Test this issue by opening and closing a file, and then checking whether the file can be deleted. + */ + @Test + void testFileReleasing() throws IOException, TRSFormatException, InterruptedException { + String filePath = tempDir.toAbsolutePath() + File.separator + BYTES_TRS; + // Open the file, and let the try-with-resources statement close it + try (TraceSet traceSet = TraceSet.open(filePath)) { + traceSet.getMetaData().getTraceSetParameters(); + } + // Assert that the opened file has been closed again, by deleting it. + File file = new File(filePath); + assert(file.delete()); + } } From 3162738667e79c6f0f84fda3a659d958bf2390fb Mon Sep 17 00:00:00 2001 From: Tom Hogervorst Date: Wed, 27 Nov 2024 13:54:39 +0100 Subject: [PATCH 3/5] #65: Delete memory mapped buffer on close Unfortunately, the current solution requires a garbage collect to have been performed before the issue is resolved. Other fixes required either a Java 8 Cleaner.clean() call not accessible from Java 21, or a Java 20 Arena.close(), which is not been finalized in Java 21. --- src/main/java/com/riscure/trs/TraceSet.java | 1 + src/test/java/TestTraceSet.java | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/src/main/java/com/riscure/trs/TraceSet.java b/src/main/java/com/riscure/trs/TraceSet.java index 4b7a5a9..85cf8dc 100644 --- a/src/main/java/com/riscure/trs/TraceSet.java +++ b/src/main/java/com/riscure/trs/TraceSet.java @@ -338,6 +338,7 @@ private void checkValid(Trace trace) { } private void closeReader() throws IOException { + buffer = null; readStream.close(); } diff --git a/src/test/java/TestTraceSet.java b/src/test/java/TestTraceSet.java index 235931c..ba6e132 100644 --- a/src/test/java/TestTraceSet.java +++ b/src/test/java/TestTraceSet.java @@ -675,6 +675,11 @@ void testFileReleasing() throws IOException, TRSFormatException, InterruptedExce try (TraceSet traceSet = TraceSet.open(filePath)) { traceSet.getMetaData().getTraceSetParameters(); } + // Unfortunately, the current solution requires a garbage collect to have been performed before the issue is resolved. + // Other fixes required either a Java 8 Cleaner.clean() call not accessible from Java 21, or a Java 20 Arena.close(), + // which is not been finalized in Java 21. + System.gc(); + Thread.sleep(1000); // Assert that the opened file has been closed again, by deleting it. File file = new File(filePath); assert(file.delete()); From 3e281371dad6505cbf8bd9f72ff789f4f5243d48 Mon Sep 17 00:00:00 2001 From: Matthijs Geers Date: Wed, 4 Dec 2024 17:35:37 +0100 Subject: [PATCH 4/5] Update maintainer info --- pom.xml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index d5a7f11..155fde2 100644 --- a/pom.xml +++ b/pom.xml @@ -11,10 +11,11 @@ ${project.groupId}:${project.artifactId} Inspector Trace Set `.trs` file support for Java. - Riscure Inspector uses the `.trs` file format to save and read traces from disk. To better assist reading and - writing trace set files from third parties, Riscure published this Java library. + Keysight Inspector uses the `.trs` file format to save and read traces from disk. To better assist reading and + writing trace set files from third parties, Keysight manages this Java library. Note that the library was + originally published by Riscure, which was acquired by Keysight in 2024. - https://github.com/Riscure/java-trsfile + https://github.com/Keysight/java-trsfile BSD 3-Clause Clear License @@ -23,9 +24,9 @@ - Riscure Team - Riscure - https://www.riscure.com + Riscure Security Solutions + Keysight Technologies + https://www.keysight.com From 3c58111d9714feb98a253fb9097970b6d39a7748 Mon Sep 17 00:00:00 2001 From: Matthijs Geers Date: Wed, 4 Dec 2024 17:35:52 +0100 Subject: [PATCH 5/5] Bump to release version --- README.md | 2 +- pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 517b886..e2e2ed1 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ This library is available on Maven Central. Use the following information to inc com.riscure trsfile - 2.2.5 + 2.2.6 #### Basic diff --git a/pom.xml b/pom.xml index 155fde2..e5de10a 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.riscure trsfile - 2.2.6-SNAPSHOT + 2.2.6 jar ${project.groupId}:${project.artifactId}