Bug 301688 - [breakpoints] NPE while toggling breakpoint & 'Skip All
Breakpoints' action & 'Save' action
Change-Id: Ie83b058a92430d765bad48bbdedb627fcf4a9224
diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/BreakpointLocationVerifierJob.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/BreakpointLocationVerifierJob.java
index 4c469f7..81f4904 100644
--- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/BreakpointLocationVerifierJob.java
+++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/BreakpointLocationVerifierJob.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2003, 2015 IBM Corporation and others.
+ * Copyright (c) 2003, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -120,6 +120,9 @@
fCunit.accept(locator);
int lineNumber = locator.getLineLocation();
String typeName = locator.getFullyQualifiedTypeName();
+ if (typeName == null) {
+ return new Status(IStatus.ERROR, JDIDebugUIPlugin.getUniqueIdentifier(), IStatus.ERROR, ActionMessages.BreakpointLocationVerifierJob_not_valid_location, null);
+ }
try {
switch (locator.getLocationType()) {
case ValidBreakpointLocationLocator.LOCATION_LINE:
diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/RunToLineAdapter.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/RunToLineAdapter.java
index 97ce8b3..2042e28 100644
--- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/RunToLineAdapter.java
+++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/RunToLineAdapter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -78,12 +78,15 @@
CompilationUnit compilationUnit= (CompilationUnit)parser.createAST(null);
ValidBreakpointLocationLocator locator= new ValidBreakpointLocationLocator(compilationUnit, lineNumber[0], false, false);
compilationUnit.accept(locator);
- validLine[0]= locator.getLineLocation();
+ validLine[0] = locator.getLineLocation();
typeName[0]= locator.getFullyQualifiedTypeName();
}
};
BusyIndicator.showWhile(JDIDebugUIPlugin.getStandardDisplay(), r);
if (validLine[0] == lineNumber[0]) {
+ if (typeName[0] == null) {
+ throw new CoreException(new Status(IStatus.ERROR, JDIDebugUIPlugin.getUniqueIdentifier(), IJavaDebugUIConstants.INTERNAL_ERROR, "Invalid Type Name", null)); //$NON-NLS-1$
+ }
IBreakpoint breakpoint= null;
Map<String, Object> attributes = new HashMap<String, Object>(4);
BreakpointUtils.addRunToLineAttributes(attributes);
diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/ToggleBreakpointAdapter.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/ToggleBreakpointAdapter.java
index 572c616..003ac07 100644
--- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/ToggleBreakpointAdapter.java
+++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/ToggleBreakpointAdapter.java
@@ -354,6 +354,9 @@
} else {
tname = locator.getFullyQualifiedTypeName();
}
+ if (tname == null) {
+ return Status.CANCEL_STATUS;
+ }
IResource resource = BreakpointUtils.getBreakpointResource(type);
int lnumber = locator == null ? tsel.getStartLine() + 1 : locator.getLineLocation();
IJavaLineBreakpoint existingBreakpoint = JDIDebugModel.lineBreakpointExists(resource, tname, lnumber);
diff --git a/org.eclipse.jdt.debug/model/org/eclipse/jdt/internal/debug/core/breakpoints/JavaBreakpointImportParticipant.java b/org.eclipse.jdt.debug/model/org/eclipse/jdt/internal/debug/core/breakpoints/JavaBreakpointImportParticipant.java
index 881b4cf..f8f0064 100644
--- a/org.eclipse.jdt.debug/model/org/eclipse/jdt/internal/debug/core/breakpoints/JavaBreakpointImportParticipant.java
+++ b/org.eclipse.jdt.debug/model/org/eclipse/jdt/internal/debug/core/breakpoints/JavaBreakpointImportParticipant.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2013 IBM Corporation and others.
+ * Copyright (c) 2008, 2016 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -561,6 +561,8 @@
int newline = locator.getLineLocation();
if (locator.getLocationType() == ValidBreakpointLocationLocator.LOCATION_LINE) {
if (currentline != newline) {
+ if (locator.getFullyQualifiedTypeName() == null)
+ throw new CoreException(Status.CANCEL_STATUS);
bp.getMarker().setAttribute(JavaBreakpoint.TYPE_NAME,
locator.getFullyQualifiedTypeName());
bp.getMarker().setAttribute(IMarker.LINE_NUMBER,
@@ -594,6 +596,9 @@
if (attr1 == null) {
return attr2 == null;
}
+ if (attr2 == null) {
+ return false;
+ }
return attr1.equals(attr2);
}