From c350ef6daed053cf557cec7f14849510f0bce0b1 Mon Sep 17 00:00:00 2001 From: "Marc R. Hoffmann" Date: Mon, 5 Jul 2021 23:41:26 +0200 Subject: [PATCH 1/9] Retry exec file locking when file is locked from same JVM FileChannel.lock() throws OverlappingFileLockException when the file is locked from within the same JVM. This can happen when multiple JaCoCo agents are loaded by different classloaders --- .../rt/internal/output/FileOutputTest.java | 44 +++++++++++++++++-- .../agent/rt/internal/output/FileOutput.java | 31 ++++++++++++- 2 files changed, 70 insertions(+), 5 deletions(-) diff --git a/org.jacoco.agent.rt.test/src/org/jacoco/agent/rt/internal/output/FileOutputTest.java b/org.jacoco.agent.rt.test/src/org/jacoco/agent/rt/internal/output/FileOutputTest.java index fbb5a8cd9e..d4674d994a 100644 --- a/org.jacoco.agent.rt.test/src/org/jacoco/agent/rt/internal/output/FileOutputTest.java +++ b/org.jacoco.agent.rt.test/src/org/jacoco/agent/rt/internal/output/FileOutputTest.java @@ -16,7 +16,10 @@ import static org.junit.Assert.assertTrue; import java.io.File; +import java.io.FileOutputStream; import java.io.IOException; +import java.io.InterruptedIOException; +import java.nio.channels.OverlappingFileLockException; import org.jacoco.core.runtime.AgentOptions; import org.jacoco.core.runtime.RuntimeData; @@ -33,7 +36,7 @@ public class FileOutputTest { public TemporaryFolder folder = new TemporaryFolder(); @Test - public void testCreateDestFileOnStartup() throws Exception { + public void startup_should_create_empty_execfile() throws Exception { File destFile = folder.newFile("jacoco.exec"); AgentOptions options = new AgentOptions(); options.setDestfile(destFile.getAbsolutePath()); @@ -47,7 +50,7 @@ public void testCreateDestFileOnStartup() throws Exception { } @Test - public void testWriteData() throws Exception { + public void shutdown_should_write_execdata() throws Exception { File destFile = folder.newFile("jacoco.exec"); AgentOptions options = new AgentOptions(); options.setDestfile(destFile.getAbsolutePath()); @@ -63,7 +66,8 @@ public void testWriteData() throws Exception { } @Test(expected = IOException.class) - public void testInvalidDestFile() throws Exception { + public void startup_should_throw_IOException_when_execfile_cannot_be_created() + throws Exception { AgentOptions options = new AgentOptions(); options.setDestfile(folder.newFolder("folder").getAbsolutePath()); FileOutput controller = new FileOutput(); @@ -72,4 +76,38 @@ public void testInvalidDestFile() throws Exception { controller.startup(options, new RuntimeData()); } + @Test(expected = OverlappingFileLockException.class) + public void startup_should_throws_OverlappingFileLockException_when_execfile_is_permanently_locked() + throws Exception { + File destFile = folder.newFile("jacoco.exec"); + AgentOptions options = new AgentOptions(); + options.setDestfile(destFile.getAbsolutePath()); + + FileOutputStream out = new FileOutputStream(destFile); + try { + out.getChannel().lock(); + FileOutput controller = new FileOutput(); + controller.startup(options, new RuntimeData()); + } finally { + out.close(); + } + } + + @Test(expected = InterruptedIOException.class) + public void startup_should_throws_InterruptedIOException_when_execfile_is_locked_and_thread_is_interrupted() + throws Exception { + File destFile = folder.newFile("jacoco.exec"); + AgentOptions options = new AgentOptions(); + options.setDestfile(destFile.getAbsolutePath()); + + FileOutputStream out = new FileOutputStream(destFile); + try { + out.getChannel().lock(); + FileOutput controller = new FileOutput(); + Thread.currentThread().interrupt(); + controller.startup(options, new RuntimeData()); + } finally { + out.close(); + } + } } diff --git a/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/output/FileOutput.java b/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/output/FileOutput.java index 21b994fee9..50da62ebd5 100644 --- a/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/output/FileOutput.java +++ b/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/output/FileOutput.java @@ -15,7 +15,10 @@ import java.io.File; import java.io.FileOutputStream; import java.io.IOException; +import java.io.InterruptedIOException; import java.io.OutputStream; +import java.nio.channels.FileChannel; +import java.nio.channels.OverlappingFileLockException; import org.jacoco.core.data.ExecutionDataWriter; import org.jacoco.core.runtime.AgentOptions; @@ -31,6 +34,10 @@ */ public class FileOutput implements IAgentOutput { + private static final int LOCK_RETRY_COUNT = 30; + + private static final long LOCK_RETRY_WAIT_TIME_MS = 100; + private RuntimeData data; private File destFile; @@ -67,8 +74,28 @@ public void shutdown() throws IOException { private OutputStream openFile() throws IOException { final FileOutputStream file = new FileOutputStream(destFile, append); // Avoid concurrent writes from different agents running in parallel: - file.getChannel().lock(); - return file; + final FileChannel fc = file.getChannel(); + int retries = 0; + while (true) { + try { + // An agent from another JVM might have a lock. In this case + // this method blocks until the lock is freed. + fc.lock(); + return file; + } catch (final OverlappingFileLockException e) { + // In the case of multiple class loaders there can be multiple + // JaCoCo runtimes even in the same VM. In this case we get an + // OverlappingFileLockException and retry lock acquisition: + if (retries++ > LOCK_RETRY_COUNT) { + throw e; + } + } + try { + Thread.sleep(LOCK_RETRY_WAIT_TIME_MS); + } catch (final InterruptedException e) { + throw new InterruptedIOException(); + } + } } } From c74b0122bf77d35081a1dd0558388ce4c68d6111 Mon Sep 17 00:00:00 2001 From: "Marc R. Hoffmann" Date: Mon, 5 Jul 2021 23:41:31 +0200 Subject: [PATCH 2/9] OverlappingFileLockException only thrown since Java 1.6 --- org.jacoco.agent.rt.test/pom.xml | 4 ++++ .../agent/rt/internal/output/FileOutputTest.java | 12 ++++++++++++ .../org/jacoco/core/test/validation/JavaVersion.java | 7 +++++++ 3 files changed, 23 insertions(+) diff --git a/org.jacoco.agent.rt.test/pom.xml b/org.jacoco.agent.rt.test/pom.xml index bd7ef36cc7..290008ec70 100644 --- a/org.jacoco.agent.rt.test/pom.xml +++ b/org.jacoco.agent.rt.test/pom.xml @@ -33,6 +33,10 @@ ${project.groupId} org.jacoco.agent.rt + + ${project.groupId} + org.jacoco.core.test + junit junit diff --git a/org.jacoco.agent.rt.test/src/org/jacoco/agent/rt/internal/output/FileOutputTest.java b/org.jacoco.agent.rt.test/src/org/jacoco/agent/rt/internal/output/FileOutputTest.java index d4674d994a..dfbfae635b 100644 --- a/org.jacoco.agent.rt.test/src/org/jacoco/agent/rt/internal/output/FileOutputTest.java +++ b/org.jacoco.agent.rt.test/src/org/jacoco/agent/rt/internal/output/FileOutputTest.java @@ -23,6 +23,8 @@ import org.jacoco.core.runtime.AgentOptions; import org.jacoco.core.runtime.RuntimeData; +import org.jacoco.core.test.validation.JavaVersion; +import org.junit.AssumptionViolatedException; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; @@ -79,6 +81,11 @@ public void startup_should_throw_IOException_when_execfile_cannot_be_created() @Test(expected = OverlappingFileLockException.class) public void startup_should_throws_OverlappingFileLockException_when_execfile_is_permanently_locked() throws Exception { + if (JavaVersion.current().isBefore("1.6")) { + throw new AssumptionViolatedException( + "OverlappingFileLockException only thrown since Java 1.6"); + } + File destFile = folder.newFile("jacoco.exec"); AgentOptions options = new AgentOptions(); options.setDestfile(destFile.getAbsolutePath()); @@ -96,6 +103,11 @@ public void startup_should_throws_OverlappingFileLockException_when_execfile_is_ @Test(expected = InterruptedIOException.class) public void startup_should_throws_InterruptedIOException_when_execfile_is_locked_and_thread_is_interrupted() throws Exception { + if (JavaVersion.current().isBefore("1.6")) { + throw new AssumptionViolatedException( + "OverlappingFileLockException only thrown since Java 1.6"); + } + File destFile = folder.newFile("jacoco.exec"); AgentOptions options = new AgentOptions(); options.setDestfile(destFile.getAbsolutePath()); diff --git a/org.jacoco.core.test/src/org/jacoco/core/test/validation/JavaVersion.java b/org.jacoco.core.test/src/org/jacoco/core/test/validation/JavaVersion.java index a12c068beb..276d996c26 100644 --- a/org.jacoco.core.test/src/org/jacoco/core/test/validation/JavaVersion.java +++ b/org.jacoco.core.test/src/org/jacoco/core/test/validation/JavaVersion.java @@ -64,4 +64,11 @@ public boolean isBefore(final String version) { && this.update < other.update); } + /** + * @return Version of the current JVM + */ + public static JavaVersion current() { + return new JavaVersion(System.getProperty("java.version")); + } + } From 7a11b6b87238bf133d891d72f1d7071550c7443a Mon Sep 17 00:00:00 2001 From: "Marc R. Hoffmann" Date: Mon, 5 Jul 2021 23:41:38 +0200 Subject: [PATCH 3/9] Consolidate place to check current JDK version --- .../test/validation/java5/EnumSwitchTest.java | 3 ++- .../core/test/validation/java5/FinallyTest.java | 15 ++++++++------- .../validation/java7/TryWithResourcesTest.java | 13 +++++++------ .../validation/java8/BadCycleInterfaceTest.java | 7 ++++--- .../core/test/validation/ValidationTestBase.java | 3 --- 5 files changed, 21 insertions(+), 20 deletions(-) diff --git a/org.jacoco.core.test.validation.java5/src/org/jacoco/core/test/validation/java5/EnumSwitchTest.java b/org.jacoco.core.test.validation.java5/src/org/jacoco/core/test/validation/java5/EnumSwitchTest.java index eb87bb5b20..6840ffb632 100644 --- a/org.jacoco.core.test.validation.java5/src/org/jacoco/core/test/validation/java5/EnumSwitchTest.java +++ b/org.jacoco.core.test.validation.java5/src/org/jacoco/core/test/validation/java5/EnumSwitchTest.java @@ -12,6 +12,7 @@ *******************************************************************************/ package org.jacoco.core.test.validation.java5; +import org.jacoco.core.test.validation.JavaVersion; import org.jacoco.core.test.validation.Source.Line; import org.jacoco.core.test.validation.ValidationTestBase; import org.jacoco.core.test.validation.java5.targets.EnumSwitchTarget; @@ -27,7 +28,7 @@ public EnumSwitchTest() { } public void assertSwitch(final Line line) { - if (isJDKCompiler && JAVA_VERSION.isBefore("1.6")) { + if (isJDKCompiler && JavaVersion.current().isBefore("1.6")) { // class that holds "switch map" is not marked as synthetic when // compiling with javac 1.5 assertPartlyCovered(line, 0, 2); diff --git a/org.jacoco.core.test.validation.java5/src/org/jacoco/core/test/validation/java5/FinallyTest.java b/org.jacoco.core.test.validation.java5/src/org/jacoco/core/test/validation/java5/FinallyTest.java index d23d225d8d..0b02d5da7c 100644 --- a/org.jacoco.core.test.validation.java5/src/org/jacoco/core/test/validation/java5/FinallyTest.java +++ b/org.jacoco.core.test.validation.java5/src/org/jacoco/core/test/validation/java5/FinallyTest.java @@ -24,6 +24,7 @@ import org.jacoco.core.internal.instr.InstrSupport; import org.jacoco.core.test.TargetLoader; +import org.jacoco.core.test.validation.JavaVersion; import org.jacoco.core.test.validation.Source.Line; import org.jacoco.core.test.validation.ValidationTestBase; import org.jacoco.core.test.validation.java5.targets.FinallyTarget; @@ -62,7 +63,7 @@ public void assertFinally(final Line line) { } public void assertTwoRegions1(final Line line) { - if (isJDKCompiler && JAVA_VERSION.isBefore("1.8")) { + if (isJDKCompiler && JavaVersion.current().isBefore("1.8")) { // https://bugs.openjdk.java.net/browse/JDK-7008643 assertPartlyCovered(line); } else { @@ -71,7 +72,7 @@ public void assertTwoRegions1(final Line line) { } public void assertTwoRegionsReturn1(final Line line) { - if (isJDKCompiler && JAVA_VERSION.isBefore("1.8")) { + if (isJDKCompiler && JavaVersion.current().isBefore("1.8")) { // https://bugs.openjdk.java.net/browse/JDK-7008643 assertEmpty(line); } else { @@ -80,7 +81,7 @@ public void assertTwoRegionsReturn1(final Line line) { } public void assertTwoRegionsReturn2(final Line line) { - if (isJDKCompiler && JAVA_VERSION.isBefore("1.8")) { + if (isJDKCompiler && JavaVersion.current().isBefore("1.8")) { // https://bugs.openjdk.java.net/browse/JDK-7008643 assertEmpty(line); } else { @@ -89,7 +90,7 @@ public void assertTwoRegionsReturn2(final Line line) { } public void assertEmptyTry1(final Line line) { - if (isJDKCompiler && JAVA_VERSION.isBefore("1.8")) { + if (isJDKCompiler && JavaVersion.current().isBefore("1.8")) { // compiler bug fixed in javac >= 1.8: assertPartlyCovered(line); } else { @@ -98,7 +99,7 @@ public void assertEmptyTry1(final Line line) { } public void assertEmptyTry2(final Line line) { - if (isJDKCompiler && JAVA_VERSION.isBefore("1.8")) { + if (isJDKCompiler && JavaVersion.current().isBefore("1.8")) { // compiler bug fixed in javac >= 1.8: assertFullyCovered(line); } else { @@ -146,7 +147,7 @@ private void gotos() throws IOException { expected.add("breakStatement.for"); if (isJDKCompiler) { - if (JAVA_VERSION.isBefore("10")) { + if (JavaVersion.current().isBefore("10")) { // https://bugs.openjdk.java.net/browse/JDK-8180141 expected.add("breakStatement.1"); } else { @@ -179,7 +180,7 @@ private void gotos() throws IOException { expected.add("nested.3"); } - if (isJDKCompiler && JAVA_VERSION.isBefore("1.8")) { + if (isJDKCompiler && JavaVersion.current().isBefore("1.8")) { expected.add("emptyTry.2"); } diff --git a/org.jacoco.core.test.validation.java7/src/org/jacoco/core/test/validation/java7/TryWithResourcesTest.java b/org.jacoco.core.test.validation.java7/src/org/jacoco/core/test/validation/java7/TryWithResourcesTest.java index cdc535c611..ee922e575c 100644 --- a/org.jacoco.core.test.validation.java7/src/org/jacoco/core/test/validation/java7/TryWithResourcesTest.java +++ b/org.jacoco.core.test.validation.java7/src/org/jacoco/core/test/validation/java7/TryWithResourcesTest.java @@ -12,6 +12,7 @@ *******************************************************************************/ package org.jacoco.core.test.validation.java7; +import org.jacoco.core.test.validation.JavaVersion; import org.jacoco.core.test.validation.Source.Line; import org.jacoco.core.test.validation.ValidationTestBase; import org.jacoco.core.test.validation.java7.targets.TryWithResourcesTarget; @@ -28,7 +29,7 @@ public TryWithResourcesTest() { public void assertTry(final Line line) { // without filter this line is covered partly: - if (!isJDKCompiler || JAVA_VERSION.isBefore("11")) { + if (!isJDKCompiler || JavaVersion.current().isBefore("11")) { assertFullyCovered(line); } else { assertEmpty(line); @@ -40,7 +41,7 @@ public void assertReturnInBodyClose(final Line line) { if (isJDKCompiler) { // https://bugs.openjdk.java.net/browse/JDK-8134759 // javac 7 and 8 up to 8u92 are affected - if (JAVA_VERSION.isBefore("1.8.0_92")) { + if (JavaVersion.current().isBefore("1.8.0_92")) { assertFullyCovered(line); } else { assertEmpty(line); @@ -61,9 +62,9 @@ public void assertHandwritten(final Line line) { public void assertEmptyClose(final Line line) { if (!isJDKCompiler) { assertPartlyCovered(line, 7, 1); - } else if (JAVA_VERSION.isBefore("8")) { + } else if (JavaVersion.current().isBefore("8")) { assertPartlyCovered(line, 6, 2); - } else if (JAVA_VERSION.isBefore("9")) { + } else if (JavaVersion.current().isBefore("9")) { assertPartlyCovered(line, 2, 2); } else { assertFullyCovered(line); @@ -74,9 +75,9 @@ public void assertThrowInBodyClose(final Line line) { // not filtered if (!isJDKCompiler) { assertNotCovered(line, 6, 0); - } else if (JAVA_VERSION.isBefore("9")) { + } else if (JavaVersion.current().isBefore("9")) { assertNotCovered(line, 4, 0); - } else if (JAVA_VERSION.isBefore("11")) { + } else if (JavaVersion.current().isBefore("11")) { assertNotCovered(line); } else { assertEmpty(line); diff --git a/org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/java8/BadCycleInterfaceTest.java b/org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/java8/BadCycleInterfaceTest.java index 82bdc54a23..08ae5c2e58 100644 --- a/org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/java8/BadCycleInterfaceTest.java +++ b/org.jacoco.core.test.validation.java8/src/org/jacoco/core/test/validation/java8/BadCycleInterfaceTest.java @@ -12,6 +12,7 @@ *******************************************************************************/ package org.jacoco.core.test.validation.java8; +import org.jacoco.core.test.validation.JavaVersion; import org.jacoco.core.test.validation.Source.Line; import org.jacoco.core.test.validation.ValidationTestBase; import org.jacoco.core.test.validation.java8.targets.BadCycleInterfaceTarget; @@ -28,7 +29,7 @@ public BadCycleInterfaceTest() throws Exception { @Test public void method_execution_sequence() throws Exception { - if (JAVA_VERSION.isBefore("1.8.0_152")) { + if (JavaVersion.current().isBefore("1.8.0_152")) { assertLogEvents("baseclinit", "childdefaultmethod", "childclinit", "childstaticmethod"); } else { @@ -37,7 +38,7 @@ public void method_execution_sequence() throws Exception { } public void assertBaseClInit(final Line line) { - if (JAVA_VERSION.isBefore("1.8.0_152")) { + if (JavaVersion.current().isBefore("1.8.0_152")) { // Incorrect interpetation of JVMS 5.5 in JDK 8 causes a default // method to be called before the static initializer of an interface // (see JDK-8098557 and JDK-8164302): @@ -51,7 +52,7 @@ public void assertBaseClInit(final Line line) { } public void assertChildDefault(final Line line) throws Exception { - if (JAVA_VERSION.isBefore("1.8.0_152")) { + if (JavaVersion.current().isBefore("1.8.0_152")) { // Incorrect interpetation of JVMS 5.5 in JDK 8 causes a default // method to be called before the static initializer of an interface // (see JDK-8098557 and JDK-8164302): diff --git a/org.jacoco.core.test/src/org/jacoco/core/test/validation/ValidationTestBase.java b/org.jacoco.core.test/src/org/jacoco/core/test/validation/ValidationTestBase.java index 1d35126890..a9aed4e359 100644 --- a/org.jacoco.core.test/src/org/jacoco/core/test/validation/ValidationTestBase.java +++ b/org.jacoco.core.test/src/org/jacoco/core/test/validation/ValidationTestBase.java @@ -41,9 +41,6 @@ public abstract class ValidationTestBase { protected static final boolean isJDKCompiler = Compiler.DETECT.isJDK(); - protected static final JavaVersion JAVA_VERSION = new JavaVersion( - System.getProperty("java.version")); - private static final String[] STATUS_NAME = new String[4]; { From bc947066431fd3ae1265dbf793be8e2333c33acb Mon Sep 17 00:00:00 2001 From: "Marc R. Hoffmann" Date: Mon, 5 Jul 2021 23:41:43 +0200 Subject: [PATCH 4/9] Update change log --- org.jacoco.doc/docroot/doc/changes.html | 2 ++ 1 file changed, 2 insertions(+) diff --git a/org.jacoco.doc/docroot/doc/changes.html b/org.jacoco.doc/docroot/doc/changes.html index 128455ffda..033e6fe2f8 100644 --- a/org.jacoco.doc/docroot/doc/changes.html +++ b/org.jacoco.doc/docroot/doc/changes.html @@ -27,6 +27,8 @@

New Features

  • Part of bytecode generated by the Java compilers for assert statement is filtered out during generation of report (GitHub #1196).
  • +
  • Improved support for multiple JaCoCo runtimes in the same VM + (GitHub #1057).
  • Fixed bugs

    From 25a3cbb92cdb03e2dcbce00853f495d296961520 Mon Sep 17 00:00:00 2001 From: "Marc R. Hoffmann" Date: Tue, 6 Jul 2021 13:21:39 +0200 Subject: [PATCH 5/9] Review Comment: Use try/catch pattern for exception assertion --- .../rt/internal/output/FileOutputTest.java | 35 ++++++++++++------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/org.jacoco.agent.rt.test/src/org/jacoco/agent/rt/internal/output/FileOutputTest.java b/org.jacoco.agent.rt.test/src/org/jacoco/agent/rt/internal/output/FileOutputTest.java index dfbfae635b..8873025b2b 100644 --- a/org.jacoco.agent.rt.test/src/org/jacoco/agent/rt/internal/output/FileOutputTest.java +++ b/org.jacoco.agent.rt.test/src/org/jacoco/agent/rt/internal/output/FileOutputTest.java @@ -14,6 +14,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import java.io.File; import java.io.FileOutputStream; @@ -67,18 +68,22 @@ public void shutdown_should_write_execdata() throws Exception { destFile.length() > 0); } - @Test(expected = IOException.class) + @Test public void startup_should_throw_IOException_when_execfile_cannot_be_created() throws Exception { AgentOptions options = new AgentOptions(); options.setDestfile(folder.newFolder("folder").getAbsolutePath()); FileOutput controller = new FileOutput(); - // Startup should fail as the file can not be created: - controller.startup(options, new RuntimeData()); + try { + controller.startup(options, new RuntimeData()); + fail("IOException expected"); + } catch (IOException e) { + // expected + } } - @Test(expected = OverlappingFileLockException.class) + @Test public void startup_should_throws_OverlappingFileLockException_when_execfile_is_permanently_locked() throws Exception { if (JavaVersion.current().isBefore("1.6")) { @@ -89,18 +94,20 @@ public void startup_should_throws_OverlappingFileLockException_when_execfile_is_ File destFile = folder.newFile("jacoco.exec"); AgentOptions options = new AgentOptions(); options.setDestfile(destFile.getAbsolutePath()); - FileOutputStream out = new FileOutputStream(destFile); + out.getChannel().lock(); + FileOutput controller = new FileOutput(); + try { - out.getChannel().lock(); - FileOutput controller = new FileOutput(); controller.startup(options, new RuntimeData()); + fail("OverlappingFileLockException expected"); + } catch (OverlappingFileLockException e) { + // expected } finally { out.close(); } } - @Test(expected = InterruptedIOException.class) public void startup_should_throws_InterruptedIOException_when_execfile_is_locked_and_thread_is_interrupted() throws Exception { if (JavaVersion.current().isBefore("1.6")) { @@ -111,15 +118,19 @@ public void startup_should_throws_InterruptedIOException_when_execfile_is_locked File destFile = folder.newFile("jacoco.exec"); AgentOptions options = new AgentOptions(); options.setDestfile(destFile.getAbsolutePath()); - FileOutputStream out = new FileOutputStream(destFile); + out.getChannel().lock(); + FileOutput controller = new FileOutput(); + Thread.currentThread().interrupt(); + try { - out.getChannel().lock(); - FileOutput controller = new FileOutput(); - Thread.currentThread().interrupt(); controller.startup(options, new RuntimeData()); + fail("InterruptedIOException expected"); + } catch (InterruptedIOException e) { + // expected } finally { out.close(); } } + } From 6b4fa1b31090b0c5e792178b20e5c51d4c76238d Mon Sep 17 00:00:00 2001 From: "Marc R. Hoffmann" Date: Thu, 8 Jul 2021 10:42:28 +0200 Subject: [PATCH 6/9] Fix typo Co-authored-by: Evgeny Mandrikov <138671+Godin@users.noreply.github.com> --- .../src/org/jacoco/agent/rt/internal/output/FileOutputTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org.jacoco.agent.rt.test/src/org/jacoco/agent/rt/internal/output/FileOutputTest.java b/org.jacoco.agent.rt.test/src/org/jacoco/agent/rt/internal/output/FileOutputTest.java index 8873025b2b..be70abb26f 100644 --- a/org.jacoco.agent.rt.test/src/org/jacoco/agent/rt/internal/output/FileOutputTest.java +++ b/org.jacoco.agent.rt.test/src/org/jacoco/agent/rt/internal/output/FileOutputTest.java @@ -84,7 +84,7 @@ public void startup_should_throw_IOException_when_execfile_cannot_be_created() } @Test - public void startup_should_throws_OverlappingFileLockException_when_execfile_is_permanently_locked() + public void startup_should_throw_OverlappingFileLockException_when_execfile_is_permanently_locked() throws Exception { if (JavaVersion.current().isBefore("1.6")) { throw new AssumptionViolatedException( From dd60a525b204e42435bcf0af7aa18fac1e4c106d Mon Sep 17 00:00:00 2001 From: "Marc R. Hoffmann" Date: Thu, 8 Jul 2021 10:42:45 +0200 Subject: [PATCH 7/9] Review: Fix type Co-authored-by: Evgeny Mandrikov <138671+Godin@users.noreply.github.com> --- .../src/org/jacoco/agent/rt/internal/output/FileOutputTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org.jacoco.agent.rt.test/src/org/jacoco/agent/rt/internal/output/FileOutputTest.java b/org.jacoco.agent.rt.test/src/org/jacoco/agent/rt/internal/output/FileOutputTest.java index be70abb26f..7d9819ce1c 100644 --- a/org.jacoco.agent.rt.test/src/org/jacoco/agent/rt/internal/output/FileOutputTest.java +++ b/org.jacoco.agent.rt.test/src/org/jacoco/agent/rt/internal/output/FileOutputTest.java @@ -108,7 +108,7 @@ public void startup_should_throw_OverlappingFileLockException_when_execfile_is_p } } - public void startup_should_throws_InterruptedIOException_when_execfile_is_locked_and_thread_is_interrupted() + public void startup_should_throw_InterruptedIOException_when_execfile_is_locked_and_thread_is_interrupted() throws Exception { if (JavaVersion.current().isBefore("1.6")) { throw new AssumptionViolatedException( From d07386c47345e21de268d5350092de9329cb25d1 Mon Sep 17 00:00:00 2001 From: "Marc R. Hoffmann" Date: Thu, 8 Jul 2021 10:43:08 +0200 Subject: [PATCH 8/9] Review: Fix typo Co-authored-by: Evgeny Mandrikov <138671+Godin@users.noreply.github.com> --- .../src/org/jacoco/core/test/validation/JavaVersion.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org.jacoco.core.test/src/org/jacoco/core/test/validation/JavaVersion.java b/org.jacoco.core.test/src/org/jacoco/core/test/validation/JavaVersion.java index 276d996c26..e3ca5bcbf5 100644 --- a/org.jacoco.core.test/src/org/jacoco/core/test/validation/JavaVersion.java +++ b/org.jacoco.core.test/src/org/jacoco/core/test/validation/JavaVersion.java @@ -65,7 +65,7 @@ public boolean isBefore(final String version) { } /** - * @return Version of the current JVM + * @return version of the current JVM */ public static JavaVersion current() { return new JavaVersion(System.getProperty("java.version")); From de55b081937141742b95aa578ccaf25a073ee1c5 Mon Sep 17 00:00:00 2001 From: "Marc R. Hoffmann" Date: Thu, 8 Jul 2021 10:46:19 +0200 Subject: [PATCH 9/9] Review comment: Adjust test method naming to actual test case --- .../src/org/jacoco/agent/rt/internal/output/FileOutputTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org.jacoco.agent.rt.test/src/org/jacoco/agent/rt/internal/output/FileOutputTest.java b/org.jacoco.agent.rt.test/src/org/jacoco/agent/rt/internal/output/FileOutputTest.java index 7d9819ce1c..35080e10ba 100644 --- a/org.jacoco.agent.rt.test/src/org/jacoco/agent/rt/internal/output/FileOutputTest.java +++ b/org.jacoco.agent.rt.test/src/org/jacoco/agent/rt/internal/output/FileOutputTest.java @@ -53,7 +53,7 @@ public void startup_should_create_empty_execfile() throws Exception { } @Test - public void shutdown_should_write_execdata() throws Exception { + public void writeExecutionData_should_write_execdata() throws Exception { File destFile = folder.newFile("jacoco.exec"); AgentOptions options = new AgentOptions(); options.setDestfile(destFile.getAbsolutePath());