Skip to content

Fix NullPointerException in JavaBreakpoint.deregisterRequest when marker is null#44

Open
Copilot wants to merge 3 commits intomasterfrom
copilot/fix-nullpointer-exception-bug
Open

Fix NullPointerException in JavaBreakpoint.deregisterRequest when marker is null#44
Copilot wants to merge 3 commits intomasterfrom
copilot/fix-nullpointer-exception-bug

Conversation

Copy link
Copy Markdown

Copilot AI commented Feb 1, 2026

getMarker() can return null when a breakpoint is deregistered after its marker has been deleted. The existing code called .exists() without a null check, causing NPE.

Changes

  • Added null check before marker.exists() call
  • Stored marker in local variable to eliminate redundant getMarker() invocations

Before:

if (!(request instanceof ClassPrepareRequest) && getMarker().exists()) {
    decrementInstallCount();
}

After:

IMarker marker = getMarker();
if (!(request instanceof ClassPrepareRequest) && marker != null && marker.exists()) {
    decrementInstallCount();
}

Related to Bug 576200 (Stale Breakpoint Confusion) and Bug 354784 (DebugException: Breakpoint does not have an associated marker).

Original prompt

Problem

In org.eclipse.jdt.debug/model/org/eclipse/jdt/internal/debug/core/breakpoints/JavaBreakpoint.java, line 289, there is a potential NullPointerException when getMarker() returns null:

if (!(request instanceof ClassPrepareRequest) && getMarker().exists()) {
    decrementInstallCount();
}

This can happen when a breakpoint is being deregistered because the marker has already been deleted. The comment above even acknowledges this scenario:

// A request may be getting de-registered because the breakpoint has
// been deleted. It may be that this occurred because of a marker
// deletion.
// Don't try updating the marker (decrementing the install count) if
// it no longer exists.

However, the code doesn't properly guard against getMarker() returning null - it only checks if the marker exists, but calling .exists() on a null reference throws a NullPointerException.

This is related to GitHub Issue eclipse-jdt#55 (Stale Breakpoints and marker mismatch) and the underlying Eclipse bugs:

  • Bug 576200 - Stale Breakpoint Confusion
  • Bug 354784 - DebugException: Breakpoint does not have an associated marker

Solution

Add a null check before calling .exists():

Before:

if (!(request instanceof ClassPrepareRequest) && getMarker().exists()) {

After:

if (!(request instanceof ClassPrepareRequest) && getMarker() != null && getMarker().exists()) {

File to modify

org.eclipse.jdt.debug/model/org/eclipse/jdt/internal/debug/core/breakpoints/JavaBreakpoint.java

Line 289 in the deregisterRequest method.

This pull request was created from Copilot chat.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Fix potential NullPointerException in JavaBreakpoint Fix NullPointerException in JavaBreakpoint.deregisterRequest when marker is null Feb 1, 2026
Copilot AI requested a review from carstenartur February 1, 2026 08:14
@carstenartur carstenartur marked this pull request as ready for review February 2, 2026 04:51
@carstenartur
Copy link
Copy Markdown
Owner

@copilot how can I rebase on followupstream branch?

Copy link
Copy Markdown
Author

Copilot AI commented Feb 2, 2026

@copilot how can I rebase on followupstream branch?

I cannot perform git rebase operations directly. However, you can rebase this branch onto an upstream branch yourself with these steps:

  1. First, add the upstream remote if not already added:

    git remote add upstream https://github.com/eclipse-jdt/eclipse.jdt.debug.git
  2. Fetch the upstream branches:

    git fetch upstream
  3. Rebase your branch onto the upstream branch:

    git rebase upstream/master

    (Replace master with the specific upstream branch name you want to rebase onto)

  4. If there are conflicts, resolve them and continue:

    git add .
    git rebase --continue
  5. Force push to update your PR:

    git push --force-with-lease origin copilot/fix-nullpointer-exception-bug

Note: If "followupstream" is a specific branch name, use that instead of "master" in step 3.

@carstenartur
Copy link
Copy Markdown
Owner

/rebase-upstream

@github-actions
Copy link
Copy Markdown

github-actions bot commented Feb 3, 2026

❌ Rebase failed due to conflicts.

To rebase manually:

git remote add upstream https://github.com/eclipse-jdt/eclipse.jdt.debug.git
git fetch upstream master
git rebase upstream/master
# Resolve conflicts
git rebase --continue
git push --force-with-lease

@github-actions github-actions bot force-pushed the copilot/fix-nullpointer-exception-bug branch from 132c878 to e715843 Compare February 3, 2026 02:20
@carstenartur
Copy link
Copy Markdown
Owner

/rebase-upstream

@github-actions
Copy link
Copy Markdown

github-actions bot commented Feb 3, 2026

✅ Successfully rebased onto eclipse-jdt/eclipse.jdt.debug:master

@github-actions github-actions bot force-pushed the copilot/fix-nullpointer-exception-bug branch 2 times, most recently from f515555 to 1261e54 Compare February 3, 2026 03:59
@carstenartur
Copy link
Copy Markdown
Owner

/rebase-upstream

Copilot AI and others added 3 commits February 3, 2026 04:30
Co-authored-by: carstenartur <3164220+carstenartur@users.noreply.github.com>
Co-authored-by: carstenartur <3164220+carstenartur@users.noreply.github.com>
@github-actions github-actions bot force-pushed the copilot/fix-nullpointer-exception-bug branch from 1261e54 to 604298d Compare February 3, 2026 04:30
@github-actions
Copy link
Copy Markdown

github-actions bot commented Feb 3, 2026

❌ Rebase succeeded but push failed due to insufficient permissions.

Possible causes:

  • The PR author has not enabled "Allow edits by maintainers"
  • The fork repository has restricted push access

To enable automatic rebase:

  1. Go to the PR page
  2. Check "Allow edits by maintainers" in the sidebar
  3. Try the /rebase-upstream command again

Or rebase manually:

git remote add upstream https://github.com/eclipse-jdt/eclipse.jdt.debug.git
git fetch upstream master

# Determine the number of commits in your PR
# You can find this on the PR page under "Commits" tab
# Example: if your PR has 3 commits, set PR_COMMIT_COUNT=3
PR_COMMIT_COUNT=3

# Rebase only your PR commits onto upstream/master
git rebase --onto upstream/master HEAD~${PR_COMMIT_COUNT}

git push --force-with-lease

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.

2 participants