Skip to content

Commit 301cc33

Browse files
antonisclaude
andcommitted
fix(feedback): capture onFormClose as local variable in lambda
The onFormClose lambda was reading previousOnFormClose field at dismiss time. If onActivityResumed or onActivityDestroyed already restored and nulled the field, the lambda would overwrite onFormClose with null. Now captured as a local variable at dialog creation time. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 8b9bab2 commit 301cc33

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/FeedbackShakeIntegration.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,15 +145,16 @@ private void startShakeDetection(final @NotNull Activity activity) {
145145
}
146146
try {
147147
isDialogShowing = true;
148-
previousOnFormClose = options.getFeedbackOptions().getOnFormClose();
148+
final Runnable captured = options.getFeedbackOptions().getOnFormClose();
149+
previousOnFormClose = captured;
149150
options
150151
.getFeedbackOptions()
151152
.setOnFormClose(
152153
() -> {
153154
isDialogShowing = false;
154-
options.getFeedbackOptions().setOnFormClose(previousOnFormClose);
155-
if (previousOnFormClose != null) {
156-
previousOnFormClose.run();
155+
options.getFeedbackOptions().setOnFormClose(captured);
156+
if (captured != null) {
157+
captured.run();
157158
}
158159
previousOnFormClose = null;
159160
});

0 commit comments

Comments
 (0)