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

Bug 352196

Summary: ExternalModelManager#extractJar - prove for NPE
Product: [Eclipse Project] PDE Reporter: Karsten Thoms <karsten.thoms>
Component: UIAssignee: Curtis Windatt <curtis.windatt.public>
Status: VERIFIED FIXED QA Contact:
Severity: trivial    
Priority: P3 CC: curtis.windatt.public, ed
Version: 3.7   
Target Milestone: 3.8 M1   
Hardware: PC   
OS: Linux   
Whiteboard:
Bug Depends on:    
Bug Blocks: 353814    

Description Karsten Thoms CLA 2011-07-15 06:45:16 EDT
In the mentioned method the input stream 'in' is closed in the finally block, and any exceptions catched. It can be that 'in' is null, which raises a NullPointerException. Of course this one is catched by the empty catch block, but I think this situation should be proven explicitly.

I have usually an exception breakpoint on NullPointerException on when debugging code, and I usually expect NPEs only in the code that I want to debug.

So please make this a bit more safer:

===============================
			try {
				f.close();
			} catch (Exception e) {
			}
			try {
				in.close();
			} catch (Exception e) {
===============================
Replace by:
			try {
				if (f!=null) f.close();
			} catch (Exception e) {
			}
			try {
				if (in!=null) in.close();
			} catch (Exception e) {
Comment 1 Curtis Windatt CLA 2011-07-18 15:47:42 EDT
In this case, 'f' will never be null.  However, 'in' could end up being null, so I have added the null check.  Thanks for reporting this.

Fixed in HEAD.  See ExternalModelManager.java
Comment 2 Ed Willink CLA 2011-08-03 15:03:00 EDT
Surely this should be in SR1?
Comment 3 Curtis Windatt CLA 2011-08-03 17:14:17 EDT
See bug 353814 for 3.7.1 inclusion
Comment 4 Curtis Windatt CLA 2011-08-03 17:14:46 EDT
Verified code is in I20110802-2000