This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 258373

Summary: Invalid call of CompoundModel.getValueAt(node, column)
Product: platform Reporter: epele83 <epele83>
Component: Outline&TreeTableAssignee: Martin Entlicher <mentlicher>
Status: NEW ---    
Severity: normal    
Priority: P3    
Version: 8.1   
Hardware: PC   
OS: Linux   
Issue Type: DEFECT Exception Reporter:

Description epele83 2016-03-15 10:22:36 UTC
I found a problem in the org/netbeans/modules/viewmodel/TreeModelNode.java
at line 2127 in the updateShortDescription the method model.getValueAt is called passing the JTooltip instead of the Node Object.
This is going to cause a Illegal Cast Exception in our client code.
Of course we will protect our code checking the instance of the object before to cast it, but I think this method is used improperly in the case.

Here the code.


private String updateShortDescription() {
            try {
                javax.swing.JToolTip tooltip = new javax.swing.JToolTip();
                String sd = null;
                try {
                    tooltip.putClientProperty("getShortDescription", object); // NOI18N
                    Object tooltipObj = model.getValueAt(tooltip, id);
                    if (tooltipObj != null) {
                        sd = adjustHTML(tooltipObj.toString());
                    }
                    return sd;
                } finally {
                    // We MUST clear the client property, Swing holds this in a static reference!
                    tooltip.putClientProperty("getShortDescription", null); // NOI18N
                    synchronized (properties) {
                        properties.put (id + "#shortDescription", sd);
                    }
                }
            } catch (UnknownTypeException e) {
                // Ignore models that do not define tooltips for values.
                return null;
            }
        }

Thanks
-Paolo