Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 357367

Summary: NPE when ScriptSource#clearBreakpoints is called.
Product: [WebTools] JSDT Reporter: lex78
Component: DebugAssignee: Project Inbox <jsdt.debug-inbox>
Status: RESOLVED FIXED QA Contact: Michael Rennie <Michael_Rennie>
Severity: normal    
Priority: P3 CC: thatnitind
Version: unspecified   
Target Milestone: 3.4 M2   
Hardware: All   
OS: All   
Whiteboard:

Description lex78 CLA 2011-09-12 08:16:23 EDT
Build Identifier: 20110615-0604

org.eclipse.wst.jsdt.debug.internal.rhino.debugger.ScriptSource#clearBreakpoints throws and NPE exception when it gets the breakpoint from the lines[0].breakpoint 

for (int i = 0; i < this.lines.length; i++) {
Breakpoint bp = lines[i].breakpoint;  => NPE Exception!!!

The constructor fill the array from lines[1] to lines[lineNumbers+1].
				

Reproducible: Always

Steps to Reproduce:
1.Start debugging a JS Script. It  triggers the RhinoDebuggerImpl.handleCompilationDone() and it puts the script into the "uriToScript"
2.Update the script so it triggers again the call of RhinoDebuggerImpl.handleCompilationDone() and it finds the "ScriptSource old = (ScriptSource) uriToScript.remove(uri);" old script. 
3.The old.clearBreakpoints(this); in line 156 throws NPE
Comment 1 Michael Rennie CLA 2011-09-12 10:25:31 EDT
Thanks for the bug and the assessment of the problem!

We should be checking the line data for existence like we do pretty much everywhere else in ScriptSource.

Applied check to HEAD.