diff options
14 files changed, 97 insertions, 44 deletions
diff --git a/admin/findbugs-exclude.xml b/admin/findbugs-exclude.xml index 1d9899b40..5d57753ad 100644 --- a/admin/findbugs-exclude.xml +++ b/admin/findbugs-exclude.xml @@ -55,5 +55,37 @@ <Method name="initialize"/> </And> </Match> + + <!-- Filters for org.eclipse.tcf bundle --> + <Match> + <Bug pattern="ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD"/> + <And> + <Class name="org.eclipse.tcf.Activator"/> + <Method name="initialize"/> + </And> + </Match> + + <!-- Filters for org.eclipse.tcf.core bundle --> + <Match> + <Bug pattern="EI_EXPOSE_REP2"/> + <And> + <Class name="org.eclipse.tcf.core.Command"/> + <Method name="initialize"/> + </And> + </Match> + <Match> + <Bug pattern="STCAL_INVOKE_ON_STATIC_DATE_FORMAT_INSTANCE"/> + <And> + <Class name="org.eclipse.tcf.core.Command"/> + <Method name="appendErrorProps"/> + </And> + </Match> + + <!-- Filters for org.eclipse.tcf.debug.ui bundle --> + <Match> + <Bug pattern="ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD"/> + <Class name="org.eclipse.tcf.internal.debug.ui.model.TCFNodeSymbol"/> + </Match> + </FindBugsFilter> diff --git a/plugins/org.eclipse.tcf.core/src/org/eclipse/tcf/core/AbstractChannel.java b/plugins/org.eclipse.tcf.core/src/org/eclipse/tcf/core/AbstractChannel.java index 4d982807e..18f9b8f9c 100644 --- a/plugins/org.eclipse.tcf.core/src/org/eclipse/tcf/core/AbstractChannel.java +++ b/plugins/org.eclipse.tcf.core/src/org/eclipse/tcf/core/AbstractChannel.java @@ -610,7 +610,7 @@ public abstract class AbstractChannel implements IChannel { synchronized (out_queue) { out_queue.clear(); out_queue.add(null); - out_queue.notify(); + out_queue.notifyAll(); } out_thread.join(timeout); } @@ -657,6 +657,7 @@ public abstract class AbstractChannel implements IChannel { else if (error != null) x = new Exception(error); else x = new IOException("Channel is closed"); for (Message msg : out_tokens.values()) { + assert msg.token != null; try { String s = msg.toString(); if (s.length() > 72) s = s.substring(0, 72) + "...]"; @@ -773,7 +774,7 @@ public abstract class AbstractChannel implements IChannel { msg.trace = trace_listeners; synchronized (out_queue) { out_queue.add(msg); - out_queue.notify(); + out_queue.notifyAll(); } } @@ -788,13 +789,14 @@ public abstract class AbstractChannel implements IChannel { Token token = new Token(listener) { @Override public boolean cancel() { + assert msg.token == this; assert Protocol.isDispatchThread(); if (state != STATE_OPEN) return false; synchronized (out_queue) { if (msg.is_sent) return false; msg.is_canceled = true; } - out_tokens.remove(msg.token.getID()); + out_tokens.remove(getID()); return true; } }; @@ -877,6 +879,8 @@ public abstract class AbstractChannel implements IChannel { } switch (msg.type) { case 'C': + assert msg.service != null; + assert msg.name != null; if (state == STATE_OPENING) { throw new IOException("Received command " + msg.service + "." + msg.name + " before Hello message"); } @@ -915,6 +919,8 @@ public abstract class AbstractChannel implements IChannel { } break; case 'E': + assert msg.service != null; + assert msg.name != null; boolean hello = msg.service.equals(ILocator.NAME) && msg.name.equals("Hello"); if (hello) { remote_service_by_name.clear(); diff --git a/plugins/org.eclipse.tcf.core/src/org/eclipse/tcf/core/AbstractPeer.java b/plugins/org.eclipse.tcf.core/src/org/eclipse/tcf/core/AbstractPeer.java index 0bec71205..632fbe030 100644 --- a/plugins/org.eclipse.tcf.core/src/org/eclipse/tcf/core/AbstractPeer.java +++ b/plugins/org.eclipse.tcf.core/src/org/eclipse/tcf/core/AbstractPeer.java @@ -11,7 +11,6 @@ package org.eclipse.tcf.core; import java.io.IOException; -import java.util.Iterator; import java.util.Map; import org.eclipse.tcf.internal.core.RemotePeer; @@ -63,24 +62,9 @@ public class AbstractPeer extends TransientPeer { } public void updateAttributes(Map<String,String> attrs) { - boolean equ = true; - assert attrs.get(ATTR_ID).equals(rw_attrs.get(ATTR_ID)); - for (Iterator<String> i = rw_attrs.keySet().iterator(); i.hasNext();) { - String key = i.next(); - if (!rw_attrs.get(key).equals(attrs.get(key))) { - equ = false; - break; - } - } - for (Iterator<String> i = attrs.keySet().iterator(); i.hasNext();) { - String key = i.next(); - if (!attrs.get(key).equals(rw_attrs.get(key))) { - equ = false; - break; - } - } long time = System.currentTimeMillis(); - if (!equ) { + if (!attrs.equals(ro_attrs)) { + assert attrs.get(ATTR_ID).equals(rw_attrs.get(ATTR_ID)); rw_attrs.clear(); rw_attrs.putAll(attrs); for (LocatorListener l : LocatorService.getListeners()) { diff --git a/plugins/org.eclipse.tcf.core/src/org/eclipse/tcf/core/Command.java b/plugins/org.eclipse.tcf.core/src/org/eclipse/tcf/core/Command.java index 711d60c3f..1061bc1bf 100644 --- a/plugins/org.eclipse.tcf.core/src/org/eclipse/tcf/core/Command.java +++ b/plugins/org.eclipse.tcf.core/src/org/eclipse/tcf/core/Command.java @@ -208,10 +208,10 @@ public abstract class Command implements IChannel.ICommandListener { bf.append('\n'); bf.append("Severity: "); switch (severity.intValue()) { - case IErrorReport.SEVERITY_ERROR: bf.append("Error"); - case IErrorReport.SEVERITY_FATAL: bf.append("Fatal"); - case IErrorReport.SEVERITY_WARNING: bf.append("Warning"); - default: bf.append("Unknown"); + case IErrorReport.SEVERITY_ERROR: bf.append("Error"); break; + case IErrorReport.SEVERITY_FATAL: bf.append("Fatal"); break; + case IErrorReport.SEVERITY_WARNING: bf.append("Warning"); break; + default: bf.append("Unknown"); break; } } bf.append('\n'); diff --git a/plugins/org.eclipse.tcf.core/src/org/eclipse/tcf/internal/services/local/ChannelProxy.java b/plugins/org.eclipse.tcf.core/src/org/eclipse/tcf/internal/services/local/ChannelProxy.java index 68dbf46eb..d0ffe84f7 100644 --- a/plugins/org.eclipse.tcf.core/src/org/eclipse/tcf/internal/services/local/ChannelProxy.java +++ b/plugins/org.eclipse.tcf.core/src/org/eclipse/tcf/internal/services/local/ChannelProxy.java @@ -130,6 +130,7 @@ class ChannelProxy { public void onChannelClosed(Throwable error) { ch_y.removeChannelListener(this); if (error == null) error = new Exception("Channel closed"); + ch_x.terminate(error); } public void onChannelOpened() { diff --git a/plugins/org.eclipse.tcf.core/src/org/eclipse/tcf/internal/services/local/LocatorService.java b/plugins/org.eclipse.tcf.core/src/org/eclipse/tcf/internal/services/local/LocatorService.java index 7242e4e98..db60679ca 100644 --- a/plugins/org.eclipse.tcf.core/src/org/eclipse/tcf/internal/services/local/LocatorService.java +++ b/plugins/org.eclipse.tcf.core/src/org/eclipse/tcf/internal/services/local/LocatorService.java @@ -408,8 +408,8 @@ public class LocatorService implements ILocator { private Map<String,Object> makeErrorReport(int code, String msg) { Map<String,Object> err = new HashMap<String,Object>(); - err.put(IErrorReport.ERROR_TIME, new Long(System.currentTimeMillis())); - err.put(IErrorReport.ERROR_CODE, new Integer(code)); + err.put(IErrorReport.ERROR_TIME, Long.valueOf(System.currentTimeMillis())); + err.put(IErrorReport.ERROR_CODE, Integer.valueOf(code)); err.put(IErrorReport.ERROR_FORMAT, msg); return err; } diff --git a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFNodeExpression.java b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFNodeExpression.java index 09e943d03..1e5b2ba7f 100644 --- a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFNodeExpression.java +++ b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFNodeExpression.java @@ -972,7 +972,7 @@ public class TCFNodeExpression extends TCFNode implements IElementEditor, ICastT break; } } - if (s == null) s = "N/A"; + assert s != null; return s; } @@ -1648,6 +1648,8 @@ public class TCFNodeExpression extends TCFNode implements IElementEditor, ICastT switch(eval.getTypeClass()) { case real: is_float = true; + signed = true; + break; case integer: signed = true; break; diff --git a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFNodeStackFrame.java b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFNodeStackFrame.java index 061a6ddc3..f72524b5c 100644 --- a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFNodeStackFrame.java +++ b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/model/TCFNodeStackFrame.java @@ -378,8 +378,8 @@ public class TCFNodeStackFrame extends TCFNode { if (!sym.getFlag(ISymbols.SYM_FLAG_PARAMETER)) continue; if (cnt > 0) bf.append(','); if (show_arg_names) { - String name = "?"; - if (sym != null && sym.getName() != null) name = sym.getName(); + String name = sym.getName(); + if (name == null) name = "?"; bf.append(name); if (show_arg_values) bf.append('='); } diff --git a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/properties/TCFBreakpointStatusPage.java b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/properties/TCFBreakpointStatusPage.java index bdfd6c840..3855b3dd6 100644 --- a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/properties/TCFBreakpointStatusPage.java +++ b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/properties/TCFBreakpointStatusPage.java @@ -93,6 +93,14 @@ public class TCFBreakpointStatusPage extends PropertyPage { if (n.object instanceof TCFNode) return -1; return 0; } + + @Override + public boolean equals(Object o) { + if (o instanceof StatusItem) { + return compareTo((StatusItem)o) == 0; + } + return false; + } } private class StatusCache extends TCFDataCache<StatusItem> { @@ -293,7 +301,7 @@ public class TCFBreakpointStatusPage extends PropertyPage { public Object[] getChildren(Object parent) { StatusItem x = (StatusItem)parent; - if (x.children == null) return null; + if (x.children == null) return new Object[0]; Object[] arr = x.children.toArray(new StatusItem[x.children.size()]); Arrays.sort(arr); return arr; @@ -411,7 +419,6 @@ public class TCFBreakpointStatusPage extends PropertyPage { @SuppressWarnings("unchecked") private Object[] toObjectArray(Object o) { - if (o == null) return null; Collection<Object> c = (Collection<Object>)o; return (Object[])c.toArray(new Object[c.size()]); } diff --git a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/trace/TraceView.java b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/trace/TraceView.java index 2da1d3c9d..a96f790b6 100644 --- a/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/trace/TraceView.java +++ b/plugins/org.eclipse.tcf.debug.ui/src/org/eclipse/tcf/internal/debug/ui/trace/TraceView.java @@ -187,9 +187,11 @@ public class TraceView extends ViewPart implements Protocol.ChannelOpenListener catch (InterruptedException e) { e.printStackTrace(); } - tab2page.remove(tab); - tab.dispose(); - tab = null; + if (tab != null) { + tab2page.remove(tab); + tab.dispose(); + tab = null; + } text = null; if (tab2page.isEmpty()) hideTabs(); } diff --git a/plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/model/TCFBreakpointsModel.java b/plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/model/TCFBreakpointsModel.java index 960bf2887..834f86dce 100644 --- a/plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/model/TCFBreakpointsModel.java +++ b/plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/model/TCFBreakpointsModel.java @@ -320,7 +320,6 @@ public class TCFBreakpointsModel { String id = (String)marker.getAttributes().get(ATTR_ID); if (id != null) return id; id = marker.getResource().getLocationURI().toString(); - if (id == null) return null; return id + ':' + marker.getId(); } @@ -539,7 +538,7 @@ public class TCFBreakpointsModel { } Number line = (Number)p.get(IBreakpoints.PROP_LINE); if (line != null) { - m.put(ATTR_LINE, new Integer(line.intValue())); + m.put(ATTR_LINE, Integer.valueOf(line.intValue())); Number column = (Number)p.get(IBreakpoints.PROP_COLUMN); if (column != null) { m.put(IMarker.CHAR_START, new Integer(column.intValue())); @@ -623,7 +622,7 @@ public class TCFBreakpointsModel { Integer line = (Integer)p.get(ATTR_REQESTED_LINE); if (line == null || line < 0) line = (Integer)p.get(ATTR_LINE); if (line != null && line >= 0) { - m.put(IBreakpoints.PROP_LINE, new Integer(line.intValue())); + m.put(IBreakpoints.PROP_LINE, Integer.valueOf(line.intValue())); Integer column = (Integer)p.get(ATTR_REQESTED_CHAR); if (column == null || column < 0) column = (Integer)p.get(ATTR_CHAR); if (column != null && column >= 0) m.put(IBreakpoints.PROP_COLUMN, column); diff --git a/plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/model/TCFBreakpointsStatus.java b/plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/model/TCFBreakpointsStatus.java index e489be911..2e4816f32 100644 --- a/plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/model/TCFBreakpointsStatus.java +++ b/plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/model/TCFBreakpointsStatus.java @@ -131,7 +131,6 @@ public class TCFBreakpointsStatus { public Map<String,Object> getStatus(IBreakpoint bp) { try { String id = TCFBreakpointsModel.getBreakpointID(bp); - if (id == null) return status_not_supported; return getStatus(id); } catch (CoreException e) { diff --git a/plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/model/TCFMemoryRegion.java b/plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/model/TCFMemoryRegion.java index 6810105ea..c8b327c0d 100644 --- a/plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/model/TCFMemoryRegion.java +++ b/plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/model/TCFMemoryRegion.java @@ -36,4 +36,12 @@ public class TCFMemoryRegion extends org.eclipse.tcf.util.TCFMemoryRegion implem if (r.addr == null) return +1; return addr.compareTo(r.addr); } + + @Override + public boolean equals(Object o) { + if (o instanceof TCFMemoryRegion) { + return compareTo((TCFMemoryRegion)o) == 0; + } + return false; + } } diff --git a/plugins/org.eclipse.tcf/src/org/eclipse/tcf/ssl/TCFSecurityManager.java b/plugins/org.eclipse.tcf/src/org/eclipse/tcf/ssl/TCFSecurityManager.java index 55624bca0..58bc0fcf6 100644 --- a/plugins/org.eclipse.tcf/src/org/eclipse/tcf/ssl/TCFSecurityManager.java +++ b/plugins/org.eclipse.tcf/src/org/eclipse/tcf/ssl/TCFSecurityManager.java @@ -43,7 +43,7 @@ import org.eclipse.tcf.protocol.Protocol; */ public class TCFSecurityManager { - public static File getCertificatesDirectory() { + public static File getCertificatesDirectory() throws IOException { File certs; try { certs = Activator.getDefault().getStateLocation().append("certificates").toFile(); //$NON-NLS-1$ @@ -53,7 +53,7 @@ public class TCFSecurityManager { certs = new File(System.getProperty("user.home"), ".tcf"); certs = new File(certs, "certificates"); } - if (!certs.exists()) certs.mkdirs(); + if (!certs.exists() && !certs.mkdirs()) throw new IOException("Cannot create directory: " + certs); return certs; } @@ -61,10 +61,12 @@ public class TCFSecurityManager { File file = null; String osname = System.getProperty("os.name", ""); if (osname.startsWith("Windows")) { + Process prs = null; + BufferedReader inp = null; try { String sys_root = "SystemRoot"; - Process prs = Runtime.getRuntime().exec(new String[]{ "cmd", "/c", "set", sys_root }, null); - BufferedReader inp = new BufferedReader(new InputStreamReader(prs.getInputStream())); + prs = Runtime.getRuntime().exec(new String[]{ "cmd", "/c", "set", sys_root }, null); + inp = new BufferedReader(new InputStreamReader(prs.getInputStream())); for (;;) { String s = inp.readLine(); if (s == null) break; @@ -83,10 +85,21 @@ public class TCFSecurityManager { inp.close(); } catch (IOException x) { + Protocol.log("Cannot close child process I/O streams", x); //$NON-NLS-1$ } prs.waitFor(); } catch (Throwable x) { + Protocol.log("Cannot get system directory name", x); //$NON-NLS-1$ + try { + if (prs != null) { + prs.getErrorStream().close(); + prs.getOutputStream().close(); + } + if (inp != null) inp.close(); + } + catch (IOException y) { + } } } else { @@ -118,7 +131,7 @@ public class TCFSecurityManager { inp.close(); return new X509Certificate[] { cert }; } - catch (Exception x) { + catch (Throwable x) { Protocol.log("Cannot read certificate: " + f, x); //$NON-NLS-1$ try { if (inp != null) inp.close(); |