Add check before we add more rows

This commit is contained in:
Brian Carrier 2014-03-18 21:32:52 -04:00
parent 6ceb859f30
commit 4e169433c3

View File

@ -391,12 +391,21 @@ public class DataResultViewerTable extends AbstractDataResultViewer {
// Populate a two-dimensional array with rows of property values for up // Populate a two-dimensional array with rows of property values for up
// to maxRows children of the node passed in. // to maxRows children of the node passed in.
private static Object[][] getRowValues(Node node, int maxRows) { private static Object[][] getRowValues(Node node, int maxRows) {
Object[][] rowValues = new Object[Math.min(maxRows, node.getChildren().getNodesCount())][]; int numRows = Math.min(maxRows, node.getChildren().getNodesCount());
Object[][] rowValues = new Object[numRows][];
int rowCount = 0; int rowCount = 0;
for (Node child : node.getChildren().getNodes()) { for (Node child : node.getChildren().getNodes()) {
if (rowCount >= maxRows) { if (rowCount >= maxRows) {
break; break;
} }
// BC: I got this once, I think it was because the table
// refreshed while we were in this method
// could be better synchronized. Or it was from
// the lazy nodes updating... Didn't have time
// to fully debug it.
if (rowCount > numRows) {
break;
}
PropertySet[] propertySets = child.getPropertySets(); PropertySet[] propertySets = child.getPropertySets();
if (propertySets.length > 0) { if (propertySets.length > 0) {
Property[] properties = propertySets[0].getProperties(); Property[] properties = propertySets[0].getProperties();