blob: b10d780e1b642e7415b2f4c9abc251223700c485 [file] [log] [blame]
From d49447aae32e1794dfc5d5e31c848d57e27d17a7 Mon Sep 17 00:00:00 2001
From: Liam Miller-Cushon <cushon@google.com>
Date: Thu, 28 Jan 2021 22:18:36 -0800
Subject: [PATCH 2/2] Partially revert 40c8fd89b0bc0c36e30e6a12f5b42d9da13aca86
See b/177687001#comment5.
---
.../org/jacoco/agent/rt/internal/Agent.java | 9 +++----
.../org/jacoco/agent/rt/internal/Offline.java | 24 +++++++------------
2 files changed, 11 insertions(+), 22 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 efb74846..bba5dd1d 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
@@ -44,11 +44,8 @@ public class Agent implements IAgent {
* @param options
* options to configure the instance
* @return global instance
- * @throws Exception
- * in case something cannot be initialized
*/
- public static synchronized Agent getInstance(final AgentOptions options)
- throws Exception {
+ public static synchronized Agent getInstance(final AgentOptions options) {
if (singleton == null) {
final Agent agent = new Agent(options, IExceptionLogger.SYSTEM_ERR);
agent.startup();
@@ -117,8 +114,9 @@ public class Agent implements IAgent {
*
* @throws Exception
* in case something cannot be initialized
+ *
*/
- public void startup() throws Exception {
+ public void startup() {
try {
String sessionId = options.getSessionId();
if (sessionId == null) {
@@ -132,7 +130,6 @@ public class Agent implements IAgent {
}
} catch (final Exception e) {
logger.logExeption(e);
- throw e;
}
}
diff --git a/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/Offline.java b/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/Offline.java
index 476c4e2b..70bb4e8a 100644
--- a/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/Offline.java
+++ b/org.jacoco.agent.rt/src/org/jacoco/agent/rt/internal/Offline.java
@@ -23,25 +23,17 @@ import org.jacoco.core.runtime.RuntimeData;
*/
public final class Offline {
+ private static final RuntimeData DATA;
private static final String CONFIG_RESOURCE = "/jacoco-agent.properties";
- private Offline() {
- // no instances
+ static {
+ final Properties config = ConfigLoader.load(CONFIG_RESOURCE,
+ System.getProperties());
+ DATA = Agent.getInstance(new AgentOptions(config)).getData();
}
- private static RuntimeData data;
-
- private static synchronized RuntimeData getRuntimeData() {
- if (data == null) {
- final Properties config = ConfigLoader.load(CONFIG_RESOURCE,
- System.getProperties());
- try {
- data = Agent.getInstance(new AgentOptions(config)).getData();
- } catch (final Exception e) {
- throw new RuntimeException("Failed to initialize JaCoCo.", e);
- }
- }
- return data;
+ private Offline() {
+ // no instances
}
/**
@@ -57,7 +49,7 @@ public final class Offline {
*/
public static boolean[] getProbes(final long classid,
final String classname, final int probecount) {
- return getRuntimeData()
+ return DATA
.getExecutionData(Long.valueOf(classid), classname, probecount)
.getProbes();
}
--
2.32.0.93.g670b81a890-goog