Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvladt2011-01-27 21:01:38 +0000
committervladt2011-01-27 21:02:34 +0000
commit14f8562fe514ea4dde8a8a1c80868abedf2df3bc (patch)
tree2507f76719a5b0959246c9314c02f1df6df194b7
parent263ff23310e5e34df300568530444264def13b69 (diff)
downloadm2e-core-14f8562fe514ea4dde8a8a1c80868abedf2df3bc.tar.gz
m2e-core-14f8562fe514ea4dde8a8a1c80868abedf2df3bc.tar.xz
m2e-core-14f8562fe514ea4dde8a8a1c80868abedf2df3bc.zip
335595 - The download sources/javadocs task ignores cancelation
-rw-r--r--org.eclipse.m2e.jdt/META-INF/MANIFEST.MF3
-rw-r--r--org.eclipse.m2e.jdt/src/org/eclipse/m2e/jdt/DownloadSourcesJob.java17
-rw-r--r--org.eclipse.m2e.tests.common/src/org/eclipse/m2e/tests/common/JobHelpers.java3
3 files changed, 19 insertions, 4 deletions
diff --git a/org.eclipse.m2e.jdt/META-INF/MANIFEST.MF b/org.eclipse.m2e.jdt/META-INF/MANIFEST.MF
index c3c66e14..b68afc8b 100644
--- a/org.eclipse.m2e.jdt/META-INF/MANIFEST.MF
+++ b/org.eclipse.m2e.jdt/META-INF/MANIFEST.MF
@@ -22,7 +22,8 @@ Require-Bundle: org.eclipse.core.resources,
org.eclipse.m2e.maven.runtime;bundle-version="[0.13.0,0.14.0)",
org.eclipse.m2e.model.edit;bundle-version="[0.13.0,0.14.0)",
org.eclipse.m2e.core;bundle-version="[0.13.0,0.14.0)",
- org.eclipse.ui.console
+ org.eclipse.ui.console,
+ org.slf4j.api;bundle-version="1.5.11"
Eclipse-LazyStart: true
Bundle-Activator: org.eclipse.m2e.jdt.MavenJdtPlugin
Bundle-RequiredExecutionEnvironment: J2SE-1.5,
diff --git a/org.eclipse.m2e.jdt/src/org/eclipse/m2e/jdt/DownloadSourcesJob.java b/org.eclipse.m2e.jdt/src/org/eclipse/m2e/jdt/DownloadSourcesJob.java
index 737fd9bb..c121cdad 100644
--- a/org.eclipse.m2e.jdt/src/org/eclipse/m2e/jdt/DownloadSourcesJob.java
+++ b/org.eclipse.m2e.jdt/src/org/eclipse/m2e/jdt/DownloadSourcesJob.java
@@ -19,12 +19,16 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.ISchedulingRule;
import org.eclipse.core.runtime.jobs.Job;
@@ -51,6 +55,8 @@ import org.eclipse.m2e.jdt.internal.Messages;
* @author igor
*/
class DownloadSourcesJob extends Job implements IBackgroundProcessingQueue {
+ private static Logger log = LoggerFactory.getLogger(DownloadSourcesJob.class);
+ private static final long SCHEDULE_INTERVAL = 1000L;
private static class DownloadRequest {
final IProject project;
@@ -193,7 +199,14 @@ class DownloadSourcesJob extends Job implements IBackgroundProcessingQueue {
private File[] downloadAttachments(ArtifactKey artifact, List<ArtifactRepository> repositories, boolean downloadSources,
boolean downloadJavadoc, IProgressMonitor monitor) throws CoreException {
-
+ if(monitor != null && monitor.isCanceled()) {
+ String message = "Downloading of sources/javadocs was canceled"; //$NON-NLS-1$
+ log.debug(message);
+ synchronized(queue) {
+ queue.clear();
+ }
+ throw new OperationCanceledException(message);
+ }
ArtifactKey[] attached = manager.getAttachedSourcesAndJavadoc(artifact, repositories, downloadSources, downloadJavadoc);
File[] files = new File[2];
@@ -244,7 +257,7 @@ class DownloadSourcesJob extends Job implements IBackgroundProcessingQueue {
queue.add(new DownloadRequest(project, fragment, artifact, downloadSources, downloadJavadoc));
}
- schedule(1000L);
+ schedule(SCHEDULE_INTERVAL);
}
/**
diff --git a/org.eclipse.m2e.tests.common/src/org/eclipse/m2e/tests/common/JobHelpers.java b/org.eclipse.m2e.tests.common/src/org/eclipse/m2e/tests/common/JobHelpers.java
index 57fe3f6e..a115ba7a 100644
--- a/org.eclipse.m2e.tests.common/src/org/eclipse/m2e/tests/common/JobHelpers.java
+++ b/org.eclipse.m2e.tests.common/src/org/eclipse/m2e/tests/common/JobHelpers.java
@@ -76,8 +76,9 @@ public class JobHelpers {
// Now we flush all background processing queues
boolean processed = flushProcessingQueues(jobManager, monitor);
- for (int i = 0; i < 10 && processed; i++) {
+ for(int i = 0; i < 10 && processed; i++ ) {
processed = flushProcessingQueues(jobManager, monitor);
+ Thread.sleep(10);
}
Assert.assertFalse("Could not flush background processing queues: " + getProcessingQueues(jobManager), processed);

Back to the top