Skip to content

Commit

Permalink
Fix concurrent access to frameMetrics listener (#2823)
Browse files Browse the repository at this point in the history
* changed metrics listener map from HashMap to ConcurrentHashMap
* trackedWindows is now a CopyOnWriteArraySet
  • Loading branch information
stefanosiano committed Jul 10, 2023
1 parent f274c79 commit 5fe0117
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Unreleased

### Fixes

- Fix concurrent access to frameMetrics listener ([#2823](https://github.com/getsentry/sentry-java/pull/2823))

## 6.25.0

### Features
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,24 @@
import io.sentry.util.Objects;
import java.lang.ref.WeakReference;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArraySet;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

@ApiStatus.Internal
public final class SentryFrameMetricsCollector implements Application.ActivityLifecycleCallbacks {
private final @NotNull BuildInfoProvider buildInfoProvider;
private final @NotNull Set<Window> trackedWindows = new HashSet<>();
private final @NotNull Set<Window> trackedWindows = new CopyOnWriteArraySet<>();
private final @NotNull SentryOptions options;
private @Nullable Handler handler;
private @Nullable WeakReference<Window> currentWindow;
private final @NotNull HashMap<String, FrameMetricsCollectorListener> listenerMap =
new HashMap<>();
private final @NotNull Map<String, FrameMetricsCollectorListener> listenerMap =
new ConcurrentHashMap<>();
private boolean isAvailable = false;
private final WindowFrameMetricsManager windowFrameMetricsManager;

Expand Down

0 comments on commit 5fe0117

Please sign in to comment.