Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

6286501: JTabbedPane throws NPE from its stateChanged listener in particular case #10216

Closed
wants to merge 1 commit into from

Conversation

prsadhuk
Copy link
Contributor

@prsadhuk prsadhuk commented Sep 8, 2022

JTabbedPane throws NPE from its stateChanged listener as it tries to access uninstantiated TabbedPane.
Fix is to use the tabPane passed to stateChangeListener so that correct tabPane is accessed.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-6286501: JTabbedPane throws NPE from its stateChanged listener in particular case

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk pull/10216/head:pull/10216
$ git checkout pull/10216

Update a local copy of the PR:
$ git checkout pull/10216
$ git pull https://git.openjdk.org/jdk pull/10216/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 10216

View PR using the GUI difftool:
$ git pr show -t 10216

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/10216.diff

@bridgekeeper
Copy link

bridgekeeper bot commented Sep 8, 2022

👋 Welcome back psadhukhan! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot added the rfr Pull request is ready for review label Sep 8, 2022
@openjdk
Copy link

openjdk bot commented Sep 8, 2022

@prsadhuk The following label will be automatically applied to this pull request:

  • client

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the client client-libs-dev@openjdk.org label Sep 8, 2022
@mlbridge
Copy link

mlbridge bot commented Sep 8, 2022

Webrevs

@@ -4099,7 +4099,7 @@ public void stateChanged(ChangeEvent e) {

setFocusIndex(tabPane.getSelectedIndex(), false);

if (scrollableTabLayoutEnabled()) {
if (tabPane.getLayout() instanceof TabbedPaneScrollLayout) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see BasicTabbedPaneUI.tabPane object getting used in other listeners in this Handler class. Is there a reason why only when we hit stateChanged() function we are seeing NPE?

Is this NPE for tabPane object itself or Layout not being initialized?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically, when a tab index is selected via tbp.setSelectedIndex() in testcase, it fires a state change event (via DefaultSingleSelectionModel#setSelectedIndex) which is caught by the application and in this case, state change listener in the testcase calls JTabbedPane.updateUI() which calls JComponent.setUI() which first uninstalls UI (which made tabPane null in BasicTabbedPaneUI#uninstallUI) and then install new UI instance but when it goes to JDK's stateChange listener BasicTabbedPaneUI.stateChanged() it passes the new instance but scrollableTabLayoutEnabled() still uses old UI instance in which tabPane is already made null so NPE happens, so it is better to use the tabPane instance passed to UI's stateChange listener..

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we install new UI instance will we not call BasicTabbedPaneUI.installUI() to update current tabPane object? or is it happening at later stage(like after BasicTabbedPaneUI.stateChanged() is called)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

installUI is called for new UI instance with current tabpane object but scrollableTabLayoutEnabled was using the old UI instance whose tabpane object is already reset to null.

@openjdk
Copy link

openjdk bot commented Sep 16, 2022

@prsadhuk This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

6286501: JTabbedPane throws NPE from its stateChanged listener in particular case

Reviewed-by: jdv

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 173 new commits pushed to the master branch:

  • 3beca2d: 8291600: [vectorapi] vector cast op check is not always needed for vector mask cast
  • 9a40b76: 8293842: IPv6-only systems throws UnsupportedOperationException for several socket/TCP options
  • bb9aa4e: 8293813: ProblemList com/sun/jdi/JdbLastErrorTest.java on windows-x64 in Xcomp mode
  • 4cec141: 8291509: Minor cleanup could be done in sun.security
  • 6beeb84: 8293875: ProblemList sun/management/jmxremote/bootstrap/RmiBootstrapTest.java#id1 on linux-x64
  • bf79f99: 8292989: Avoid dynamic memory in AsyncLogWriter
  • 2028ec7: 8289608: Change com/sun/jdi tests to not use Thread.suspend/resume
  • ecb456a: 8293779: redundant checking in AESCrypt.makeSessionKey() method
  • 6fca9ae: 8288474: Move EventContinuationFreezeOld from try_freeze_fast to freeze_slow
  • fbd8b42: 8293591: Remove use of Thread.stop from jshell tests
  • ... and 163 more: https://git.openjdk.org/jdk/compare/bd674dc55e87940f442cb140841f95424b6d42fd...master

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Sep 16, 2022
@prsadhuk
Copy link
Contributor Author

/integrate

@openjdk
Copy link

openjdk bot commented Sep 19, 2022

Going to push as commit ab7f58a.
Since your change was applied there have been 199 commits pushed to the master branch:

  • d41f69f: 8293849: PrintIdealPhase in compiler directives file is ignored when used with other compile commands
  • 471e2f1: 8292088: C2: assert(is_OuterStripMinedLoop()) failed: invalid node class: IfTrue
  • a93cf92: 8293920: G1: Add index based heap region iteration
  • 36c9034: 8293808: mscapi destroyKeyContainer enhance KeyStoreException: Access is denied exception
  • cbd0688: 8293851: hs_err should print more stack in hex dump
  • 04d7b7d: 8293503: gc/metaspace/TestMetaspacePerfCounters.java#Epsilon-64 failed assertGreaterThanOrEqual: expected MMM >= NNN
  • d77c464: 8293891: gc/g1/mixedgc/TestOldGenCollectionUsage.java (still) assumes that GCs take 1ms minimum
  • d7c1a76: 8293861: G1: Disable preventive GCs by default
  • 43f7f47: 8293499: Provide jmod --compress option
  • 26e08cf: 8293844: C2: Verify Location::{oop,normal} types in PhaseOutput::FillLocArray
  • ... and 189 more: https://git.openjdk.org/jdk/compare/bd674dc55e87940f442cb140841f95424b6d42fd...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Sep 19, 2022
@openjdk openjdk bot closed this Sep 19, 2022
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Sep 19, 2022
@openjdk
Copy link

openjdk bot commented Sep 19, 2022

@prsadhuk Pushed as commit ab7f58a.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client client-libs-dev@openjdk.org integrated Pull request has been integrated
2 participants