diff options
author | Uwe Stieber | 2012-05-25 11:17:57 +0000 |
---|---|---|
committer | Uwe Stieber | 2012-05-25 11:17:57 +0000 |
commit | 56f65bf8bd24b9bfe88cab99cbed1c566db133c3 (patch) | |
tree | ab167315ef684d3ba6c5de9e9a31dee1e15da48d | |
parent | 4d557cc7b17b91c4d6de3827b1d7668fced82366 (diff) | |
download | org.eclipse.tcf-56f65bf8bd24b9bfe88cab99cbed1c566db133c3.tar.gz org.eclipse.tcf-56f65bf8bd24b9bfe88cab99cbed1c566db133c3.tar.xz org.eclipse.tcf-56f65bf8bd24b9bfe88cab99cbed1c566db133c3.zip |
TargetExplorer: More findbugs fixes
5 files changed, 31 insertions, 17 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime/src/org/eclipse/tcf/te/runtime/events/EventManager.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime/src/org/eclipse/tcf/te/runtime/events/EventManager.java index ef9d63a9c..1929a10c4 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.runtime/src/org/eclipse/tcf/te/runtime/events/EventManager.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime/src/org/eclipse/tcf/te/runtime/events/EventManager.java @@ -150,11 +150,22 @@ public final class EventManager { } /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + if (getListener() != null) { + return getListener().hashCode(); + } + return super.hashCode(); + } + + /* (non-Javadoc) * @see java.lang.Object#equals(java.lang.Object) */ @Override public boolean equals(Object obj) { - if (obj != null && obj instanceof ListenerListEntry) { + if (obj instanceof ListenerListEntry) { ListenerListEntry other = (ListenerListEntry)obj; return this.getListener() == other.getListener(); } @@ -276,7 +287,9 @@ public final class EventManager { */ public void clear() { listeners.clear(); - extensionPointProcessed = false; + synchronized (this) { + extensionPointProcessed = false; + } } /** diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime/src/org/eclipse/tcf/te/runtime/extensions/ExecutableExtension.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime/src/org/eclipse/tcf/te/runtime/extensions/ExecutableExtension.java index 439288869..a3da6f82a 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.runtime/src/org/eclipse/tcf/te/runtime/extensions/ExecutableExtension.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime/src/org/eclipse/tcf/te/runtime/extensions/ExecutableExtension.java @@ -70,7 +70,7 @@ public class ExecutableExtension extends PlatformObject implements IExecutableEx // Initialize the id field by reading the <id> extension attribute. // Throws an exception if the id is empty or null. id = config != null ? config.getAttribute("id") : null; //$NON-NLS-1$ - if (id == null || (id != null && "".equals(id.trim()))) { //$NON-NLS-1$ + if (id == null || "".equals(id.trim())) { //$NON-NLS-1$ throw createMissingMandatoryAttributeException("id", config.getContributor().getName()); //$NON-NLS-1$ } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime/src/org/eclipse/tcf/te/runtime/extensions/ExecutableExtensionProxy.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime/src/org/eclipse/tcf/te/runtime/extensions/ExecutableExtensionProxy.java index 3b3100195..c60417a6c 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.runtime/src/org/eclipse/tcf/te/runtime/extensions/ExecutableExtensionProxy.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime/src/org/eclipse/tcf/te/runtime/extensions/ExecutableExtensionProxy.java @@ -121,8 +121,9 @@ public class ExecutableExtensionProxy<V> { Assert.isNotNull(element); // The "class" to load can be specified either as attribute or as child element - String attributeName = getExecutableExtensionAttributeName() != null ? getExecutableExtensionAttributeName() : "class"; //$NON-NLS-1$ - if (element != null && (element.getAttribute(attributeName) != null || element.getChildren(attributeName).length > 0)) { + String attributeName = getExecutableExtensionAttributeName(); + Assert.isNotNull(attributeName); + if (element.getAttribute(attributeName) != null || element.getChildren(attributeName).length > 0) { try { return (V)element.createExecutableExtension(attributeName); } catch (Exception e) { diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime/src/org/eclipse/tcf/te/runtime/properties/PropertiesContainer.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime/src/org/eclipse/tcf/te/runtime/properties/PropertiesContainer.java index bfaf6646e..b517d49b2 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.runtime/src/org/eclipse/tcf/te/runtime/properties/PropertiesContainer.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime/src/org/eclipse/tcf/te/runtime/properties/PropertiesContainer.java @@ -35,7 +35,7 @@ import org.eclipse.tcf.te.runtime.interfaces.tracing.ITraceIds; public class PropertiesContainer extends PlatformObject implements IPropertiesContainer {
// Used to have a simple check that the random generated UUID isn't
// the same if objects of this type are created very rapidly.
- private static UUID LAST_UUID_GENERATED = null;
+ private volatile static UUID LAST_UUID_GENERATED = null;
// The unique node id
private final UUID uniqueId;
@@ -463,7 +463,7 @@ public class PropertiesContainer extends PlatformObject implements IPropertiesCo @Override
public final boolean setProperty(String key, float value) {
float oldValue = getFloatProperty(key);
- if (oldValue != value) {
+ if (Math.abs(oldValue - value) >= .0000001) {
return setProperty(key, Float.valueOf(value));
}
return false;
@@ -475,7 +475,7 @@ public class PropertiesContainer extends PlatformObject implements IPropertiesCo @Override
public final boolean setProperty(String key, double value) {
double oldValue = getDoubleProperty(key);
- if (oldValue != value) {
+ if (Math.abs(oldValue - value) >= .0000001) {
return setProperty(key, Double.valueOf(value));
}
return false;
@@ -574,7 +574,7 @@ public class PropertiesContainer extends PlatformObject implements IPropertiesCo */
@Override
public final boolean isProperty(String key, float value) {
- return getFloatProperty(key) == value;
+ return Math.abs(getFloatProperty(key) - value) < .0000001;
}
/* (non-Javadoc)
@@ -582,7 +582,7 @@ public class PropertiesContainer extends PlatformObject implements IPropertiesCo */
@Override
public final boolean isProperty(String key, double value) {
- return getDoubleProperty(key) == value;
+ return Math.abs(getDoubleProperty(key) - value) < .0000001;
}
/* (non-Javadoc)
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime/src/org/eclipse/tcf/te/runtime/utils/net/IPAddressUtil.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime/src/org/eclipse/tcf/te/runtime/utils/net/IPAddressUtil.java index 617450d8d..50c1de508 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.runtime/src/org/eclipse/tcf/te/runtime/utils/net/IPAddressUtil.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime/src/org/eclipse/tcf/te/runtime/utils/net/IPAddressUtil.java @@ -3,7 +3,7 @@ * 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 http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: * Wind River Systems - initial API and implementation *******************************************************************************/ @@ -136,7 +136,7 @@ public class IPAddressUtil { addrtype |= HOSTMAP_IPV6; } String addrAsString = addr.getHostAddress(); - fLocalHostAddresses.put(addrAsString, new Integer(addrtype | HOSTMAP_ADDR)); + fLocalHostAddresses.put(addrAsString, Integer.valueOf(addrtype | HOSTMAP_ADDR)); if (0 == (addrtype & (HOSTMAP_LINKLOCAL | HOSTMAP_SITELOCAL | HOSTMAP_MULTICAST))) { // Don't do DNS Reverse Loopkup's for non-routable addresses. // They won't be known to the Name Server anyway, and they @@ -150,17 +150,17 @@ public class IPAddressUtil { // returns the original address in case it thinks the name is spoofed! if (0 == (addrtype & HOSTMAP_LOOPBACK)) { // Not loopback --> found a Canonical Name. - fLocalHostAddresses.put(addrAsNameCan, new Integer(addrtype | HOSTMAP_NAME | HOSTMAP_CANONICALNAME)); + fLocalHostAddresses.put(addrAsNameCan, Integer.valueOf(addrtype | HOSTMAP_NAME | HOSTMAP_CANONICALNAME)); // override the address as canonical-address - fLocalHostAddresses.put(addrAsString, new Integer(addrtype | HOSTMAP_ADDR | HOSTMAP_CANONICALADDR)); + fLocalHostAddresses.put(addrAsString, Integer.valueOf(addrtype | HOSTMAP_ADDR | HOSTMAP_CANONICALADDR)); } else { // Loopback --> add the found name as non-canonical. - fLocalHostAddresses.put(addrAsNameCan, new Integer(addrtype | HOSTMAP_NAME)); + fLocalHostAddresses.put(addrAsNameCan, Integer.valueOf(addrtype | HOSTMAP_NAME)); } } if (!addrAsName.equals(addrAsString) && !addrAsName.equals(addrAsNameCan)) { // don't override the canonical name by the name. - fLocalHostAddresses.put(addrAsName, new Integer(addrtype | HOSTMAP_NAME)); + fLocalHostAddresses.put(addrAsName, Integer.valueOf(addrtype | HOSTMAP_NAME)); } } } @@ -186,7 +186,7 @@ public class IPAddressUtil { // found a new name for a known local address ? if (!fLocalHostAddresses.containsKey(hostName)) { int addrtype = entryType.intValue() & (~(HOSTMAP_ADDR | HOSTMAP_CANONICALADDR)); - fLocalHostAddresses.put(hostName, new Integer(addrtype | HOSTMAP_NAME)); + fLocalHostAddresses.put(hostName, Integer.valueOf(addrtype | HOSTMAP_NAME)); } return true; } |