Mercurial > hg > release > thermostat-0.9
changeset 107:fd0aba264820
cleanup warnings throughout project
reviewed-by: omajid
review-thread: http://icedtea.classpath.org/pipermail/thermostat/2012-March/000269.html
line wrap: on
line diff
--- a/agent/src/main/java/com/redhat/thermostat/backend/system/ProcessStatusInfo.java Wed Mar 07 09:39:52 2012 -0500 +++ b/agent/src/main/java/com/redhat/thermostat/backend/system/ProcessStatusInfo.java Wed Mar 07 16:34:26 2012 -0500 @@ -81,7 +81,6 @@ this.pid = scanner.nextInt(); scanner.close(); - int execStartNamePos = statusLine.indexOf('('); int execEndNamePos = statusLine.lastIndexOf(')'); String cleanStatusLine = statusLine.substring(execEndNamePos + 1);
--- a/client/src/main/java/com/redhat/thermostat/client/HostPanelFacade.java Wed Mar 07 09:39:52 2012 -0500 +++ b/client/src/main/java/com/redhat/thermostat/client/HostPanelFacade.java Wed Mar 07 16:34:26 2012 -0500 @@ -36,13 +36,15 @@ package com.redhat.thermostat.client; +import java.util.List; + import javax.swing.table.TableModel; import org.jfree.data.time.TimeSeriesCollection; public interface HostPanelFacade extends AsyncUiFacade { - public DiscreteTimeData<Long>[] getMemoryUsage(MemoryType type); + public List<DiscreteTimeData<Long>> getMemoryUsage(MemoryType type); public MemoryType[] getMemoryTypesToDisplay();
--- a/client/src/main/java/com/redhat/thermostat/client/HostPanelFacadeImpl.java Wed Mar 07 09:39:52 2012 -0500 +++ b/client/src/main/java/com/redhat/thermostat/client/HostPanelFacadeImpl.java Wed Mar 07 16:34:26 2012 -0500 @@ -229,7 +229,7 @@ } @Override - public DiscreteTimeData<Long>[] getMemoryUsage(MemoryType type) { + public List<DiscreteTimeData<Long>> getMemoryUsage(MemoryType type) { List<DiscreteTimeData<Long>> data = new ArrayList<DiscreteTimeData<Long>>(); BasicDBObject queryObject = new BasicDBObject(); queryObject.put("agent-id", agent.getAgentId()); @@ -248,7 +248,7 @@ } // TODO we may also want to avoid sending out thousands of values. // a subset of the values from this entire array should suffice. - return (DiscreteTimeData<Long>[]) data.toArray(new DiscreteTimeData<?>[0]); + return data; } @Override @@ -280,7 +280,7 @@ updater.execute(); } - private static class CpuLoadChartUpdater extends SwingWorker<DiscreteTimeData<Double>[], Void> { + private static class CpuLoadChartUpdater extends SwingWorker<List<DiscreteTimeData<Double>>, Void> { private HostPanelFacadeImpl facade; @@ -289,11 +289,11 @@ } @Override - protected DiscreteTimeData<Double>[] doInBackground() throws Exception { + protected List<DiscreteTimeData<Double>> doInBackground() throws Exception { return getCpuLoad(facade.cpuLoadLastUpdateTime); } - private DiscreteTimeData<Double>[] getCpuLoad(long after) { + private List<DiscreteTimeData<Double>> getCpuLoad(long after) { List<DiscreteTimeData<Double>> load = new ArrayList<DiscreteTimeData<Double>>(); BasicDBObject queryObject = new BasicDBObject(); queryObject.put("agent-id", facade.agent.getAgentId()); @@ -313,7 +313,7 @@ } // TODO we may also want to avoid sending out thousands of values. // a subset of values from this entire array should suffice. - return (DiscreteTimeData<Double>[]) load.toArray(new DiscreteTimeData<?>[0]); + return load; } @Override @@ -324,7 +324,7 @@ facade.cpuLoadSeries.clear(); } - DiscreteTimeData<Double>[] data = get(); + List<DiscreteTimeData<Double>> data = get(); appendCpuChartData(data); } catch (ExecutionException ee) { @@ -334,8 +334,8 @@ } } - private void appendCpuChartData(DiscreteTimeData<Double>[] cpuData) { - if (cpuData.length > 0) { + private void appendCpuChartData(List<DiscreteTimeData<Double>> cpuData) { + if (cpuData.size() > 0) { /* * We have lots of new data to add. we do it in 2 steps: @@ -343,10 +343,7 @@ * 2. Notify the chart that there has been a change. It does * all the expensive computations and redraws itself. */ - - DiscreteTimeData<Double> data; - for (int i = 0; i < cpuData.length; i++) { - data = cpuData[i]; + for (DiscreteTimeData<Double> data: cpuData) { facade.cpuLoadLastUpdateTime = Math.max(facade.cpuLoadLastUpdateTime, data.getTimeInMillis()); facade.cpuLoadSeries.add( new FixedMillisecond(data.getTimeInMillis()), data.getData(),
--- a/client/src/main/java/com/redhat/thermostat/client/MainWindowFacadeImpl.java Wed Mar 07 09:39:52 2012 -0500 +++ b/client/src/main/java/com/redhat/thermostat/client/MainWindowFacadeImpl.java Wed Mar 07 16:34:26 2012 -0500 @@ -227,7 +227,9 @@ } private void syncTree(DefaultMutableTreeNode sourceRoot, DefaultTreeModel targetModel, DefaultMutableTreeNode targetNode) { + @SuppressWarnings("unchecked") // We know what we put into these trees. List<DefaultMutableTreeNode> sourceChildren = Collections.list(sourceRoot.children()); + @SuppressWarnings("unchecked") List<DefaultMutableTreeNode> targetChildren = Collections.list(targetNode.children()); for (DefaultMutableTreeNode sourceChild : sourceChildren) { Ref sourceRef = (Ref) sourceChild.getUserObject(); @@ -266,9 +268,12 @@ } } + @SuppressWarnings("unused") // Used for debugging but not in production code. private static void printTree(PrintStream out, TreeNode node, int depth) { out.println(StringUtils.repeat(" ", depth) + node.toString()); - for (TreeNode child : (List<TreeNode>) Collections.list(node.children())) { + @SuppressWarnings("unchecked") + List<TreeNode> children = Collections.list(node.children()); + for (TreeNode child : children) { printTree(out, child, depth + 1); } }
--- a/client/src/main/java/com/redhat/thermostat/client/VmPanelFacadeImpl.java Wed Mar 07 09:39:52 2012 -0500 +++ b/client/src/main/java/com/redhat/thermostat/client/VmPanelFacadeImpl.java Wed Mar 07 16:34:26 2012 -0500 @@ -237,7 +237,8 @@ BasicDBObject queryObject = new BasicDBObject(); queryObject.put("agent-id", ref.getAgent().getAgentId()); queryObject.put("vm-id", Integer.valueOf(ref.getId())); - List results = vmGcStatsCollection.distinct("collector", queryObject); + @SuppressWarnings("unchecked") // This is temporary; this will eventually come from a DAO as the correct type. + List<String> results = vmGcStatsCollection.distinct("collector", queryObject); List<String> collectorNames = new ArrayList<String>(results); return collectorNames.toArray(new String[0]); @@ -251,7 +252,7 @@ } } - public static class CollectorChartUpdater extends SwingWorker<DiscreteTimeData<Double>[], Void> { + public static class CollectorChartUpdater extends SwingWorker<List<DiscreteTimeData<Double>>, Void> { private VmPanelFacadeImpl facade; private String collectorName; @@ -262,7 +263,7 @@ } @Override - protected DiscreteTimeData<Double>[] doInBackground() throws Exception { + protected List<DiscreteTimeData<Double>> doInBackground() throws Exception { Long after = facade.collectorSeriesLastUpdateTime.get(collectorName); if (after == null) { after = Long.MIN_VALUE; @@ -270,7 +271,7 @@ return getCollectorRunTime(after); } - private DiscreteTimeData<Double>[] getCollectorRunTime(long after) { + private List<DiscreteTimeData<Double>> getCollectorRunTime(long after) { ArrayList<DiscreteTimeData<Double>> result = new ArrayList<DiscreteTimeData<Double>>(); BasicDBObject queryObject = new BasicDBObject(); queryObject.put("agent-id", facade.ref.getAgent().getAgentId()); @@ -292,7 +293,7 @@ result.add(new DiscreteTimeData<Double>(timestamp, walltime)); } - return (DiscreteTimeData<Double>[]) result.toArray(new DiscreteTimeData<?>[0]); + return result; } @Override @@ -311,10 +312,10 @@ } } - private long appendCollectorDataToChart(DiscreteTimeData<Double>[] collectorData, TimeSeries collectorSeries, long prevMaxTime) { + private long appendCollectorDataToChart(List<DiscreteTimeData<Double>> collectorData, TimeSeries collectorSeries, long prevMaxTime) { long maxTime = prevMaxTime; - if (collectorData.length > 0) { + if (collectorData.size() > 0) { /* * We have lots of new data to add. we do it in 2 steps: @@ -322,10 +323,7 @@ * 2. Notify the chart that there has been a change. It * does all the expensive computations and redraws itself. */ - - DiscreteTimeData<Double> data; - for (int i = 0; i < collectorData.length; i++) { - data = collectorData[i]; + for (DiscreteTimeData<Double> data : collectorData) { maxTime = Math.max(maxTime, data.getTimeInMillis()); collectorSeries.add( new FixedMillisecond(data.getTimeInMillis()), data.getData(),
--- a/client/src/main/java/com/redhat/thermostat/client/ui/AboutDialog.java Wed Mar 07 09:39:52 2012 -0500 +++ b/client/src/main/java/com/redhat/thermostat/client/ui/AboutDialog.java Wed Mar 07 16:34:26 2012 -0500 @@ -67,6 +67,8 @@ public class AboutDialog extends JDialog { + private static final long serialVersionUID = -7611616871710076514L; + private static final Logger logger = LoggingUtils.getLogger(AboutDialog.class); private String name;
--- a/client/src/main/java/com/redhat/thermostat/client/ui/HostPanel.java Wed Mar 07 09:39:52 2012 -0500 +++ b/client/src/main/java/com/redhat/thermostat/client/ui/HostPanel.java Wed Mar 07 16:34:26 2012 -0500 @@ -251,7 +251,7 @@ for (MemoryType type : facade.getMemoryTypesToDisplay()) { XYSeries series = new XYSeries(type.name()); - DiscreteTimeData<Long>[] data = facade.getMemoryUsage(type); + List<DiscreteTimeData<Long>> data = facade.getMemoryUsage(type); for (DiscreteTimeData<Long> point : data) { series.add(point.getTimeInMillis(), point.getData()); }
--- a/client/src/main/java/com/redhat/thermostat/client/ui/MainWindow.java Wed Mar 07 09:39:52 2012 -0500 +++ b/client/src/main/java/com/redhat/thermostat/client/ui/MainWindow.java Wed Mar 07 16:34:26 2012 -0500 @@ -369,6 +369,9 @@ } private static class Separator extends JPopupMenu.Separator { + + private static final long serialVersionUID = 3061771592573345826L; + @Override public Dimension getPreferredSize() { Dimension result = super.getPreferredSize();
--- a/client/src/main/java/com/redhat/thermostat/client/ui/RecentTimeSeriesChartPanel.java Wed Mar 07 09:39:52 2012 -0500 +++ b/client/src/main/java/com/redhat/thermostat/client/ui/RecentTimeSeriesChartPanel.java Wed Mar 07 16:34:26 2012 -0500 @@ -79,7 +79,7 @@ JPanel container = new JPanel(); final JTextField durationSelector = new JTextField(5); - final JComboBox unitSelector = new JComboBox(controller.getTimeUnits()); + final JComboBox<TimeUnit> unitSelector = new JComboBox<>(controller.getTimeUnits()); int defaultValue = controller.getTimeValue(); TimeUnit defaultUnit = controller.getTimeUnit(); @@ -143,7 +143,8 @@ @Override public void actionPerformed(ActionEvent e) { - JComboBox comboBox = (JComboBox) e.getSource(); + @SuppressWarnings("unchecked") // We are a TimeUnitChangeListener, specifically. + JComboBox<TimeUnit> comboBox = (JComboBox<TimeUnit>) e.getSource(); TimeUnit time = (TimeUnit) comboBox.getSelectedItem(); this.unit = time; updateChartParameters();
--- a/client/src/main/java/com/redhat/thermostat/client/ui/SummaryPanel.java Wed Mar 07 09:39:52 2012 -0500 +++ b/client/src/main/java/com/redhat/thermostat/client/ui/SummaryPanel.java Wed Mar 07 16:34:26 2012 -0500 @@ -70,9 +70,9 @@ Section summarySection = new Section(localize(LocaleResources.HOME_PANEL_SECTION_SUMMARY)); sections.add(summarySection); - entry = new TableEntry(localize(LocaleResources.HOME_PANEL_TOTAL_MACHINES), facade.getTotalConnectedAgents()); + entry = new TableEntry(localize(LocaleResources.HOME_PANEL_TOTAL_MACHINES), this.facade.getTotalConnectedAgents()); summarySection.add(entry); - entry = new TableEntry(localize(LocaleResources.HOME_PANEL_TOTAL_JVMS), facade.getTotalConnectedVms()); + entry = new TableEntry(localize(LocaleResources.HOME_PANEL_TOTAL_JVMS), this.facade.getTotalConnectedVms()); summarySection.add(entry); SimpleTable simpleTable = new SimpleTable(); @@ -92,15 +92,15 @@ result.add(Components.header(localize(LocaleResources.HOME_PANEL_SECTION_ISSUES)), BorderLayout.PAGE_START); - ListModel model = new IssuesListModel(new ArrayList<Object>()); + ListModel<Object> model = new IssuesListModel(new ArrayList<>()); - JList issuesList = new JList(model); + JList<Object> issuesList = new JList<>(model); result.add(new JScrollPane(issuesList), BorderLayout.CENTER); return result; } - private static class IssuesListModel extends AbstractListModel { + private static class IssuesListModel extends AbstractListModel<Object> { private static final long serialVersionUID = 7131506292620902850L;
--- a/client/src/main/java/com/redhat/thermostat/client/ui/VmClassStatPanel.java Wed Mar 07 09:39:52 2012 -0500 +++ b/client/src/main/java/com/redhat/thermostat/client/ui/VmClassStatPanel.java Wed Mar 07 16:34:26 2012 -0500 @@ -52,6 +52,7 @@ public class VmClassStatPanel extends JPanel implements VmClassStatView { + private static final long serialVersionUID = 1067532168697544774L; private Component chartPanel; public VmClassStatPanel() {
--- a/client/src/main/java/com/redhat/thermostat/client/ui/WrapLayout.java Wed Mar 07 09:39:52 2012 -0500 +++ b/client/src/main/java/com/redhat/thermostat/client/ui/WrapLayout.java Wed Mar 07 16:34:26 2012 -0500 @@ -1,5 +1,5 @@ /* - * Copyright 2012 Red Hat, Inc. + * Copyright 2008 Rob Camick, 2012 Red Hat, Inc. * * This file is part of Thermostat. * @@ -52,11 +52,11 @@ /** * FlowLayout subclass that fully supports wrapping of components. */ -public class WrapLayout extends FlowLayout -{ - private Dimension preferredLayoutSize; +public class WrapLayout extends FlowLayout { - /** + private static final long serialVersionUID = -9169664895883997422L; + + /** * Constructs a new <code>WrapLayout</code> with a left * alignment and a default 5-unit horizontal and vertical gap. */
--- a/common/src/main/java/com/redhat/thermostat/common/dao/MongoConnection.java Wed Mar 07 09:39:52 2012 -0500 +++ b/common/src/main/java/com/redhat/thermostat/common/dao/MongoConnection.java Wed Mar 07 16:34:26 2012 -0500 @@ -162,5 +162,6 @@ } private class LocalAgentException extends RuntimeException { + private static final long serialVersionUID = -4507363475778127729L; } }
--- a/common/src/main/java/com/redhat/thermostat/common/dao/MongoDAOFactory.java Wed Mar 07 09:39:52 2012 -0500 +++ b/common/src/main/java/com/redhat/thermostat/common/dao/MongoDAOFactory.java Wed Mar 07 16:34:26 2012 -0500 @@ -36,9 +36,6 @@ package com.redhat.thermostat.common.dao; -import java.util.Properties; - - public class MongoDAOFactory implements DAOFactory { private MongoConnection connection;