Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAxel Richard2016-09-30 05:53:58 -0400
committerLaurent Delaigue2016-10-13 09:10:04 -0400
commitd2efef258ad29921c5619008d1fa1c5575d140c6 (patch)
tree532c98fd5cec22caf33cf230d3a37f2fb6ce24b3
parent3c7d3d74422aa061acf2db09586db94088136e61 (diff)
downloadorg.eclipse.emf.compare-d2efef258ad29921c5619008d1fa1c5575d140c6.tar.gz
org.eclipse.emf.compare-d2efef258ad29921c5619008d1fa1c5575d140c6.tar.xz
org.eclipse.emf.compare-d2efef258ad29921c5619008d1fa1c5575d140c6.zip
Miscellaneous Findbugs fixes
Remove unnecessary static access to AdapterFactory Fix potential NPE in AbstractGitMergeTestCase Fix potential NPE in InternalGitTestSupport Change-Id: I1184d851c9b8c21d6fc5b0cd38b668acdfb3ecff Signed-off-by: Axel Richard <axel.richard@obeo.fr> Signed-off-by: Laurent Delaigue <laurent.delaigue@obeo.fr>
-rw-r--r--plugins/org.eclipse.emf.compare.diagram.papyrus.tests.git/src/org/eclipse/emf/compare/diagram/papyrus/tests/egit/AbstractGitMergeTestCase.java31
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui.tests.git.framework/src/org/eclipse/emf/compare/ide/ui/tests/git/framework/internal/statements/InternalGitTestSupport.java50
-rw-r--r--plugins/org.eclipse.emf.compare.rcp.ui.tests/src/org/eclipse/emf/compare/rcp/ui/tests/structuremergeviewer/groups/provider/AbstractTestTreeNodeItemProviderAdapter.java6
3 files changed, 54 insertions, 33 deletions
diff --git a/plugins/org.eclipse.emf.compare.diagram.papyrus.tests.git/src/org/eclipse/emf/compare/diagram/papyrus/tests/egit/AbstractGitMergeTestCase.java b/plugins/org.eclipse.emf.compare.diagram.papyrus.tests.git/src/org/eclipse/emf/compare/diagram/papyrus/tests/egit/AbstractGitMergeTestCase.java
index 676b61114..ba9e7e26a 100644
--- a/plugins/org.eclipse.emf.compare.diagram.papyrus.tests.git/src/org/eclipse/emf/compare/diagram/papyrus/tests/egit/AbstractGitMergeTestCase.java
+++ b/plugins/org.eclipse.emf.compare.diagram.papyrus.tests.git/src/org/eclipse/emf/compare/diagram/papyrus/tests/egit/AbstractGitMergeTestCase.java
@@ -201,18 +201,24 @@ public abstract class AbstractGitMergeTestCase {
private static void copyDirectoryContents(File rootDirectory, final File workingDirectory)
throws IOException {
- for (String child : rootDirectory.list()) {
- copyDirectory(new File(rootDirectory, child), new File(workingDirectory, child));
+ String[] list = rootDirectory.list();
+ if (list != null) {
+ for (String child : list) {
+ copyDirectory(new File(rootDirectory, child), new File(workingDirectory, child));
+ }
}
}
private static void copyDirectory(File source, File destination) throws IOException {
- if (source.isDirectory()) {
- if (!destination.exists()) {
+ if (source != null && source.isDirectory()) {
+ if (destination != null && !destination.exists()) {
destination.mkdir();
}
- for (String child : source.list()) {
- copyDirectory(new File(source, child), new File(destination, child));
+ String[] list = source.list();
+ if (list != null) {
+ for (String child : list) {
+ copyDirectory(new File(source, child), new File(destination, child));
+ }
}
} else {
copyFile(source, destination);
@@ -235,11 +241,14 @@ public abstract class AbstractGitMergeTestCase {
private Iterable<File> getAllContainedFiles(File workingDirectory) {
final Builder<File> builder = ImmutableList.builder();
- for (File containedFile : workingDirectory.listFiles()) {
- if (containedFile.isFile()) {
- builder.add(containedFile);
- } else if (containedFile.isDirectory()) {
- builder.addAll(getAllContainedFiles(containedFile));
+ File[] listFiles = workingDirectory.listFiles();
+ if (listFiles != null) {
+ for (File containedFile : listFiles) {
+ if (containedFile.isFile()) {
+ builder.add(containedFile);
+ } else if (containedFile.isDirectory()) {
+ builder.addAll(getAllContainedFiles(containedFile));
+ }
}
}
return builder.build();
diff --git a/plugins/org.eclipse.emf.compare.ide.ui.tests.git.framework/src/org/eclipse/emf/compare/ide/ui/tests/git/framework/internal/statements/InternalGitTestSupport.java b/plugins/org.eclipse.emf.compare.ide.ui.tests.git.framework/src/org/eclipse/emf/compare/ide/ui/tests/git/framework/internal/statements/InternalGitTestSupport.java
index 6488d8908..6a383c4fa 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui.tests.git.framework/src/org/eclipse/emf/compare/ide/ui/tests/git/framework/internal/statements/InternalGitTestSupport.java
+++ b/plugins/org.eclipse.emf.compare.ide.ui.tests.git.framework/src/org/eclipse/emf/compare/ide/ui/tests/git/framework/internal/statements/InternalGitTestSupport.java
@@ -151,13 +151,16 @@ public class InternalGitTestSupport {
* @return The path to the .git folder
*/
private File findGitDir(File file) {
- for (File child : file.listFiles()) {
- if (child.isDirectory() && child.getName().equals(".git")) { //$NON-NLS-1$
- return child;
- } else if (child.isDirectory()) {
- File findGitDir = findGitDir(child);
- if (findGitDir != null) {
- return findGitDir;
+ File[] listFiles = file.listFiles();
+ if (listFiles != null) {
+ for (File child : listFiles) {
+ if (child.isDirectory() && child.getName().equals(".git")) { //$NON-NLS-1$
+ return child;
+ } else if (child.isDirectory()) {
+ File findGitDir = findGitDir(child);
+ if (findGitDir != null) {
+ return findGitDir;
+ }
}
}
}
@@ -178,12 +181,15 @@ public class InternalGitTestSupport {
*/
private void importProjects(File file)
throws InvocationTargetException, InterruptedException, CoreException {
- for (File child : file.listFiles()) {
- if (child.isDirectory() && !child.getName().equals(METADATA_FOLDER)
- && !child.getName().equals(".git")) { //$NON-NLS-1$
- importProjects(child);
- } else if (child.getName().equals(".project")) { //$NON-NLS-1$
- importProject(child);
+ File[] listFiles = file.listFiles();
+ if (listFiles != null) {
+ for (File child : listFiles) {
+ if (child.isDirectory() && !child.getName().equals(METADATA_FOLDER)
+ && !child.getName().equals(".git")) { //$NON-NLS-1$
+ importProjects(child);
+ } else if (child.getName().equals(".project")) { //$NON-NLS-1$
+ importProject(child);
+ }
}
}
}
@@ -282,9 +288,12 @@ public class InternalGitTestSupport {
Activator.getDefault().getRepositoryCache().clear();
File file = new File(workspaceRoot.getLocation().toOSString());
- for (File child : file.listFiles()) {
- if (!child.getName().equals(METADATA_FOLDER)) {
- FileUtils.delete(child, FileUtils.RECURSIVE | FileUtils.RETRY);
+ File[] listFiles = file.listFiles();
+ if (listFiles != null) {
+ for (File child : listFiles) {
+ if (!child.getName().equals(METADATA_FOLDER)) {
+ FileUtils.delete(child, FileUtils.RECURSIVE | FileUtils.RETRY);
+ }
}
}
}
@@ -319,9 +328,12 @@ public class InternalGitTestSupport {
}
File file = new File(ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString());
- for (File child : file.listFiles()) {
- if (!child.getName().equals(METADATA_FOLDER)) {
- FileUtils.delete(child, FileUtils.RECURSIVE | FileUtils.RETRY);
+ File[] listFiles = file.listFiles();
+ if (listFiles != null) {
+ for (File child : listFiles) {
+ if (!child.getName().equals(METADATA_FOLDER)) {
+ FileUtils.delete(child, FileUtils.RECURSIVE | FileUtils.RETRY);
+ }
}
}
}
diff --git a/plugins/org.eclipse.emf.compare.rcp.ui.tests/src/org/eclipse/emf/compare/rcp/ui/tests/structuremergeviewer/groups/provider/AbstractTestTreeNodeItemProviderAdapter.java b/plugins/org.eclipse.emf.compare.rcp.ui.tests/src/org/eclipse/emf/compare/rcp/ui/tests/structuremergeviewer/groups/provider/AbstractTestTreeNodeItemProviderAdapter.java
index 42fcbe9a4..4db1cb666 100644
--- a/plugins/org.eclipse.emf.compare.rcp.ui.tests/src/org/eclipse/emf/compare/rcp/ui/tests/structuremergeviewer/groups/provider/AbstractTestTreeNodeItemProviderAdapter.java
+++ b/plugins/org.eclipse.emf.compare.rcp.ui.tests/src/org/eclipse/emf/compare/rcp/ui/tests/structuremergeviewer/groups/provider/AbstractTestTreeNodeItemProviderAdapter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2013, 2015 Obeo.
+ * Copyright (c) 2013, 2016 Obeo.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -20,9 +20,9 @@ import org.eclipse.emf.common.notify.Notifier;
import org.eclipse.emf.compare.AttributeChange;
import org.eclipse.emf.compare.Comparison;
import org.eclipse.emf.compare.EMFCompare;
+import org.eclipse.emf.compare.EMFCompare.Builder;
import org.eclipse.emf.compare.Match;
import org.eclipse.emf.compare.ReferenceChange;
-import org.eclipse.emf.compare.EMFCompare.Builder;
import org.eclipse.emf.compare.rcp.internal.extension.impl.EMFCompareBuilderConfigurator;
import org.eclipse.emf.compare.rcp.ui.internal.structuremergeviewer.filters.StructureMergeViewerFilter;
import org.eclipse.emf.compare.rcp.ui.internal.structuremergeviewer.groups.provider.TreeItemProviderAdapterFactorySpec;
@@ -46,7 +46,7 @@ import com.google.common.eventbus.EventBus;
@SuppressWarnings("restriction")
public class AbstractTestTreeNodeItemProviderAdapter {
- protected static TreeItemProviderAdapterFactorySpec treeItemProviderAdapterFactory;
+ protected TreeItemProviderAdapterFactorySpec treeItemProviderAdapterFactory;
protected EventBus eventBus;

Back to the top