Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 352196 - ExternalModelManager#extractJar - prove for NPE
Summary: ExternalModelManager#extractJar - prove for NPE
Status: VERIFIED FIXED
Alias: None
Product: PDE
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.7   Edit
Hardware: PC Linux
: P3 trivial (vote)
Target Milestone: 3.8 M1   Edit
Assignee: Curtis Windatt CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 353814
  Show dependency tree
 
Reported: 2011-07-15 06:45 EDT by Karsten Thoms CLA
Modified: 2011-08-03 17:14 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 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