summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit
diff options
context:
space:
mode:
authorAlexa Panfil <alexapizza@google.com>2020-10-23 17:23:23 +0000
committerMatthias Sohn <matthias.sohn@sap.com>2020-11-06 19:20:08 -0400
commit4f3161d3cc1af6ff725d6e7fb21909001df62705 (patch)
treeb5de206a0bb0d67b54df78e8c260f68d130a8d46 /org.eclipse.jgit
parentd76088bca6077579f5b8fe669147a31ce7bbd6ad (diff)
downloadjgit-4f3161d3cc1af6ff725d6e7fb21909001df62705.tar.gz
jgit-4f3161d3cc1af6ff725d6e7fb21909001df62705.zip
Fix bug in PerformanceLogContext
PerformanceLogContext threw NullPointerException when multiple threads tried to add an event to the PerformanceLogContext. The cause for this is that the ThreadLocal was initialized only in the class constructor for the first thread; for subsequent threads it was null. To fix this initialize eventRecords for each thread. Change-Id: I18ef67dff8f0488e3ad28c9bbc18ce73d5168cf9 Signed-off-by: Alexa Panfil <alexapizza@google.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/logging/PerformanceLogContext.java6
1 files changed, 3 insertions, 3 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/logging/PerformanceLogContext.java b/org.eclipse.jgit/src/org/eclipse/jgit/logging/PerformanceLogContext.java
index 4421efd7f3..fab0dd102a 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/logging/PerformanceLogContext.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/logging/PerformanceLogContext.java
@@ -24,10 +24,10 @@ public class PerformanceLogContext {
private static final PerformanceLogContext INSTANCE = new PerformanceLogContext();
/** List that stores events as performance logs. */
- private final ThreadLocal<List<PerformanceLogRecord>> eventRecords = new ThreadLocal<>();
+ private static final ThreadLocal<List<PerformanceLogRecord>> eventRecords = ThreadLocal
+ .withInitial(ArrayList::new);
private PerformanceLogContext() {
- eventRecords.set(new ArrayList<>());
}
/**
@@ -62,6 +62,6 @@ public class PerformanceLogContext {
* Removes all of the existing records from the current list of events.
*/
public void cleanEvents() {
- eventRecords.get().clear();
+ eventRecords.remove();
}
} \ No newline at end of file