Skip to content

Commit 83eed6d

Browse files
antonisclaude
andcommitted
fix(feedback): restore original onFormClose to prevent callback chain growth
Save the user's original onFormClose once during register() and restore it after each dialog dismiss, instead of wrapping it with a new lambda each time. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 0cc2f3b commit 83eed6d

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

sentry-android-core/src/main/java/io/sentry/android/core/ShakeDetectionIntegration.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public final class ShakeDetectionIntegration
2727
private @Nullable SentryAndroidOptions options;
2828
private volatile @Nullable Activity currentActivity;
2929
private volatile boolean isDialogShowing = false;
30+
private @Nullable Runnable originalOnFormClose;
3031

3132
public ShakeDetectionIntegration(final @NotNull Application application) {
3233
this.application = Objects.requireNonNull(application, "Application is required");
@@ -41,6 +42,7 @@ public void register(final @NotNull IScopes scopes, final @NotNull SentryOptions
4142
}
4243

4344
addIntegrationToSdkVersion("ShakeDetection");
45+
originalOnFormClose = this.options.getFeedbackOptions().getOnFormClose();
4446
application.registerActivityLifecycleCallbacks(this);
4547
options.getLogger().log(SentryLevel.DEBUG, "ShakeDetectionIntegration installed.");
4648

@@ -111,15 +113,14 @@ private void startShakeDetection(final @NotNull Activity activity) {
111113
}
112114
try {
113115
isDialogShowing = true;
114-
final Runnable previousOnFormClose =
115-
options.getFeedbackOptions().getOnFormClose();
116116
options
117117
.getFeedbackOptions()
118118
.setOnFormClose(
119119
() -> {
120120
isDialogShowing = false;
121-
if (previousOnFormClose != null) {
122-
previousOnFormClose.run();
121+
options.getFeedbackOptions().setOnFormClose(originalOnFormClose);
122+
if (originalOnFormClose != null) {
123+
originalOnFormClose.run();
123124
}
124125
});
125126
options.getFeedbackOptions().getDialogHandler().showDialog(null, null);

0 commit comments

Comments
 (0)