Skip to content

Commit

Permalink
Wait to ask to collect anonymous statistics in JabRefExecutorService …
Browse files Browse the repository at this point in the history
…to allow jvm to terminate (#3266)

* use JabRefExecutorService for TrackingNotification instead of a new ExecutorService

* add changelog entry
  • Loading branch information
125m125 authored and tobiasdiez committed Oct 6, 2017
1 parent effe334 commit 7ef2b3a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -16,6 +16,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
- We added support for '[entrytype]' bracketed expression.

### Fixed
- We fixed an issue where JabRef would not terminated after asking to collect anonymous statistics [#2955 comment](https://github.com/JabRef/jabref/issues/2955#issuecomment-334591123)

### Removed

Expand Down
14 changes: 9 additions & 5 deletions src/main/java/org/jabref/gui/JabRefFrame.java
Expand Up @@ -30,9 +30,7 @@
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.TimerTask;

import javax.swing.AbstractAction;
import javax.swing.Action;
Expand Down Expand Up @@ -64,6 +62,7 @@
import javafx.application.Platform;

import org.jabref.Globals;
import org.jabref.JabRefExecutorService;
import org.jabref.gui.actions.Actions;
import org.jabref.gui.actions.AutoLinkFilesAction;
import org.jabref.gui.actions.ConnectToSharedDatabaseAction;
Expand Down Expand Up @@ -661,8 +660,13 @@ public void windowClosing(WindowEvent e) {

private void initShowTrackingNotification() {
if (!Globals.prefs.shouldAskToCollectTelemetry()) {
ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor();
scheduler.schedule(() -> DefaultTaskExecutor.runInJavaFXThread(this::showTrackingNotification), 1, TimeUnit.MINUTES);
JabRefExecutorService.INSTANCE.submit(new TimerTask() {

@Override
public void run() {
DefaultTaskExecutor.runInJavaFXThread(JabRefFrame.this::showTrackingNotification);
}
}, 60000); // run in one minute
}
}

Expand Down

0 comments on commit 7ef2b3a

Please sign in to comment.