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 - Invalid call of CompoundModel.getValueAt(node, column)
Summary: Invalid call of CompoundModel.getValueAt(node, column)
Status: NEW
Alias: None
Product: platform
Classification: Unclassified
Component: Outline&TreeTable (show other bugs)
Version: 8.1
Hardware: PC Linux
: P3 normal with 1 vote (vote)
Assignee: Martin Entlicher
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-03-15 10:22 UTC by epele83
Modified: 2016-03-15 10:22 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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