Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Stieber2012-05-31 17:50:37 +0000
committerUwe Stieber2012-05-31 17:50:37 +0000
commit9a57024bf6b43d08285a09ba3316e0c5272ffa03 (patch)
treef365fb488a492d63476176bfb6259b119e87fb70 /target_explorer/plugins/org.eclipse.tcf.te.launch.core
parent75851083999fcbe274b9fc81887ed58985860ab8 (diff)
downloadorg.eclipse.tcf-9a57024bf6b43d08285a09ba3316e0c5272ffa03.tar.gz
org.eclipse.tcf-9a57024bf6b43d08285a09ba3316e0c5272ffa03.tar.xz
org.eclipse.tcf-9a57024bf6b43d08285a09ba3316e0c5272ffa03.zip
Target Explorer: Fix FindBugs warnings
Diffstat (limited to 'target_explorer/plugins/org.eclipse.tcf.te.launch.core')
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/internal/LaunchBinding.java4
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/lm/LaunchConfigSorter.java11
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/lm/delegates/DefaultLaunchManagerDelegate.java26
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/persistence/AbstractItemListXMLParser.java2
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/persistence/DefaultPersistenceDelegate.java2
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/persistence/projects/ReferencedProjectItem.java15
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/selection/AbstractSelectionContext.java4
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/selection/LaunchSelection.java5
8 files changed, 54 insertions, 15 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/internal/LaunchBinding.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/internal/LaunchBinding.java
index da18a3d0c..737d67dae 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/internal/LaunchBinding.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/bindings/internal/LaunchBinding.java
@@ -9,6 +9,8 @@
*******************************************************************************/
package org.eclipse.tcf.te.launch.core.bindings.internal;
+import java.util.Arrays;
+
import org.eclipse.core.runtime.Assert;
import org.eclipse.tcf.te.launch.core.bindings.interfaces.ILaunchBinding;
@@ -50,7 +52,7 @@ public class LaunchBinding implements ILaunchBinding {
* @return The list of launch modes or an empty list.
*/
public final String[] getModes() {
- return modes;
+ return Arrays.copyOf(modes, modes.length);
}
/* (non-Javadoc)
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/lm/LaunchConfigSorter.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/lm/LaunchConfigSorter.java
index d4ba9c6b7..9143b2be7 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/lm/LaunchConfigSorter.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/lm/LaunchConfigSorter.java
@@ -51,6 +51,17 @@ public class LaunchConfigSorter implements Comparable<LaunchConfigSorter> {
}
/* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof LaunchConfigSorter) {
+ return ranking == ((LaunchConfigSorter)obj).ranking;
+ }
+ return super.equals(obj);
+ }
+
+ /* (non-Javadoc)
* @see java.lang.Comparable#compareTo(java.lang.Object)
*/
@Override
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/lm/delegates/DefaultLaunchManagerDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/lm/delegates/DefaultLaunchManagerDelegate.java
index 9c482faf5..885a96fb7 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/lm/delegates/DefaultLaunchManagerDelegate.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/lm/delegates/DefaultLaunchManagerDelegate.java
@@ -462,14 +462,19 @@ public class DefaultLaunchManagerDelegate extends ExecutableExtension implements
*/
@Override
public void validate(String launchMode, ILaunchConfiguration launchConfig) throws LaunchServiceException {
- String missingAttributes = null;
+ StringBuilder missingAttributes = new StringBuilder();
for (String attribute : getMandatoryAttributes()) {
if (!isValidAttribute(attribute, launchConfig, launchMode)) {
- missingAttributes = (missingAttributes == null) ? attribute : missingAttributes + ", " + attribute; //$NON-NLS-1$
+ if (missingAttributes.length() == 0) {
+ missingAttributes.append(attribute);
+ } else {
+ missingAttributes.append(", "); //$NON-NLS-1$
+ missingAttributes.append(attribute);
+ }
}
}
- if (missingAttributes != null) {
- throw new LaunchServiceException("Missing launch configuration attributes: " + '\n' + missingAttributes, LaunchServiceException.TYPE_MISSING_LAUNCH_CONFIG_ATTR); //$NON-NLS-1$
+ if (missingAttributes.length() > 0) {
+ throw new LaunchServiceException("Missing launch configuration attributes: " + '\n' + missingAttributes.toString(), LaunchServiceException.TYPE_MISSING_LAUNCH_CONFIG_ATTR); //$NON-NLS-1$
}
}
@@ -500,15 +505,20 @@ public class DefaultLaunchManagerDelegate extends ExecutableExtension implements
*/
@Override
public void validate(ILaunchSpecification launchSpec) throws LaunchServiceException {
- String missingAttributes = null;
+ StringBuilder missingAttributes = new StringBuilder();
for (String attribute : getMandatoryAttributes()) {
if (launchSpec == null || !launchSpec.hasAttribute(attribute)) {
// Remember the missing attribute for adding the list to the exception.
- missingAttributes = (missingAttributes == null) ? attribute : missingAttributes + ", " + attribute; //$NON-NLS-1$
+ if (missingAttributes.length() == 0) {
+ missingAttributes.append(attribute);
+ } else {
+ missingAttributes.append(", "); //$NON-NLS-1$
+ missingAttributes.append(attribute);
+ }
}
}
- if (missingAttributes != null) {
- throw new LaunchServiceException("Missing launch specification attributes: " + '\n' + missingAttributes, LaunchServiceException.TYPE_MISSING_LAUNCH_SPEC_ATTR); //$NON-NLS-1$
+ if (missingAttributes.length() > 0) {
+ throw new LaunchServiceException("Missing launch specification attributes: " + '\n' + missingAttributes.toString(), LaunchServiceException.TYPE_MISSING_LAUNCH_SPEC_ATTR); //$NON-NLS-1$
}
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/persistence/AbstractItemListXMLParser.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/persistence/AbstractItemListXMLParser.java
index e56ab4d5c..9cd03696d 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/persistence/AbstractItemListXMLParser.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/persistence/AbstractItemListXMLParser.java
@@ -160,7 +160,7 @@ public abstract class AbstractItemListXMLParser<ItemType> extends DefaultHandler
if (delegate != null) {
try {
ItemType item = (ItemType)delegate.read(getReadClass(), lastData, null);
- if (!items.contains(item)) {
+ if (items != null && !items.contains(item)) {
items.add(item);
}
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/persistence/DefaultPersistenceDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/persistence/DefaultPersistenceDelegate.java
index f858bb0c3..557920def 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/persistence/DefaultPersistenceDelegate.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/persistence/DefaultPersistenceDelegate.java
@@ -120,7 +120,7 @@ public class DefaultPersistenceDelegate {
*/
public final static void setAttribute(ILaunchConfigurationWorkingCopy wc, String attributeId, int attributeValue) {
if (wc == null || attributeId == null) return;
- if (isAttributeChanged(wc, attributeId, new Integer(attributeValue))) {
+ if (isAttributeChanged(wc, attributeId, Integer.valueOf(attributeValue))) {
// Determine the old attribute value
Object oldValue = null;
if (hasAttribute(wc, attributeId)) try { oldValue = wc.getAttributes().get(attributeId); } catch (CoreException e) { /* ignored on purpose */ }
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/persistence/projects/ReferencedProjectItem.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/persistence/projects/ReferencedProjectItem.java
index ca39a9b9a..0c5d8d0b3 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/persistence/projects/ReferencedProjectItem.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/persistence/projects/ReferencedProjectItem.java
@@ -47,12 +47,25 @@ public class ReferencedProjectItem extends PropertiesContainer implements IRefer
}
/* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.properties.PropertiesContainer#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ if (getProjectName() != null) {
+ return getProjectName().hashCode();
+ }
+ return super.hashCode();
+ }
+
+ /* (non-Javadoc)
* @see org.eclipse.tcf.te.runtime.properties.PropertiesContainer#equals(java.lang.Object)
*/
@Override
public boolean equals(Object obj) {
if (obj instanceof IReferencedProjectItem) {
- return getProjectName().equals(((IReferencedProjectItem)obj).getProjectName());
+ String pn1 = getProjectName();
+ String pn2 = ((IReferencedProjectItem)obj).getProjectName();
+ return pn1 != null ? pn1.equals(pn2) : pn2 == null;
}
return super.equals(obj);
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/selection/AbstractSelectionContext.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/selection/AbstractSelectionContext.java
index 46eb193b6..5b8bdc65b 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/selection/AbstractSelectionContext.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/selection/AbstractSelectionContext.java
@@ -9,6 +9,8 @@
*******************************************************************************/
package org.eclipse.tcf.te.launch.core.selection;
+import java.util.Arrays;
+
import org.eclipse.tcf.te.launch.core.selection.interfaces.ISelectionContext;
/**
@@ -137,7 +139,7 @@ public abstract class AbstractSelectionContext implements ISelectionContext {
hashCode ^= Boolean.valueOf(isPreferred).hashCode();
if (selections != null) {
- hashCode ^= selections.hashCode();
+ hashCode ^= Arrays.hashCode(selections);
}
return hashCode;
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/selection/LaunchSelection.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/selection/LaunchSelection.java
index 32a089814..8b9515e40 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/selection/LaunchSelection.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.core/src/org/eclipse/tcf/te/launch/core/selection/LaunchSelection.java
@@ -10,6 +10,7 @@
package org.eclipse.tcf.te.launch.core.selection;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
import org.eclipse.tcf.te.launch.core.selection.interfaces.ILaunchSelection;
@@ -41,7 +42,7 @@ public class LaunchSelection implements ILaunchSelection {
*/
public LaunchSelection(String mode, ISelectionContext[] contexts) {
this.mode = mode;
- this.contexts = contexts;
+ this.contexts = contexts != null ? Arrays.copyOf(contexts, contexts.length) : null;
}
/* (non-Javadoc)
@@ -57,7 +58,7 @@ public class LaunchSelection implements ILaunchSelection {
*/
@Override
public ISelectionContext[] getSelectedContexts() {
- return contexts != null ? contexts : new ISelectionContext[0];
+ return contexts != null ? Arrays.copyOf(contexts, contexts.length) : new ISelectionContext[0];
}
/* (non-Javadoc)

Back to the top