Bug 542960 - NPE in InitialSharedInstall's cleanupDotEclipseFolder() when '~/.eclipse/' doesn't exist

InitialSharedInstall's cleanupDotEclipseFolder() ensures that
'${user.home}/.eclipse/' doesn't have directories/files which names
start with 'p2.automated.test'. But it will throw NPE when the folder
doesn't exist in the first place:

    setupRun(org.eclipse.equinox.p2.tests.sharedinstall.InitialSharedInstall)  Time elapsed: 0.002 s  <<< ERROR!
    java.lang.NullPointerException
	    at org.eclipse.equinox.p2.tests.sharedinstall.InitialSharedInstall.cleanupDotEclipseFolder(InitialSharedInstall.java:72)
	    at org.eclipse.equinox.p2.tests.sharedinstall.InitialSharedInstall.setupRun(InitialSharedInstall.java:49)

In this case, make InitialSharedInstall's cleanupDotEclipseFolder() a
noop.

Change-Id: I4165609c644a6dde69c1d8ffe88138bf7ce16705
Signed-off-by: Mykola Nikishov <mn@mn.com.ua>
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/sharedinstall/InitialSharedInstall.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/sharedinstall/InitialSharedInstall.java
index d8b3be1..eb144c9 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/sharedinstall/InitialSharedInstall.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/sharedinstall/InitialSharedInstall.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2013, 2017 Ericsson AB and others.
+ * Copyright (c) 2013, 2018 Ericsson AB and others.
  *
  * This
  * program and the accompanying materials are made available under the terms of
@@ -64,13 +64,17 @@
 	private void cleanupDotEclipseFolder() {
 		File userHome = new File(System.getProperty("user.home"));
 		File dotEclipse = new File(userHome, ".eclipse");
+		if (!dotEclipse.exists())
+			// nothing to clean up
+			return;
+
 		File[] toDelete = dotEclipse.listFiles((FilenameFilter) (dir, name) -> {
 			if (name.startsWith("p2.automated.test"))
 				return true;
 			return false;
 		});
-		for (int i = 0; i < toDelete.length; i++) {
-			delete(toDelete[i]);
+		for (File file : toDelete) {
+			delete(file);
 		}
 	}
 }