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

Bug 138812

Summary: directory.list(filter) is spec'd to return null
Product: [Eclipse Project] Platform Reporter: David Williams <david_williams>
Component: Update (deprecated - use Eclipse>Equinox>p2)Assignee: Platform-Update-Inbox <platform-update-inbox>
Status: RESOLVED WONTFIX QA Contact:
Severity: normal    
Priority: P3    
Version: 3.2   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
patch illustrating NPE spots none

Description David Williams CLA 2006-04-26 22:24:29 EDT
Throughout update code, it often uses Java constructs like 

  File[] filearray = pluginDirectory.list();
or 
  File[] filearray = featureDirecotry.list(filenamefileter); 

these 'list' methods are actually spec'd to be be able to return null

"
     *...       The array will be empty if the directory is
     *          empty.  Returns <code>null</code> if this abstract pathname
     *          does not denote a directory, or if an I/O error occurs.
"

But in few places is null checked. 

All the existing code works fine, and I've never seen this in normal use, 
but in the course of experimenting with posible fixes for bug 137538 I did run into cases where a 'null' was returned. I'm not exactly sure what gave rise the 
the null cases, since in most places these sections of code are well checked (e.g. that its really a directory). 

It might be related to the rare ? case of eclipes.org clusters, where, sometimes, there is "access forbidden" on one file system while it replicates ... or something? 

I'm just documenting there, since I did encounter it, and in case anyone really wants to bullet proof that upate code.
Comment 1 Branko Tripkovic CLA 2006-04-27 12:20:10 EDT
Yes, the problem can arise because checking for null and list directory are not one atomic operation. How did the code behave in this case? Did you have problem continuing regular operations? I think that there is nothing we can do about this.
Comment 2 David Williams CLA 2006-04-27 12:32:31 EDT
I just got null pointer exceptions, intially. 

most code immediately after array=list()
did array.length 

hence NPE instead of the "do nothing" logic that was there for the zero size array. 

In my "whacked" together code, it easy to put in "if null do nothing" sorts of checks and everything continued as expected. Again, not exactly sure even why it occurred sometimes, but I actually saw no ill effects in end results evnen when null was returned. That is, I saw no change in behavior, once NPE was fixed. 


Comment 3 Branko Tripkovic CLA 2006-04-27 13:24:10 EDT
Sorry i misunderstood what you are saying. I thought you want it to be check beforehand. do you know where exactly in the code this happens?
Comment 4 David Williams CLA 2006-04-28 01:37:56 EDT
Created attachment 39746 [details]
patch illustrating NPE spots

This patch is a bit sloppy, so take head it's just based on my whacked code, to get be another problem. It does, however, illustrate the 4 spots I was seeing the NPE's. And, again, remember I was seeing these NPE's after modifying other code to return ignore missing plugins. 

Hope this patch helps illustrate what I meant. There are, also, other places where list-filter is used, but I never saw NPE's there. (But, in really bullet proof code, might want to be considered).
Comment 5 John Arthorne CLA 2009-06-18 17:17:44 EDT
This is a mass update of Platform Update bugs that have had no activity in three years. Platform Update was replaced in Eclipse 3.4 (2008) by a new provisioning system called Equinox p2. If this bug or enhancement is not already addressed in p2 please enter a new bug report against p2 (RT > Equinox > p2). If you still want to see this bug addressed in the deprecated Platform Update component, please reopen this bug. Patches welcome.