Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsminto2005-07-26 15:33:19 +0000
committersminto2005-07-26 15:33:19 +0000
commit880ba1aeae0cd7b4f6660b0934559797b9ef7e45 (patch)
tree18eacbbf295e212a698f41ed7e8926e88ec7c3b9 /org.eclipse.mylyn.bugzilla.ui
parentcd31a8395db9c9467136b3cb092f7f6979d043ff (diff)
downloadorg.eclipse.mylyn.tasks-880ba1aeae0cd7b4f6660b0934559797b9ef7e45.tar.gz
org.eclipse.mylyn.tasks-880ba1aeae0cd7b4f6660b0934559797b9ef7e45.tar.xz
org.eclipse.mylyn.tasks-880ba1aeae0cd7b4f6660b0934559797b9ef7e45.zip
fixed Bug #104927: dozens of refresh jobs can hang
Diffstat (limited to 'org.eclipse.mylyn.bugzilla.ui')
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/BugzillaUiPlugin.java18
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/RefreshBugzillaAction.java9
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/RefreshBugzillaReportsAction.java13
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaRefreshManager.java65
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTask.java40
5 files changed, 109 insertions, 36 deletions
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/BugzillaUiPlugin.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/BugzillaUiPlugin.java
index aaa46d321..b7c70332c 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/BugzillaUiPlugin.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/BugzillaUiPlugin.java
@@ -1,12 +1,8 @@
package org.eclipse.mylar.bugzilla.ui;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.mylar.bugzilla.core.BugzillaPlugin;
-import org.eclipse.mylar.bugzilla.ui.tasklist.BugzillaTask;
+import org.eclipse.mylar.bugzilla.ui.tasklist.BugzillaRefreshManager;
import org.eclipse.mylar.bugzilla.ui.tasklist.BugzillaTaskListManager;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
@@ -17,6 +13,7 @@ import org.osgi.framework.BundleContext;
public class BugzillaUiPlugin extends AbstractUIPlugin {
private BugzillaTaskListManager bugzillaTaskListManager;
+ private BugzillaRefreshManager bugzillaRefreshManager;
private static BugzillaUiPlugin plugin;
@@ -34,6 +31,7 @@ public class BugzillaUiPlugin extends AbstractUIPlugin {
super.start(context);
BugzillaPlugin.setResultEditorMatchAdapter(new BugzillaResultMatchAdapter());
bugzillaTaskListManager = new BugzillaTaskListManager();
+ bugzillaRefreshManager = new BugzillaRefreshManager();
}
/**
@@ -42,11 +40,7 @@ public class BugzillaUiPlugin extends AbstractUIPlugin {
public void stop(BundleContext context) throws Exception {
super.stop(context);
plugin = null;
- List<Job> list = new ArrayList<Job>();
- list.addAll(BugzillaTask.REFRESH_JOBS.keySet());
- for(Job j: list){
- j.cancel();
- }
+ bugzillaRefreshManager.clearAllRefreshes();
}
/**
@@ -70,4 +64,8 @@ public class BugzillaUiPlugin extends AbstractUIPlugin {
public BugzillaTaskListManager getBugzillaTaskListManager() {
return bugzillaTaskListManager;
}
+
+ public BugzillaRefreshManager getBugzillaRefreshManager() {
+ return bugzillaRefreshManager;
+ }
}
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/RefreshBugzillaAction.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/RefreshBugzillaAction.java
index d5c220098..f4138d8b6 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/RefreshBugzillaAction.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/RefreshBugzillaAction.java
@@ -21,6 +21,7 @@ import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.mylar.bugzilla.ui.BugzillaImages;
+import org.eclipse.mylar.bugzilla.ui.BugzillaUiPlugin;
import org.eclipse.mylar.bugzilla.ui.tasklist.BugzillaHit;
import org.eclipse.mylar.bugzilla.ui.tasklist.BugzillaQueryCategory;
import org.eclipse.mylar.bugzilla.ui.tasklist.BugzillaTask;
@@ -77,7 +78,7 @@ public class RefreshBugzillaAction extends Action implements IViewActionDelegate
cat.refreshBugs();
for(BugzillaHit hit: cat.getChildren()){
if(hit.hasCorrespondingActivatableTask()){
- ((BugzillaTask)hit.getOrCreateCorrespondingTask()).refresh();
+ BugzillaUiPlugin.getDefault().getBugzillaRefreshManager().addTaskToBeRefreshed((BugzillaTask)hit.getOrCreateCorrespondingTask());
}
}
if(TaskListView.getDefault() != null)
@@ -101,15 +102,15 @@ public class RefreshBugzillaAction extends Action implements IViewActionDelegate
TaskCategory cat = (TaskCategory) obj;
for (ITask task : cat.getChildren()) {
if (task instanceof BugzillaTask) {
- ((BugzillaTask)task).refresh();
+ BugzillaUiPlugin.getDefault().getBugzillaRefreshManager().addTaskToBeRefreshed((BugzillaTask)task);
}
}
} else if (obj instanceof BugzillaTask) {
- ((BugzillaTask)obj).refresh();
+ BugzillaUiPlugin.getDefault().getBugzillaRefreshManager().addTaskToBeRefreshed((BugzillaTask)obj);
} else if(obj instanceof BugzillaHit){
BugzillaHit hit = (BugzillaHit)obj;
if(hit.hasCorrespondingActivatableTask()){
- hit.getAssociatedTask().refresh();
+ BugzillaUiPlugin.getDefault().getBugzillaRefreshManager().addTaskToBeRefreshed(hit.getAssociatedTask());
}
}
for(ITask task: MylarTasklistPlugin.getTaskListManager().getTaskList().getActiveTasks()){
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/RefreshBugzillaReportsAction.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/RefreshBugzillaReportsAction.java
index b586aefdb..f1aedca0d 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/RefreshBugzillaReportsAction.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/RefreshBugzillaReportsAction.java
@@ -21,6 +21,7 @@ import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.mylar.bugzilla.ui.BugzillaImages;
+import org.eclipse.mylar.bugzilla.ui.BugzillaUiPlugin;
import org.eclipse.mylar.bugzilla.ui.tasklist.BugzillaHit;
import org.eclipse.mylar.bugzilla.ui.tasklist.BugzillaQueryCategory;
import org.eclipse.mylar.bugzilla.ui.tasklist.BugzillaTask;
@@ -138,7 +139,8 @@ public class RefreshBugzillaReportsAction extends Action implements IViewActionD
for (ITask task : tasks) {
if (task instanceof BugzillaTask && !task.isCompleted()) {
- ((BugzillaTask) task).refresh();
+// ((BugzillaTask) task).refresh();
+ BugzillaUiPlugin.getDefault().getBugzillaRefreshManager().addTaskToBeRefreshed((BugzillaTask)task);
}
}
for (AbstractCategory cat : MylarTasklistPlugin
@@ -146,13 +148,15 @@ public class RefreshBugzillaReportsAction extends Action implements IViewActionD
if (cat instanceof TaskCategory) {
for (ITask task : ((TaskCategory) cat).getChildren()) {
if (task instanceof BugzillaTask && !task.isCompleted()) {
- ((BugzillaTask) task).refresh();
+ BugzillaUiPlugin.getDefault().getBugzillaRefreshManager().addTaskToBeRefreshed((BugzillaTask)task);
+// ((BugzillaTask) task).refresh();
}
}
if (((TaskCategory) cat).getChildren() != null) {
for (ITask child : ((TaskCategory) cat).getChildren()) {
if (child instanceof BugzillaTask && !child.isCompleted()) {
- ((BugzillaTask)child).refresh();
+ BugzillaUiPlugin.getDefault().getBugzillaRefreshManager().addTaskToBeRefreshed((BugzillaTask)child);
+// ((BugzillaTask)child).refresh();
}
}
}
@@ -166,7 +170,8 @@ public class RefreshBugzillaReportsAction extends Action implements IViewActionD
if(hit.hasCorrespondingActivatableTask()){
BugzillaTask task = ((BugzillaTask)hit.getOrCreateCorrespondingTask());
if(!task.isCompleted()){
- task.refresh();
+ BugzillaUiPlugin.getDefault().getBugzillaRefreshManager().addTaskToBeRefreshed(task);
+// task.refresh();
}
}
}
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaRefreshManager.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaRefreshManager.java
new file mode 100644
index 000000000..b675865c1
--- /dev/null
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaRefreshManager.java
@@ -0,0 +1,65 @@
+package org.eclipse.mylar.bugzilla.ui.tasklist;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.jobs.Job;
+
+public class BugzillaRefreshManager {
+
+ private List<BugzillaTask> toBeRefreshed;
+
+ private Map<BugzillaTask, Job> currentlyRefreshing;
+
+ private static final int MAX_REFRESH_JOBS = 5;
+
+ public BugzillaRefreshManager (){
+ toBeRefreshed = new LinkedList<BugzillaTask>();
+ currentlyRefreshing = new HashMap<BugzillaTask, Job>();
+ }
+
+ public void addTaskToBeRefreshed(BugzillaTask task){
+ if(!currentlyRefreshing.containsKey(task) && !toBeRefreshed.contains(task)){
+ toBeRefreshed.add(task);
+ }
+ updateRefreshState();
+ }
+
+ public void removeTaskToBeRefreshed(BugzillaTask task){
+ toBeRefreshed.remove(task);
+ if(currentlyRefreshing.get(task) != null){
+ currentlyRefreshing.get(task).cancel();
+ currentlyRefreshing.remove(task);
+ }
+ updateRefreshState();
+ }
+
+ public void removeRefreshingTask(BugzillaTask task){
+ if(currentlyRefreshing.containsKey(task)){
+ currentlyRefreshing.remove(task);
+ }
+ updateRefreshState();
+ }
+
+ private void updateRefreshState(){
+ if(currentlyRefreshing.size() < MAX_REFRESH_JOBS && toBeRefreshed.size() > 0){
+ BugzillaTask t = toBeRefreshed.remove(0);
+ Job j = t.getRefreshJob();
+ currentlyRefreshing.put(t, j);
+ j.schedule();
+ }
+ }
+
+ public void clearAllRefreshes() {
+ toBeRefreshed.clear();
+ List<Job> l = new ArrayList<Job>();
+ l.addAll(currentlyRefreshing.values());
+ for(Job j : l){
+ j.cancel();
+ }
+ currentlyRefreshing.clear();
+ }
+}
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTask.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTask.java
index 47e60098e..de54ec3a2 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTask.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasklist/BugzillaTask.java
@@ -16,9 +16,7 @@ package org.eclipse.mylar.bugzilla.ui.tasklist;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
import javax.security.auth.login.LoginException;
@@ -36,6 +34,7 @@ import org.eclipse.mylar.bugzilla.core.internal.HtmlStreamTokenizer;
import org.eclipse.mylar.bugzilla.core.offline.OfflineReportsFile;
import org.eclipse.mylar.bugzilla.ui.BugzillaImages;
import org.eclipse.mylar.bugzilla.ui.BugzillaUITools;
+import org.eclipse.mylar.bugzilla.ui.BugzillaUiPlugin;
import org.eclipse.mylar.bugzilla.ui.OfflineView;
import org.eclipse.mylar.core.MylarPlugin;
import org.eclipse.mylar.tasklist.MylarTasklistPlugin;
@@ -64,9 +63,6 @@ public class BugzillaTask extends Task {
public enum BugTaskState {FREE, WAITING, DOWNLOADING, COMPARING, OPENING}
private transient BugTaskState state;
- public static Map<Job, String>REFRESH_JOBS = new HashMap<Job, String>();
-
-
/**
* The bug report for this BugzillaTask. This is <code>null</code> if the
* bug report with the specified ID was unable to download.
@@ -344,7 +340,7 @@ public class BugzillaTask extends Task {
updateTaskDetails();
notifyTaskDataChange();
saveBugReport(true);
- REFRESH_JOBS.remove(this);
+ BugzillaUiPlugin.getDefault().getBugzillaRefreshManager().removeRefreshingTask(BugzillaTask.this);
return new Status(IStatus.OK, MylarPlugin.IDENTIFIER, IStatus.OK, "", null);
}
}
@@ -394,18 +390,18 @@ public class BugzillaTask extends Task {
}
}
- /**
- * Refreshes the bug report with the Bugzilla server.
- */
- public void refresh() {
- // The bug report must be untouched, and this task must not be busy.
- if (isDirty() || (state != BugTaskState.FREE)) {
- return;
- }
- GetBugReportJob job = new GetBugReportJob("Refreshing with Bugzilla server...");
- REFRESH_JOBS.put(job, getHandle());
- job.schedule();
- }
+// /**
+// * Refreshes the bug report with the Bugzilla server.
+// */
+// public void refresh() {
+// // The bug report must be untouched, and this task must not be busy.
+// if (isDirty() || (state != BugTaskState.FREE)) {
+// return;
+// }
+// GetBugReportJob job = new GetBugReportJob("Refreshing with Bugzilla server...");
+//// REFRESH_JOBS.put(job, getHandle());
+// job.schedule();
+// }
@Override
public String getToolTipText() {
@@ -557,4 +553,12 @@ public class BugzillaTask extends Task {
GetBugReportJob job = new GetBugReportJob("Downloading from Bugzilla server...");
job.schedule();
}
+
+ public Job getRefreshJob() {
+ if (isDirty() || (state != BugTaskState.FREE)) {
+ return null;
+ }
+ GetBugReportJob job = new GetBugReportJob("Refreshing with Bugzilla server...");
+ return job;
+ }
}

Back to the top