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

8258777: SkinBase: add api to un-/register invalidation-/listChange listeners #409

Closed
wants to merge 10 commits into from

Conversation

kleopatra
Copy link
Collaborator

@kleopatra kleopatra commented Feb 22, 2021

Changes in Lambda..Handler:

  • added api and implemenation to support invalidation and listChange listeners in the same way as changeListeners
  • added java doc
  • added tests

Changes in SkinBase

  • added api (and implementation delegating to the handler)
  • copied java doc from the change listener un/register methods
  • added tests to verify that the new (and old) api is indeed delegating to the handler

Note that the null handling is slightly extended: all methods now can handle both null consumers (as before) and null observables (new) - this allows simplified code on rewiring "path" properties (see reference example in the issue)


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

  • JDK-8258777: SkinBase: add api to un-/register invalidation-/listChange listeners

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jfx pull/409/head:pull/409
$ git checkout pull/409

Update a local copy of the PR:
$ git checkout pull/409
$ git pull https://git.openjdk.java.net/jfx pull/409/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 409

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jfx/pull/409.diff

@bridgekeeper
Copy link

bridgekeeper bot commented Feb 22, 2021

👋 Welcome back fastegal! 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 Ready for review label Feb 22, 2021
@mlbridge
Copy link

mlbridge bot commented Feb 22, 2021

@kevinrushforth
Copy link
Member

/reviewers 2
/csr

@openjdk
Copy link

openjdk bot commented Feb 22, 2021

@kevinrushforth
The number of required reviews for this PR is now set to 2 (with at least 1 of role reviewers).

@openjdk openjdk bot added the csr Need approved CSR to integrate pull request label Feb 22, 2021
@openjdk
Copy link

openjdk bot commented Feb 22, 2021

@kevinrushforth has indicated that a compatibility and specification (CSR) request is needed for this pull request.
@kleopatra please create a CSR request and add link to it in JDK-8258777. This pull request cannot be integrated until the CSR request is approved.

Copy link
Member

@kevinrushforth kevinrushforth left a comment

Choose a reason for hiding this comment

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

Not yet reviewed. All of the new API methods need to have an @since 17 javadoc tag.

@kleopatra
Copy link
Collaborator Author

