Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRené Purrio2018-01-17 02:26:14 -0500
committerRené Purrio2018-01-17 06:56:21 -0500
commit3dc65fbd62daa08bb5700a0dd70c5950caab423d (patch)
tree3b9e6a2764215b2bc08418e466fc1ad380deffbc /bundles
parent65668f82b11c9c33730e82474f01eeeb0fcd491e (diff)
downloadeclipse.platform.team-3dc65fbd62daa08bb5700a0dd70c5950caab423d.tar.gz
eclipse.platform.team-3dc65fbd62daa08bb5700a0dd70c5950caab423d.tar.xz
eclipse.platform.team-3dc65fbd62daa08bb5700a0dd70c5950caab423d.zip
Bug 529824 - [sonar] Resolve "Possible null pointer dereference"I20180119-0110I20180118-2000
Change-Id: I1a4ce29ea6ee3c49b6d218b0c1063415f72466c5 Signed-off-by: René Purrio <rpurrio@itemis.de>
Diffstat (limited to 'bundles')
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/ResourceVariantCache.java13
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSProjectSetCapability.java42
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/WorkspaceFileDiffOperation.java22
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/TeamUI.java23
4 files changed, 78 insertions, 22 deletions
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/ResourceVariantCache.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/ResourceVariantCache.java
index ea6b7bda6..0f3316108 100644
--- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/ResourceVariantCache.java
+++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/ResourceVariantCache.java
@@ -11,7 +11,12 @@
package org.eclipse.team.internal.core;
import java.io.File;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.jobs.ILock;
@@ -155,7 +160,8 @@ public class ResourceVariantCache {
deleteFile(file);
} catch (TeamException e) {
// Check to see if were in an acceptable state
- if (file.exists() && (!file.isDirectory() || file.listFiles().length != 0)) {
+ File[] fileList = file.listFiles();
+ if (file.exists() && (!file.isDirectory() || (fileList != null && fileList.length != 0))) {
TeamPlugin.log(e);
}
}
@@ -187,6 +193,9 @@ public class ResourceVariantCache {
private void deleteFile(File file) throws TeamException {
if (file.isDirectory()) {
File[] children = file.listFiles();
+ if(children == null) {
+ throw new TeamException(NLS.bind(Messages.RemoteContentsCache_fileError, new String[] { file.getAbsolutePath() }));
+ }
for (int i = 0; i < children.length; i++) {
deleteFile(children[i]);
}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSProjectSetCapability.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSProjectSetCapability.java
index c5e3d53d0..9f035306c 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSProjectSetCapability.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSProjectSetCapability.java
@@ -14,19 +14,44 @@ package org.eclipse.team.internal.ccvs.core;
import java.io.File;
import java.net.URI;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.StringTokenizer;
-import org.eclipse.core.resources.*;
-import org.eclipse.core.runtime.*;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRunnable;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.core.runtime.jobs.ISchedulingRule;
import org.eclipse.core.runtime.jobs.MultiRule;
-import org.eclipse.team.core.*;
-import org.eclipse.team.internal.ccvs.core.client.*;
+import org.eclipse.team.core.ProjectSetCapability;
+import org.eclipse.team.core.ProjectSetSerializationContext;
+import org.eclipse.team.core.RepositoryProvider;
+import org.eclipse.team.core.TeamException;
+import org.eclipse.team.internal.ccvs.core.client.Checkout;
+import org.eclipse.team.internal.ccvs.core.client.Command;
import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption;
+import org.eclipse.team.internal.ccvs.core.client.Request;
+import org.eclipse.team.internal.ccvs.core.client.Session;
+import org.eclipse.team.internal.ccvs.core.client.Update;
import org.eclipse.team.internal.ccvs.core.connection.CVSRepositoryLocation;
import org.eclipse.team.internal.ccvs.core.connection.CVSServerException;
import org.eclipse.team.internal.ccvs.core.filesystem.CVSURI;
-import org.eclipse.team.internal.ccvs.core.resources.*;
+import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
+import org.eclipse.team.internal.ccvs.core.resources.RemoteFolder;
+import org.eclipse.team.internal.ccvs.core.resources.RemoteModule;
import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
import org.eclipse.team.internal.ccvs.core.util.KnownRepositories;
@@ -578,9 +603,12 @@ public class CVSProjectSetCapability extends ProjectSetCapability {
}
}
- private static void deepDelete(File resource) {
+ private static void deepDelete(File resource) throws CVSException {
if (resource.isDirectory()) {
File[] fileList = resource.listFiles();
+ if(fileList == null) {
+ throw new CVSException("Content from directory '" + resource.getAbsolutePath() + "' can not be listed."); //$NON-NLS-1$ //$NON-NLS-2$
+ }
for (int i = 0; i < fileList.length; i++) {
deepDelete(fileList[i]);
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/WorkspaceFileDiffOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/WorkspaceFileDiffOperation.java
index 39531c8ea..e6c148d5d 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/WorkspaceFileDiffOperation.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/WorkspaceFileDiffOperation.java
@@ -10,11 +10,21 @@
*******************************************************************************/
package org.eclipse.team.internal.ccvs.ui.operations;
-import java.io.*;
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
-import org.eclipse.core.resources.*;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.resources.mapping.ResourceMapping;
-import org.eclipse.core.runtime.*;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
import org.eclipse.team.internal.ccvs.core.CVSException;
import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption;
import org.eclipse.ui.IWorkbenchPart;
@@ -28,7 +38,11 @@ public class WorkspaceFileDiffOperation extends FileDiffOperation {
protected void copyFile() throws CVSException {
IWorkspaceRoot root =ResourcesPlugin.getWorkspace().getRoot();
- IFile finalFile = root.getFileForLocation(new Path(this.file.getPath()));
+ String filePath = this.file.getPath();
+ IFile finalFile = root.getFileForLocation(new Path(filePath));
+ if(finalFile == null) {
+ throw new CVSException("File '" + filePath + "' can not be found in workspace."); //$NON-NLS-1$ //$NON-NLS-2$
+ }
InputStream fileInputStream = null;
try {
fileInputStream = new BufferedInputStream(new FileInputStream(tempFile));
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/TeamUI.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/TeamUI.java
index c4a6ad0a4..56ca040a8 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/TeamUI.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/TeamUI.java
@@ -13,7 +13,9 @@ package org.eclipse.team.ui;
import java.util.HashSet;
import java.util.Set;
-import org.eclipse.core.runtime.*;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.team.internal.ui.TeamUIPlugin;
import org.eclipse.team.internal.ui.history.GenericHistoryView;
@@ -22,7 +24,9 @@ import org.eclipse.team.ui.history.IHistoryPageSource;
import org.eclipse.team.ui.history.IHistoryView;
import org.eclipse.team.ui.mapping.ITeamContentProviderManager;
import org.eclipse.team.ui.synchronize.ISynchronizeManager;
-import org.eclipse.ui.*;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.PartInitException;
/**
* TeamUI contains public API for generic UI-based Team functionality.
@@ -106,16 +110,17 @@ public class TeamUI {
if (view == null) {
page.showView(IHistoryView.VIEW_ID);
view = (IHistoryView) TeamUIPlugin.getActivePage().findView(IHistoryView.VIEW_ID);
- return showInputInView(page, input, view, pageSource);
- } else {
- view = ((GenericHistoryView)view).findAppropriateHistoryViewFor(input, pageSource);
- if (view == null) {
- view = (IHistoryView) page.showView(IHistoryView.VIEW_ID, IHistoryView.VIEW_ID + System.currentTimeMillis(), IWorkbenchPage.VIEW_CREATE);
- return showInputInView(page, input, view, pageSource);
- } else {
+ if(view != null) {
return showInputInView(page, input, view, pageSource);
}
}
+ view = ((GenericHistoryView)view).findAppropriateHistoryViewFor(input, pageSource);
+ if (view == null) {
+ view = (IHistoryView) page.showView(IHistoryView.VIEW_ID, IHistoryView.VIEW_ID + System.currentTimeMillis(), IWorkbenchPage.VIEW_CREATE);
+ return showInputInView(page, input, view, pageSource);
+ } else {
+ return showInputInView(page, input, view, pageSource);
+ }
} catch (PartInitException e) {
}

Back to the top