Bug 221152 - [quick fix] Add null check if potential null dereference
Summary: [quick fix] Add null check if potential null dereference
Status: RESOLVED DUPLICATE of bug 178254
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows XP
: P3 enhancement (vote)
Target Milestone: 3.5   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-03-03 10:12 EST by Benno Baumgartner CLA
Modified: 2008-08-07 09:54 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Benno Baumgartner CLA 2008-03-03 10:12:36 EST
 
Comment 1 Benno Baumgartner CLA 2008-03-03 10:19:56 EST
Sorry, that was too quick

I20080226-1155

Given:
public class Foo {
	public void foo() {
		StringBuffer b1 = null;
		if (bar()) {
			b1= new StringBuffer();
		}
		b1.append(true);
	}

	private boolean bar() {
		return false;
	}
}

1. Quick fix at b1: Potential null pointer access: The variable b1 may be null at this location
Is:
 Add suppress warning is the only available quick fix (pretty useless)
Should:
 'Add null check' with result:

StringBuffer b1 = null;
if (b1 != null) {
   b1.append(true);
}
Comment 2 Markus Keller CLA 2008-08-07 09:54:57 EDT

*** This bug has been marked as a duplicate of bug 178254 ***