diff options
author | Oliver Nguyen <olivernguyen@google.com> | 2022-01-07 20:36:12 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2022-01-07 20:36:12 +0000 |
commit | cf92214db05a512b30c7c8f842855208ae450580 (patch) | |
tree | 6ccb427df3fbc4a579f685327e633b4b142d54a1 | |
parent | ff1df47683cfaca4e813db26f60a11c3766d78a7 (diff) | |
parent | 03781fd320e32cd09b8fab66e842404535072103 (diff) | |
download | jacoco-cf92214db05a512b30c7c8f842855208ae450580.tar.gz |
Always recreate the Agent instead of storing a singleton. am: 473f391baa am: 1e0518deed am: 2f9818da91 am: 03781fd320
Original change: https://android-review.googlesource.com/c/platform/external/jacoco/+/1940081
Change-Id: Ib144ecd763fe9834cb07b0a85f6d4fb11113c705
-rw-r--r-- | org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/Agent.java | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/Agent.java b/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/Agent.java index 45b7ccdd..c4bf874a 100644 --- a/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/Agent.java +++ b/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/Agent.java @@ -34,8 +34,6 @@ import org.jacoco.core.runtime.RuntimeData; */ public class Agent implements IAgent { - private static Agent singleton; - /** * Returns a global instance which is already started. If the method is * called the first time the instance is created with the given options. @@ -63,18 +61,15 @@ public class Agent implements IAgent { * @return global instance */ public static synchronized Agent getInstance(final AgentOptions options, RuntimeData data) { - if (singleton == null) { - final Agent agent = new Agent(options, IExceptionLogger.SYSTEM_ERR, data); - agent.startup(); - Runtime.getRuntime().addShutdownHook(new Thread() { - @Override - public void run() { - agent.shutdown(); - } - }); - singleton = agent; - } - return singleton; + final Agent agent = new Agent(options, IExceptionLogger.SYSTEM_ERR, data); + agent.startup(); + Runtime.getRuntime().addShutdownHook(new Thread() { + @Override + public void run() { + agent.shutdown(); + } + }); + return agent; } // END android-change @@ -93,9 +88,8 @@ public class Agent implements IAgent { public static synchronized Agent getInstance() throws IllegalStateException { // BEGIN android-change // throw new IllegalStateException("JaCoCo agent not started."); - singleton = Offline.createAgent(); + return Offline.createAgent(); // END android-change - return singleton; } private final AgentOptions options; |