Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsminto2005-07-15 15:13:51 +0000
committersminto2005-07-15 15:13:51 +0000
commitbf8b277e2bb5835cf3c5e67b3726e7ea686c3123 (patch)
tree4bb19366071298c5b2d0fab4a028f368df3b7c49
parent57a11b4c3ea6364fc318448a8b193e0e3f97f677 (diff)
downloadorg.eclipse.mylyn.tasks-bf8b277e2bb5835cf3c5e67b3726e7ea686c3123.tar.gz
org.eclipse.mylyn.tasks-bf8b277e2bb5835cf3c5e67b3726e7ea686c3123.tar.xz
org.eclipse.mylyn.tasks-bf8b277e2bb5835cf3c5e67b3726e7ea686c3123.zip
Fixed Bug# 103107 bugzilla fails to load corrupted offline reports
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/offline/OfflineReportsFile.java26
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/BugzillaUiPlugin.java12
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/OfflineView.java2
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/BugzillaTask.java20
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/BugzillaTaskExternalizer.java2
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/internal/TaskListExternalizer.java4
6 files changed, 52 insertions, 14 deletions
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/offline/OfflineReportsFile.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/offline/OfflineReportsFile.java
index 734295ae0..7a1ae526b 100644
--- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/offline/OfflineReportsFile.java
+++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/core/offline/OfflineReportsFile.java
@@ -21,9 +21,11 @@ import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
+import org.eclipse.core.runtime.Status;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.mylar.bugzilla.core.BugzillaPlugin;
import org.eclipse.mylar.bugzilla.core.IBugzillaBug;
+import org.eclipse.mylar.bugzilla.core.IBugzillaConstants;
/**
@@ -62,7 +64,7 @@ public class OfflineReportsFile
* @throws ClassNotFoundException
* Error deserializing objects from the offline reports file
*/
- public OfflineReportsFile(File file) throws ClassNotFoundException, IOException {
+ public OfflineReportsFile(File file) throws IOException {
this.file = file;
if (file.exists()) {
readFile();
@@ -135,8 +137,13 @@ public class OfflineReportsFile
// write each element in the array list
for (int i = 0; i < list.size(); i++) {
- Object item = list.get(i);
- out.writeObject(item);
+ IBugzillaBug item = list.get(i);
+ try{
+ out.writeObject(item);
+ }catch (IOException e) {
+ // put up a message and log the error if there is a problem writing to the file
+ BugzillaPlugin.log(new Status(Status.WARNING, IBugzillaConstants.PLUGIN_ID, Status.WARNING, "Unable to write bug object: " + item.getId(), e));
+ }
}
out.close();
}
@@ -157,7 +164,7 @@ public class OfflineReportsFile
* @throws ClassNotFoundException
* Error deserializing objects from the offline reports file
*/
- private void readFile() throws ClassNotFoundException, IOException {
+ private void readFile() throws IOException {
ObjectInputStream in = new ObjectInputStream(new FileInputStream(file));
// get the number of offline reports in the file
@@ -168,9 +175,14 @@ public class OfflineReportsFile
// read in each of the offline reports in the file
for (int nX = 0; nX < size; nX++) {
- IBugzillaBug item = (IBugzillaBug) in.readObject();
- // add the offline report to the offlineReports list
- list.add(item);
+ try {
+ IBugzillaBug item = (IBugzillaBug) in.readObject();
+ // add the offline report to the offlineReports list
+ list.add(item);
+ } catch (ClassNotFoundException e){
+ // ignore this since we can't do anything
+ BugzillaPlugin.log(new Status(Status.ERROR, IBugzillaConstants.PLUGIN_ID, Status.ERROR, "Unable to read bug object", e));
+ }
}
in.close();
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 e0c2c0059..f68445b98 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,10 +1,15 @@
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.tasks.BugzillaTask;
import org.eclipse.mylar.bugzilla.ui.tasks.BugzillaTaskExternalizer;
-import org.eclipse.mylar.bugzilla.ui.tasks.BugzillaTaskListManager;
import org.eclipse.mylar.bugzilla.ui.tasks.BugzillaTaskListActionContributor;
+import org.eclipse.mylar.bugzilla.ui.tasks.BugzillaTaskListManager;
import org.eclipse.mylar.tasks.MylarTasksPlugin;
import org.eclipse.ui.IStartup;
import org.eclipse.ui.IWorkbench;
@@ -57,6 +62,11 @@ public class BugzillaUiPlugin extends AbstractUIPlugin implements IStartup {
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();
+ }
}
/**
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/OfflineView.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/OfflineView.java
index b33657e64..3625cd7b8 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/OfflineView.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/OfflineView.java
@@ -596,7 +596,7 @@ public class OfflineView extends ViewPart {
}
public static void refresh() {
- if(viewer != null)
+ if(viewer != null && !viewer.getTable().isDisposed())
viewer.refresh();
}
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/BugzillaTask.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/BugzillaTask.java
index d6fcc8b28..c5e3b84e9 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/BugzillaTask.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/BugzillaTask.java
@@ -16,7 +16,9 @@ package org.eclipse.mylar.bugzilla.ui.tasks;
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;
@@ -65,6 +67,9 @@ 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.
@@ -192,9 +197,12 @@ public class BugzillaTask extends Task {
* downloaded.
*/
public BugReport downloadReport() {
-// BugzillaTaskEditorInput input = new BugzillaTaskEditorInput(this);
try {
// XXX make sure to send in the server name if there are multiple repositories
+ if(BugzillaPlugin.getDefault() == null){
+ MylarPlugin.log("Bugreport download failed for: " + getBugId(getHandle()) + " due to bugzilla core not existing", this);
+ return null;
+ }
return BugzillaRepository.getInstance().getBug(getBugId(getHandle()));
} catch (LoginException e) {
MylarPlugin.log(e, "download failed");
@@ -335,12 +343,17 @@ public class BugzillaTask extends Task {
updateTaskDetails();
notifyTaskDataChange();
saveBugReport(true);
+ REFRESH_JOBS.remove(this);
return new Status(IStatus.OK, MylarPlugin.IDENTIFIER, IStatus.OK, "", null);
}
}
public void updateTaskDetails() {
try {
+ if(bugReport == null)
+ downloadReport();
+ if(bugReport == null)
+ return;
setPriority(bugReport.getAttribute("Priority").getValue());
String status = bugReport.getAttribute("Status").getValue();
if (status.equals("RESOLVED") || status.equals("CLOSED") || status.equals("VERIFIED")) {
@@ -348,7 +361,7 @@ public class BugzillaTask extends Task {
}
this.setLabel(HtmlStreamTokenizer.unescape(BugzillaTask.getBugId(getHandle()) + ": " + bugReport.getSummary()));
} catch (NullPointerException npe) {
- // TODO: handle this better
+ MylarPlugin.log(npe, "Task details update failed");
}
}
@@ -388,6 +401,7 @@ public class BugzillaTask extends Task {
return;
}
GetBugReportJob job = new GetBugReportJob("Refreshing with Bugzilla server...");
+ REFRESH_JOBS.put(job, getHandle());
job.schedule();
}
@@ -467,6 +481,8 @@ public class BugzillaTask extends Task {
}
public void removeReport() {
+ // XXX do we really want to do this???
+ // XXX remove from registry too??
OfflineReportsFile offlineReports = BugzillaPlugin.getDefault().getOfflineReports();
int location = offlineReports.find(getBugId(getHandle()));
if(location != -1){
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/BugzillaTaskExternalizer.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/BugzillaTaskExternalizer.java
index 1210cdf32..ebccc9243 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/BugzillaTaskExternalizer.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/BugzillaTaskExternalizer.java
@@ -127,7 +127,7 @@ public class BugzillaTaskExternalizer extends DefaultTaskListExternalizer {
} else {
node.setAttribute(DIRTY, FALSE);
}
- bt.saveBugReport(false);
+// bt.saveBugReport(false); // XXX don't think that this needs to be done, should be handled already
return node;
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/internal/TaskListExternalizer.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/internal/TaskListExternalizer.java
index da672eef3..18da3039a 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/internal/TaskListExternalizer.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/internal/TaskListExternalizer.java
@@ -99,7 +99,7 @@ public class TaskListExternalizer {
}
if (element == null && defaultExternalizer.canCreateElementFor(category)) {
defaultExternalizer.createCategoryElement(category, doc, root);
- } else {
+ } else if(element == null){
MylarPlugin.log("Did not externalize: " + category, this);
}
}
@@ -111,7 +111,7 @@ public class TaskListExternalizer {
}
if (element == null && defaultExternalizer.canCreateElementFor(task)) {
defaultExternalizer.createTaskElement(task, doc, root);
- } else {
+ } else if(element == null){
MylarPlugin.log("Did not externalize: " + task, this);
}
}catch (Exception e) {

Back to the top