Skip to content

Commit 3dafb28

Browse files
committed
JBIDE-24412 - usage reporter prevents UI from initializing
1 parent 569f8bb commit 3dafb28

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/event/UsageReporter.java

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
package org.jboss.tools.usage.event;
1212

1313
import java.util.Set;
14+
import java.util.concurrent.CountDownLatch;
1415
import java.util.concurrent.locks.Lock;
1516
import java.util.concurrent.locks.ReentrantLock;
1617

@@ -353,21 +354,28 @@ private void askUser() {
353354
* @return the boolean
354355
*/
355356
protected Boolean askUserForEnablement() {
357+
final CountDownLatch latch = new CountDownLatch(1);
356358
final Boolean[] userResponse = new Boolean[1];
357-
Display.getDefault().syncExec(new Runnable() {
359+
Display.getDefault().asyncExec(new Runnable() {
358360
public void run() {
359-
Shell shell = PlatformUI.getWorkbench().getModalDialogShellProvider().getShell();
360-
UsageReportEnablementDialog dialog =
361-
new UsageReportEnablementDialog(
362-
shell,
363-
JBossToolsUsageActivator.getDefault().getUsageBranding());
364-
if (dialog.open() == Window.OK) {
365-
userResponse[0] = dialog.isReportEnabled();
366-
} else {
361+
try {
367362
userResponse[0] = false;
363+
Shell shell = PlatformUI.getWorkbench().getModalDialogShellProvider().getShell();
364+
UsageReportEnablementDialog dialog = new UsageReportEnablementDialog(
365+
shell, JBossToolsUsageActivator.getDefault().getUsageBranding());
366+
if (dialog.open() == Window.OK) {
367+
userResponse[0] = dialog.isReportEnabled();
368+
}
369+
} finally {
370+
latch.countDown();
368371
}
369372
}
370373
});
374+
try {
375+
latch.await(); // main thread is waiting on CountDownLatch to finish
376+
} catch (InterruptedException ie) {
377+
// Error already logged by the asyncExec
378+
}
371379
return userResponse[0];
372380
}
373381

0 commit comments

Comments
 (0)