Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDawid Pakuła2019-11-30 12:24:46 -0500
committerDawid Pakuła2019-11-30 13:24:16 -0500
commit6de3e4f26e9afda04f14fe9aa2e1f36701e0eb62 (patch)
treef42b4b501d375ebac02b615ec8c106b366f38c5d
parentba9d7554996ca32595f148c37bf87f003cde025a (diff)
downloadorg.eclipse.pdt-6de3e4f26e9afda04f14fe9aa2e1f36701e0eb62.tar.gz
org.eclipse.pdt-6de3e4f26e9afda04f14fe9aa2e1f36701e0eb62.tar.xz
org.eclipse.pdt-6de3e4f26e9afda04f14fe9aa2e1f36701e0eb62.zip
Bug 530722 - ConcurrentModificationException below PHPUnitElementTreeContentProvider.get
Change-Id: I60e4a572e068332567635ad5866775dcaf731a07 Signed-off-by: Dawid Pakuła <zulus@w3des.net>
-rw-r--r--plugins/org.eclipse.php.phpunit/src/org/eclipse/php/phpunit/model/connection/PHPUnitMessageParser.java85
-rw-r--r--plugins/org.eclipse.php.phpunit/src/org/eclipse/php/phpunit/model/elements/PHPUnitTestGroup.java1
-rw-r--r--plugins/org.eclipse.php.phpunit/src/org/eclipse/php/phpunit/ui/view/PHPUnitView.java52
-rw-r--r--plugins/org.eclipse.php.phpunit/src/org/eclipse/php/phpunit/ui/view/TestViewer.java1
4 files changed, 101 insertions, 38 deletions
diff --git a/plugins/org.eclipse.php.phpunit/src/org/eclipse/php/phpunit/model/connection/PHPUnitMessageParser.java b/plugins/org.eclipse.php.phpunit/src/org/eclipse/php/phpunit/model/connection/PHPUnitMessageParser.java
index 24e104589..326f715a5 100644
--- a/plugins/org.eclipse.php.phpunit/src/org/eclipse/php/phpunit/model/connection/PHPUnitMessageParser.java
+++ b/plugins/org.eclipse.php.phpunit/src/org/eclipse/php/phpunit/model/connection/PHPUnitMessageParser.java
@@ -15,14 +15,20 @@ package org.eclipse.php.phpunit.model.connection;
import java.util.ArrayList;
import java.util.Map;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.ISchedulingRule;
+import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.debug.core.model.IDebugTarget;
import org.eclipse.php.internal.debug.core.zend.debugger.RemoteDebugger;
import org.eclipse.php.internal.debug.core.zend.model.PHPDebugTarget;
import org.eclipse.php.phpunit.model.elements.*;
import org.eclipse.php.phpunit.ui.view.PHPUnitView;
import org.eclipse.php.phpunit.ui.view.TestViewer;
+import org.eclipse.swt.widgets.Display;
-public class PHPUnitMessageParser {
+public class PHPUnitMessageParser implements ISchedulingRule {
public static final String CALL_DYNAMIC = "->"; //$NON-NLS-1$
@@ -48,38 +54,63 @@ public class PHPUnitMessageParser {
private PHPUnitTestGroup currentGroup;
private PHPUnitTestCase currentTestCase;
private boolean inProgress = false;
+ private RefreshJob refreshJob = new RefreshJob(this);
+
+ private class RefreshJob extends Job {
+
+ public RefreshJob(PHPUnitMessageParser phpUnitMessageParser) {
+ super("Refresh PHPUnitView"); //$NON-NLS-1$
+ setRule(phpUnitMessageParser);
+ setSystem(true);
+ }
+
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+
+ Display.getDefault().syncExec(() -> {
+ PHPUnitView.getDefault().refresh(PHPUnitElementManager.getInstance().getRoot());
+ });
+
+ return Status.OK_STATUS;
+ }
+
+ }
public PHPUnitMessageParser() {
}
public void parseMessage(Message message, final TestViewer viewer) {
- if (!isInProgress()) {
- setInProgress(true);
- }
if (message == null) {
return;
}
-
- final String target = message.getTarget();
- final MessageEventType event = message.getEvent();
- if (target.equals(ELEMENT_TARGET_TESTSUITE)) {
- if (event == MessageEventType.start) {
- parseGroupStart(viewer, message);
- } else if (event == MessageEventType.end) {
- parseGroupEnd(viewer, message);
- } else {
- currentGroup.setStatus(event);
- currentGroup.addRunCount(1);
+ try {
+ Job.getJobManager().beginRule(this, null);
+ if (!isInProgress()) {
+ setInProgress(true);
}
- } else if (target.equals(ELEMENT_TARGET_TESTCASE)) {
- if (event == MessageEventType.start) {
- parseTestStart(viewer, message);
- } else {
- parseTestEnd(viewer, message);
+ final String target = message.getTarget();
+ final MessageEventType event = message.getEvent();
+ if (target.equals(ELEMENT_TARGET_TESTSUITE)) {
+ if (event == MessageEventType.start) {
+ parseGroupStart(viewer, message);
+ } else if (event == MessageEventType.end) {
+ parseGroupEnd(viewer, message);
+ } else {
+ currentGroup.setStatus(event);
+ currentGroup.addRunCount(1);
+ }
+ } else if (target.equals(ELEMENT_TARGET_TESTCASE)) {
+ if (event == MessageEventType.start) {
+ parseTestStart(viewer, message);
+ } else {
+ parseTestEnd(viewer, message);
+ }
}
- }
+ refreshJob.schedule(50);
+ } finally {
+ Job.getJobManager().endRule(this);
- PHPUnitView.getDefault().refresh(PHPUnitElementManager.getInstance().getRoot());
+ }
}
private void parseGroupStart(final TestViewer viewer, Message message) {
@@ -198,4 +229,14 @@ public class PHPUnitMessageParser {
public PHPUnitTestCase getCurrentTestCase() {
return currentTestCase;
}
+
+ @Override
+ public boolean contains(ISchedulingRule rule) {
+ return rule == this;
+ }
+
+ @Override
+ public boolean isConflicting(ISchedulingRule rule) {
+ return rule == this;
+ }
} \ No newline at end of file
diff --git a/plugins/org.eclipse.php.phpunit/src/org/eclipse/php/phpunit/model/elements/PHPUnitTestGroup.java b/plugins/org.eclipse.php.phpunit/src/org/eclipse/php/phpunit/model/elements/PHPUnitTestGroup.java
index 6053b6192..12fbea687 100644
--- a/plugins/org.eclipse.php.phpunit/src/org/eclipse/php/phpunit/model/elements/PHPUnitTestGroup.java
+++ b/plugins/org.eclipse.php.phpunit/src/org/eclipse/php/phpunit/model/elements/PHPUnitTestGroup.java
@@ -158,4 +158,5 @@ public class PHPUnitTestGroup extends PHPUnitTest {
}
return result;
}
+
} \ No newline at end of file
diff --git a/plugins/org.eclipse.php.phpunit/src/org/eclipse/php/phpunit/ui/view/PHPUnitView.java b/plugins/org.eclipse.php.phpunit/src/org/eclipse/php/phpunit/ui/view/PHPUnitView.java
index a385cf4a0..48269d2be 100644
--- a/plugins/org.eclipse.php.phpunit/src/org/eclipse/php/phpunit/ui/view/PHPUnitView.java
+++ b/plugins/org.eclipse.php.phpunit/src/org/eclipse/php/phpunit/ui/view/PHPUnitView.java
@@ -76,8 +76,8 @@ public class PHPUnitView extends ViewPart {
private static PHPUnitView instance = null;
- public static synchronized void activateView(final boolean focus) {
- PlatformUI.getWorkbench().getDisplay().syncExec(() -> {
+ public static void activateView(final boolean focus) {
+ Runnable uiTask = () -> {
final IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window != null) {
final IWorkbenchPage activePage = window.getActivePage();
@@ -85,21 +85,28 @@ public class PHPUnitView extends ViewPart {
return;
}
try {
- if (focus) {
- instance = (PHPUnitView) activePage.showView(NAME);
- } else {
- IViewPart foundView = activePage.findView(NAME);
- if (foundView != null) {
- instance = (PHPUnitView) foundView;
- } else {
+ synchronized (window) {
+ if (focus) {
instance = (PHPUnitView) activePage.showView(NAME);
+ } else {
+ IViewPart foundView = activePage.findView(NAME);
+ if (foundView != null) {
+ instance = (PHPUnitView) foundView;
+ } else {
+ instance = (PHPUnitView) activePage.showView(NAME);
+ }
}
}
} catch (final PartInitException e) {
PHPUnitPlugin.log(e);
}
}
- });
+ };
+ if (Display.getCurrent() != null) {
+ uiTask.run();
+ } else {
+ PlatformUI.getWorkbench().getDisplay().syncExec(uiTask);
+ }
}
public static PHPUnitView getDefault() {
@@ -241,12 +248,19 @@ public class PHPUnitView extends ViewPart {
}
public void refresh(final PHPUnitTestGroup root) {
- activateView(false);
+ if (getDefault() == null) {
+ return;
+ }
setInput(root);
- getSite().getShell().getDisplay().asyncExec(() -> {
+ Runnable uiTask = () -> {
final PHPUnitView view = getDefault();
view.processChangesInUI();
- });
+ };
+ if (Display.getCurrent() != null) {
+ uiTask.run();
+ } else {
+ getSite().getShell().getDisplay().asyncExec(uiTask);
+ }
}
public void refreshCounters() {
@@ -355,7 +369,7 @@ public class PHPUnitView extends ViewPart {
}
public void setCodeCoverageTabVisible(final boolean visible) {
- Display.getDefault().asyncExec(() -> {
+ Runnable uiTask = () -> {
if (!visible) {
if (codeCoverageTab != null && !codeCoverageTab.isDisposed()) {
codeCoverageTab.dispose();
@@ -363,7 +377,12 @@ public class PHPUnitView extends ViewPart {
} else if (codeCoverageTab == null || codeCoverageTab.isDisposed()) {
createCodeCoverageTab(bottomTabFolder);
}
- });
+ };
+ if (Display.getCurrent() != null) {
+ uiTask.run();
+ } else {
+ Display.getDefault().asyncExec(uiTask);
+ }
codeCoverageTabVisibile = visible;
}
@@ -632,7 +651,8 @@ public class PHPUnitView extends ViewPart {
*/
private ViewForm createCodeCoverageForm(final Composite parent) {
final ViewForm codeCoverageForm = new ViewForm(parent, SWT.NONE);
- fCodeCoverageSection = new CodeCoverageSection(codeCoverageForm, this, null /* codeCoverageToolBar */);
+ fCodeCoverageSection = new CodeCoverageSection(codeCoverageForm, this,
+ null /* codeCoverageToolBar */);
fCodeCoverageSection.addFilter(new ViewerFilter() {
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
diff --git a/plugins/org.eclipse.php.phpunit/src/org/eclipse/php/phpunit/ui/view/TestViewer.java b/plugins/org.eclipse.php.phpunit/src/org/eclipse/php/phpunit/ui/view/TestViewer.java
index 3b9a675bf..32b852683 100644
--- a/plugins/org.eclipse.php.phpunit/src/org/eclipse/php/phpunit/ui/view/TestViewer.java
+++ b/plugins/org.eclipse.php.phpunit/src/org/eclipse/php/phpunit/ui/view/TestViewer.java
@@ -552,4 +552,5 @@ public class TestViewer {
fTreeViewer.update(test, null); // if in tree: update
}
}
+
}

Back to the top