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

Fixed failing tests caused by concurrency issues #101

Merged
merged 1 commit into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ public boolean matches(Person item) {
assertFalse(this.dataChangeLayer.getDataChanges().isEmpty());
assertFalse(this.dataChangeLayer.isColumnDirty(1), "Column 1 is dirty");

// short sleep to avoid handling the next step in the previous
// processing
Thread.sleep(100);

countDownLatch = new CountDownLatch(1);
this.listenerFixture.setCountDownLatch(countDownLatch);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,10 @@ public void shouldKeepChangeOnFilter() throws InterruptedException {
assertFalse(this.dataChangeLayer.getDataChanges().isEmpty());
assertFalse(this.dataChangeLayer.isColumnDirty(1), "Column 1 is dirty");

// short sleep to avoid handling the next step in the previous
// processing
Thread.sleep(100);

countDownLatch = new CountDownLatch(1);
this.listenerFixture.setCountDownLatch(countDownLatch);
this.filterList.setMatcher(null);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2012, 2023 Original authors and others.
* Copyright (c) 2012, 2024 Original authors and others.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -58,7 +58,7 @@ public class GlazedListsEventLayer<T>
private EventList<T> eventList;
private boolean testMode = false;
private boolean structuralChangeEventsToProcess = false;
private boolean eventsToProcess = false;
private AtomicBoolean eventsToProcess = new AtomicBoolean(false);
private AtomicBoolean terminated = new AtomicBoolean(false);

private boolean active = true;
Expand All @@ -81,7 +81,7 @@ public GlazedListsEventLayer(IUniqueIndexLayer underlyingLayer, EventList<T> eve
*/
protected Runnable getEventNotifier() {
return () -> {
if (GlazedListsEventLayer.this.eventsToProcess && GlazedListsEventLayer.this.active) {
if (GlazedListsEventLayer.this.active && GlazedListsEventLayer.this.eventsToProcess.compareAndSet(true, false)) {
ILayerEvent layerEvent;
if (GlazedListsEventLayer.this.structuralChangeEventsToProcess) {
layerEvent = new RowStructuralRefreshEvent(getUnderlyingLayer());
Expand All @@ -90,7 +90,6 @@ protected Runnable getEventNotifier() {
}
fireEventFromSWTDisplayThread(layerEvent);

GlazedListsEventLayer.this.eventsToProcess = false;
GlazedListsEventLayer.this.structuralChangeEventsToProcess = false;
}
};
Expand All @@ -106,7 +105,7 @@ public void listChanged(ListEvent<T> event) {
this.structuralChangeEventsToProcess = true;
}
}
this.eventsToProcess = true;
this.eventsToProcess.set(true);
}

// PropertyChangeListener
Expand Down Expand Up @@ -232,7 +231,7 @@ public boolean isActive() {
* @since 1.6
*/
public void discardEventsToProcess() {
this.eventsToProcess = false;
this.eventsToProcess.set(false);
this.structuralChangeEventsToProcess = false;
}

Expand Down