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

Bug 314461

Summary: [local] NPE trying to delete a local folder that has no permissions at all
Product: [Tools] Target Management Reporter: Martin Oberhuber <mober.at+eclipse>
Component: RSEAssignee: Martin Oberhuber <mober.at+eclipse>
Status: RESOLVED FIXED QA Contact: Martin Oberhuber <mober.at+eclipse>
Severity: normal    
Priority: P3 CC: dmcknigh
Version: 3.2Flags: dmcknigh: review+
Target Milestone: 3.2 RC3   
Hardware: PC   
OS: Linux   
Whiteboard:
Bug Depends on:    
Bug Blocks: 314439    
Attachments:
Description Flags
trivial patch none

Description Martin Oberhuber CLA 2010-05-26 09:46:03 EDT
+++ This bug was initially created as a clone of Bug #314439 +++

Build ID: TM 3.2rc2 on Linux-GTK-RHEL-4

Found when debugging RSEFileStoreTest#testDeleteSpecialCases() : Using the RSE "local" file system to try and delete an existing folder that has no permissions at all throws a NullPointerException. Example:

  mkdir nonAccessible
  chmod 0 nonAccessible
  LocalFileService.delete(nonAccessible);

because java.io.File#listFiles() returns null in this case, this results in an NPE:

Exception in tearDown.deleteTestStore:
java.lang.NullPointerException
	at org.eclipse.rse.internal.services.local.files.LocalFileService.deleteContents(LocalFileService.java:1104)
	at org.eclipse.rse.internal.services.local.files.LocalFileService.delete(LocalFileService.java:1068)
	at org.eclipse.rse.subsystems.files.core.servicesubsystem.FileServiceSubSystem.delete(FileServiceSubSystem.java:975)
	at org.eclipse.rse.internal.efs.RSEFileStoreImpl.delete(RSEFileStoreImpl.java:797)
	at org.eclipse.rse.internal.efs.RSEFileStore.delete(RSEFileStore.java:362)
	at org.eclipse.rse.tests.subsystems.files.RSEFileStoreTest.tearDown(RSEFileStoreTest.java:174)
Comment 1 Martin Oberhuber CLA 2010-05-26 09:55:20 EDT
Created attachment 169990 [details]
trivial patch

Attached trivial patch fixes the issue. With the fix, an exception is now reported as expected instead of the NPE:

Exception in tearDown.deleteTestStore:
org.eclipse.core.runtime.CoreException: Failed to delete: /folk/mober/rseTest1274877741316: rse://LOCALHOST/folk/mober/rseTest1274877741316
	at org.eclipse.rse.internal.efs.RSEFileStoreImpl.rethrowCoreException(RSEFileStoreImpl.java:629)
	at org.eclipse.rse.internal.efs.RSEFileStoreImpl.delete(RSEFileStoreImpl.java:803)
	at org.eclipse.rse.internal.efs.RSEFileStore.delete(RSEFileStore.java:362)
	at org.eclipse.rse.tests.subsystems.files.RSEFileStoreTest.tearDown(RSEFileStoreTest.java:174)


Caused by: org.eclipse.rse.services.clientserver.messages.SystemOperationFailedException: Failed to delete: /folk/mober/rseTest1274877741316
	at org.eclipse.rse.internal.services.local.files.LocalFileService.delete(LocalFileService.java:1081)
	at org.eclipse.rse.subsystems.files.core.servicesubsystem.FileServiceSubSystem.delete(FileServiceSubSystem.java:975)
Comment 2 Martin Oberhuber CLA 2010-05-26 09:55:45 EDT
Dave can you review this trivial fix please?
Comment 3 Martin Oberhuber CLA 2010-05-26 13:02:21 EDT
Released > I20100526.