JDK-8164096 : ListChangeListener on ReadOnlyListWrapper's getReadOnlyProperty() does not reset change
  • Type: Bug
  • Component: javafx
  • Sub-Component: base
  • Affected Version: 8u74,9
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2016-08-12
  • Updated: 2020-01-31
  • Resolved: 2016-08-18
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8 JDK 9
8u152Fixed 9Fixed
Related Reports
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.8.0_92"
Java(TM) SE Runtime Environment (build 1.8.0_92-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.92-b14, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Linux host.mydomain.com 4.6.5-200.fc23.x86_64 #1 SMP Thu Jul 28 01:10:25 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux


A DESCRIPTION OF THE PROBLEM :
see attached source to reproduce

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
execute the attached code


EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
console output:

changelistener 1
handle change
changelistener 2
handle change
changelistener 1
handle change
changelistener 2
handle change

ACTUAL -
console output:

changelistener 1
handle change
changelistener 2
changelistener 1
handle change
changelistener 2

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import javafx.beans.property.ReadOnlyListWrapper;
import javafx.collections.FXCollections;
import javafx.collections.ListChangeListener;

public class TestListchangelistener2 {
	private final ReadOnlyListWrapper<String> list = new ReadOnlyListWrapper<>(FXCollections.observableArrayList());

	public TestListchangelistener2() {
		list.addListener((ListChangeListener<String>) c -> {
			System.err.println("changelistener 1");
			while (c.next()) {
				System.err.println("handle change");
			}
		});
		list.getReadOnlyProperty().addListener((ListChangeListener<String>) c -> {
			System.err.println("changelistener 2");
			//c.reset(); // workaround
			while (c.next()) {
				System.err.println("handle change");
			}
		});
		list.add("bla");
		list.addAll("bli");
	}

	public static void main(String[] args) {
		new TestListchangelistener2();
	}
}

---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
call change.reset() 
(see commented line in test case)


Comments
Checked this on Windows 7 and could confirm the issue as reported by the bug submitter. Steps to reporudce: ************************* - Run the attached test application(TestListchangelistener2.java) with JDK. Result: ********* OS : Windows 7 64 bit JDK: 8u b132 : Pass 8u40 : Pass 8u45 : Pass 8u51 : Pass 8u60 : Pass 8u66 : Pass 8u71 : Pass 8u73 : Pass => 8u74 : Fail <= Introduced version 8u101 b13 : Fail 8u102 b14 : Fail 9ea+126 : Fail ================================================================================================================ Output: ********** till 8u73: ########### changelistener 1 handle change changelistener 2 handle change changelistener 1 handle change changelistener 2 handle change -------------------- From 8u74 onwards ################# changelistener 1 handle change changelistener 2 changelistener 1 handle change changelistener 2
23-09-2016

Approved to backport to 8u-dev for 8u122.
18-08-2016

Test imports needed adjustments, other than that, applied cleanly. Webrev for convenience: http://cr.openjdk.java.net/~vadim/8164096/webrev.8u/
18-08-2016

Since this is a regression introduced in an 8u release (8u74) we should backport the fix to 8u. Does the patch apply cleanly (after adjusting the location of the files)? If not, please provide an 8u version of the webrev.
18-08-2016

Changeset: 4c3d5c3cbf49 Author: vadim Date: 2016-08-18 13:00 +0300 URL: http://hg.openjdk.java.net/openjfx/9-dev/rt/rev/4c3d5c3cbf49
18-08-2016

+1
17-08-2016

Chien, please review this fix: http://cr.openjdk.java.net/~vadim/8164096/webrev.00/
17-08-2016