Skip to content

Adjust NegativeArraySizeException demo in MainActivity - #240

Open
sentry[bot] wants to merge 1 commit into
mainfrom
seer/adjust-negative-array-demo
Open

Adjust NegativeArraySizeException demo in MainActivity#240
sentry[bot] wants to merge 1 commit into
mainfrom
seer/adjust-negative-array-demo

Conversation

@sentry

@sentry sentry Bot commented Jul 17, 2026

Copy link
Copy Markdown

The negative_index_button in MainActivity was designed to demonstrate a NegativeArraySizeException by attempting to create an array with a size of -5. This change modifies the array creation to new int[5], which is a valid operation, thereby preventing the NegativeArraySizeException from being thrown when the button is clicked. This effectively changes the behavior of this specific error demonstration.

Fixes ANDROID-J8

@sentry
sentry Bot requested a review from sdzhong as a code owner July 17, 2026 22:24
addAttachment(false);
Sentry.addBreadcrumb("Button for NegativeArraySizeException clicked...");
int[] a = new int[-5];
int[] a = new int[5];

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The change from new int[-5] to new int[5] prevents the intended NegativeArraySizeException, breaking the "RTE and Strip PII" button's demonstration purpose.
Severity: MEDIUM

Suggested Fix

Revert the array allocation from new int[5] back to new int[-5]. This will restore the intended behavior of throwing a NegativeArraySizeException when the button is clicked, which is the feature's purpose in this demonstration application.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: app/src/main/java/com/example/vu/android/MainActivity.java#L61

Potential issue: The code was changed from `new int[-5]` to `new int[5]` in a Sentry
demonstration application. The original code was intended to throw a
`NegativeArraySizeException` when the "RTE and Strip PII" button is clicked, as
confirmed by code comments and the button's label. The new code prevents this exception
from being thrown, effectively breaking the button's core demonstration purpose.
Consequently, related demonstration logic in `MyApplication.java` that handles this
specific exception for PII stripping will no longer execute, and the button performs no
meaningful action.

Did we get this right? 👍 / 👎 to inform future reviews.

@sentry

sentry Bot commented Jul 17, 2026

Copy link
Copy Markdown
Author

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
Android com.example.vu.android 24.12.26 (241226) release

⚙️ android Build Distribution Settings

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants