jmeter-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <>
Subject [GitHub] [jmeter] weisJ opened a new pull request #621: Prevent NPE in ToolTipManager
Date Wed, 16 Sep 2020 20:01:32 GMT

weisJ opened a new pull request #621:

   ## Description
   Return an empty string instead of `null` in `#getToolTipText(MouseEvent)` for main frame
   ## Motivation and Context
   Even though the documentation for `JTree#getToolTipText(MouseEvent)` says to return `null`
if the event is `null` this violates an assumed invariant of the JDK 8 implementation of `ToolTipManager`.
   Generally the `ToolTipManager` assumes that `JComponent#getToolTipText(MouseEvent)` always
returns a non-null value. For components that simply return the value provided by `JComponent#setToolTipText(String)`
this is always the case. Setting the tooltip to a null/non-null value unregisters or registers
the component with the `ToolTipManager` respectively. For components such as trees where the
tooltip text may depend on the current mouse location inside the component this invariant
doesn't hold up (because the tree is registered through calling `tree.setToolTipText("")`).
   In some scenarios this can cause a `NullPointerException` to be thrown in `ToolTipManager#initiateToolTip`
specifically at the following location
    if (!sameComponent || !toolTipText.equals(newToolTipText) || !sameLoc) // Line 478
   This bug ([JDK-6219960]( has been fixed
in newer version of the JDK by switching to
   Objects.equals(toolTipText, newToolTipText)
   but this was never backported to JDK 8.
   ## How Has This Been Tested?
   Returning `""` has the same semantics as returning `null` and will result in no tooltip
being shown.
   ## Types of changes
   - Bug fix (non-breaking change which fixes an issue)
   ## Checklist:
   <!--- Go over all the following points, and put an `x` in all the boxes that apply.
   <!--- If you're unsure about any of these, don't hesitate to ask. We're here to help!
   - [x] My code follows the [code style][style-guide] of this project.

This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:

View raw message