wondering about the sequence of next steps: should I create the csr before or after (partial) review of this? Doing before feels like expecting duplicate work (whenever doc changes are required, I'll have to change the code in the pr and the csr draft as well, I assume). If that's the way, I'll go it, naturally :)

@kevinrushforth
Copy link
Member

I'll review the API changes in the next day or so. Then you can update the CSR and move to Proposed. I'll also ask Ambarish to be the second reviewer on this.

@kevinrushforth
Copy link
Member

The API looks good to me, so go ahead and create a Draft CSR (go to your JBS issue and select "More --> Create CSR"). I don't think it will change much, if any, so you won't be duplicating work. Since you are adding new methods to an existing class, you can use the format from JDK-8259868 for the Specification section, just listing the new methods and their API docs, rather than diffs, which would be needed if changing existing javadoc comments.

Copy link
Collaborator

@nlisker nlisker left a comment

Choose a reason for hiding this comment

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

I reviewed only the public API methods.

* @param observable The observable for which all listeners should be removed.
* @return A single chained {@link Consumer} consisting of all {@link Consumer consumers} registered through
* {@link #registerInvalidationListener(Observable, Consumer)}. If no consumers have been registered on this
* property, null will be returned.
Copy link
Collaborator

Choose a reason for hiding this comment

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

"null" --> {@code null}

"property" --> "observable"

@kleopatra
Copy link
Collaborator Author

@nlisker thanks for the detailed doc review - I really like your suggestions, which I think are considerable improvements (I did part of it in the respective methods of the handler) over the original doc :) Because that's what the doc of the new methods are: c&p from the un/registerChangeListener javadoc, adjusted to the specific type of the listener.

For consistency, all related method doc should be improved along your lines. How to get there? Options

  • use old doc with new methods, leave improving the doc for all methods to a follow-up issue
  • keep old doc for old method, use improved doc for the new methods, leave improving the doc for the old method to a follow-up issue
  • use improved doc in old and new methods in this issue, changing the old

Last would be doing it right once and for all .. my reluctant (against my lazy self ;) preference would be the last.

@nlisker
Copy link
Collaborator

nlisker commented Mar 25, 2021

Can you list the other affected methods?

@kleopatra
Copy link
Collaborator Author

Can you list the other affected methods?

at line 211 (in the changed skinBase)

/**
     * Subclasses can invoke this method to register that they want to listen to
     * property change events for the given property. Registered {@link Consumer} instances
     * will be executed in the order in which they are registered.
     * @param property the property
     * @param consumer the consumer
     */
    protected final void registerChangeListener(ObservableValue<?> property, Consumer<ObservableValue<?>> consumer) {


and at line 255

/**
     * Unregisters all change listeners that have been registered using {@link #registerChangeListener(ObservableValue, Consumer)}
     * for the given property. The end result is that the given property is no longer observed by any of the change
     * listeners, but it may still have additional listeners registered on it through means outside of
     * {@link #registerChangeListener(ObservableValue, Consumer)}.
     *
     * @param property The property for which all listeners should be removed.
     * @return A single chained {@link Consumer} consisting of all {@link Consumer consumers} registered through
     *      {@link #registerChangeListener(ObservableValue, Consumer)}. If no consumers have been registered on this
     *      property, null will be returned.
     * @since 9
     */
    protected final Consumer<ObservableValue<?>> unregisterChangeListeners(ObservableValue<?> property) {


@nlisker
Copy link
Collaborator

nlisker commented Mar 25, 2021

I see. I recommend that they be improved in this PR. I don't know if this will need to be part of the CSR, though.

@kevinrushforth
Copy link
Member

Making this change seems fine to me, and better than using different language in the new methods without fixing the existing.

I don't know if this will need to be part of the CSR, though.

It would be best to include them.

@kleopatra
Copy link
Collaborator Author

kleopatra commented Mar 25, 2021

@nlisker and @kevin so we agree, thanks :)

my plan:

  • will work on the exact doc along the lines of Nir's suggestion for the un-/registerInvalidationListener methods
  • once that's basically agreed upon, will c&p the spec (with adjustments) to the methods for the other listener types
  • at a last step, create the csr draft (that would be a patch for the changeListener methods and simply added spec for the new methods, I assume?)

@openjdk openjdk bot removed the rfr Ready for review label Mar 29, 2021
@openjdk openjdk bot added the rfr Ready for review label Mar 29, 2021
@kleopatra
Copy link
Collaborator Author

hmm ... failing checks, why?

@kevinrushforth
Copy link
Member

hmm ... failing checks, why?

The failure on Windows is because your branch isn't up-to-date with master, and is missing a recent fix to the Window build. You can either git merge master (after updating your master branch from the upstream repo) or ignore the error.

@nlisker
Copy link
Collaborator

nlisker commented Mar 30, 2021

I think that the docs are ready for the CSR now.

Copy link
Member

@kevinrushforth kevinrushforth left a comment

Choose a reason for hiding this comment

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

One comment on the API that should be resolved before submitting the CSR.

@kevinrushforth kevinrushforth self-requested a review April 9, 2021 16:08
@kleopatra
Copy link
Collaborator Author

kleopatra commented Apr 12, 2021

created a csr draft JDK-8265063 - waiting for all monsters in hell breaking out and heavens falling down ;-)

@kevinrushforth
Copy link
Member

created a csr draft JDK-8265063 - waiting for all monsters in hell breaking out and heavens falling down ;-)

The Draft CSR looks good, and should keep the monsters contained. 😄 Go ahead and move it to Proposed.

@nlisker
Copy link
Collaborator

nlisker commented Apr 12, 2021

I looked at all the new public docs and they look good (I left one minor comment). I didn't review anything else.

@kleopatra
Copy link
Collaborator Author

The Draft CSR looks good, and should keep the monsters contained. 😄 Go ahead and move it to Proposed.

thanks, done :) Also updated to the most recent state (including Nir's suggestion).

Copy link
Member

@kevinrushforth kevinrushforth left a comment

Choose a reason for hiding this comment

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

I finished reviewing the API changes, and it all looks good. I noted a follow-up bug that I need to file.

I'll review the CSR (to make sure it matches exactly the latest API docs in the code) in parallel with reviewing the implementation.

@kevinrushforth
Copy link
Member

I filed JDK-8265277 to add the missing @since 9 javadoc tag.

Copy link
Member

@kevinrushforth kevinrushforth left a comment

Choose a reason for hiding this comment

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

The fix and tests looks good, with one suggestion for the test (and a couple minor comments about formatting and one naming question) left inline.

I'll review the CSR now, you can then move it to Finalized when you are ready.


@SuppressWarnings("rawtypes")
private static final Consumer EMPTY_CONSUMER = e -> {};
Copy link
Member

Choose a reason for hiding this comment

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

Minor: remove extra space between public and static.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

removed

Consumer<Change<?>> consumer = change -> changes.add(change);
WeakReference<LambdaMultiplePropertyChangeListenerHandler> ref =
new WeakReference<>(new LambdaMultiplePropertyChangeListenerHandler());
ref.get().registerListChangeListener(items, consumer);
Copy link
Member

Choose a reason for hiding this comment

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

This is fragile. It is possible, although unlikely, that the referent could be GCed between its construction in the previous statement (after which it goes out of scope), and this statement. If this rare event happened, it would cause an NPE here. I recommend to keep a local reference to the referent and then set it to null after this (and before the attemptGC).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

changed as suggested. I used a similar pattern in BehaviorMemoryTest - should I file a testbug to change it in the same way?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, please file a new bug (not high priority, since it is a corner case). I took a look and there are a few other controls tests that use this pattern as well (BehaviorCleanupTest, ListViewTest, TabPaneTest, SkinCleanupTest, SkinLabeledCleanupTest, SkinMemoryLeakTest), so the new bug could cover fixing this for all of them.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done and taken (should cleanup my own dirt ;) JDK-8265406

Copy link
Member

@kevinrushforth kevinrushforth left a comment

Choose a reason for hiding this comment

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

Looks good.

@openjdk openjdk bot removed the csr Need approved CSR to integrate pull request label Apr 17, 2021
@kevinrushforth
Copy link
Member

Pending a second reviewer.

arapte
arapte approved these changes Apr 28, 2021
@openjdk
Copy link

openjdk bot commented Apr 28, 2021

@kleopatra 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:

8258777: SkinBase: add api to un-/register invalidation-/listChange listeners

Reviewed-by: kcr, arapte

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 57 new commits pushed to the master branch:

  • 33bbf3f: 8263402: MemoryLeak: Node hardreferences it's previous Parent after csslayout and getting removed from the scene
  • 483f171: 8264677: MemoryLeak: Progressindicator leaks, when treeShowing is false
  • 6b63bf5: 8265669: AccumCell should not be visible
  • ed080c8: 8262276: Debug build of WebKit fails
  • db30e71: 8265513: Openjfx graphics build broken (Eclipse)
  • b50ce94: 8264952: [TestBug] Controls unit tests - ControlTest and SpinnerTest fail for non US Locale
  • 27e57d3: 8265469: Allow to build media and webkit for Linux-AArch64
  • dfda00d: 8265514: Openjfx controls running tests broken (Eclipse)
  • 1b407cc: 8239880: CSS tests should cleanup any global state they modify
  • fab638a: 8265425: Hard failure when building OpenJFX for Linux AArch64
  • ... and 47 more: https://git.openjdk.java.net/jfx/compare/9e42eea46d735f80235effdebb535ee66b59f7d1...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 Ready to be integrated label Apr 28, 2021
@kleopatra
Copy link
Collaborator Author

/integrate

@openjdk openjdk bot closed this Apr 28, 2021
@openjdk openjdk bot added integrated Pull request has been integrated and removed ready Ready to be integrated rfr Ready for review labels Apr 28, 2021
@openjdk
Copy link

openjdk bot commented Apr 28, 2021

@kleopatra Since your change was applied there have been 57 commits pushed to the master branch:

  • 33bbf3f: 8263402: MemoryLeak: Node hardreferences it's previous Parent after csslayout and getting removed from the scene
  • 483f171: 8264677: MemoryLeak: Progressindicator leaks, when treeShowing is false
  • 6b63bf5: 8265669: AccumCell should not be visible
  • ed080c8: 8262276: Debug build of WebKit fails
  • db30e71: 8265513: Openjfx graphics build broken (Eclipse)
  • b50ce94: 8264952: [TestBug] Controls unit tests - ControlTest and SpinnerTest fail for non US Locale
  • 27e57d3: 8265469: Allow to build media and webkit for Linux-AArch64
  • dfda00d: 8265514: Openjfx controls running tests broken (Eclipse)
  • 1b407cc: 8239880: CSS tests should cleanup any global state they modify
  • fab638a: 8265425: Hard failure when building OpenJFX for Linux AArch64
  • ... and 47 more: https://git.openjdk.java.net/jfx/compare/9e42eea46d735f80235effdebb535ee66b59f7d1...master

Your commit was automatically rebased without conflicts.

Pushed as commit cc70cdf.

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

@kleopatra kleopatra deleted the bug-fix-8258777 branch April 28, 2021 11:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integrated Pull request has been integrated
4 participants