Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfbecker2009-03-07 16:40:29 -0500
committerfbecker2009-03-07 16:40:29 -0500
commit037803b3040afbcf4baca926f0bce0342508de88 (patch)
tree7d8836ea9f9f6719ee5d86ada4b728b17c230a0b
parent898ce6ae399c515ff3e185ba22892c3b91c08cad (diff)
downloadorg.eclipse.mylyn.tasks-037803b3040afbcf4baca926f0bce0342508de88.tar.gz
org.eclipse.mylyn.tasks-037803b3040afbcf4baca926f0bce0342508de88.tar.xz
org.eclipse.mylyn.tasks-037803b3040afbcf4baca926f0bce0342508de88.zip
ASSIGNED - bug 267453: [patch] NullPointerException in BugzillaUpdateAttachmentAction
https://bugs.eclipse.org/bugs/show_bug.cgi?id=267453
-rw-r--r--org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepositoryConnectorTest.java2
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/action/BugzillaUpdateAttachmentAction.java3
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/action/UpdateAttachmentJob.java40
3 files changed, 24 insertions, 21 deletions
diff --git a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepositoryConnectorTest.java b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepositoryConnectorTest.java
index a7ba76118..fc6157731 100644
--- a/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepositoryConnectorTest.java
+++ b/org.eclipse.mylyn.bugzilla.tests/src/org/eclipse/mylyn/bugzilla/tests/BugzillaRepositoryConnectorTest.java
@@ -136,6 +136,7 @@ public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest {
TaskAttribute.TYPE_ATTACHMENT).get(0);
assertNotNull(attachment);
TaskAttribute obsolete = attachment.getMappedAttribute(TaskAttribute.ATTACHMENT_IS_DEPRECATED);
+ assertNotNull(obsolete);
boolean oldObsoleteOn = obsolete.getValue().equals("1");
if (oldObsoleteOn) {
obsolete.setValue("0"); //$NON-NLS-1$
@@ -153,6 +154,7 @@ public class BugzillaRepositoryConnectorTest extends AbstractBugzillaTest {
attachment = taskData.getAttributeMapper().getAttributesByType(taskData, TaskAttribute.TYPE_ATTACHMENT).get(0);
assertNotNull(attachment);
obsolete = attachment.getMappedAttribute(TaskAttribute.ATTACHMENT_IS_DEPRECATED);
+ assertNotNull(obsolete);
boolean newObsoleteOn = obsolete.getValue().equals("1");
assertEquals(true, oldObsoleteOn != newObsoleteOn);
}
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/action/BugzillaUpdateAttachmentAction.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/action/BugzillaUpdateAttachmentAction.java
index 36ba89b0d..2d1736dcf 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/action/BugzillaUpdateAttachmentAction.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/action/BugzillaUpdateAttachmentAction.java
@@ -106,8 +106,7 @@ public class BugzillaUpdateAttachmentAction extends BaseSelectionListenerAction
for (ITaskAttachment taskAttachment : attachmentList) {
TaskAttribute taskAttribute = taskAttachment.getTaskAttribute();
TaskAttribute deprecated = taskAttribute.getMappedAttribute(TaskAttribute.ATTACHMENT_IS_DEPRECATED);
-
- if (deprecated.getValue().equals("1") != obsolete) { //$NON-NLS-1$
+ if (deprecated != null && deprecated.getValue().equals("1") != obsolete) { //$NON-NLS-1$
action.setEnabled(true);
break;
}
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/action/UpdateAttachmentJob.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/action/UpdateAttachmentJob.java
index 4f4e92fd5..0fa6516ca 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/action/UpdateAttachmentJob.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/action/UpdateAttachmentJob.java
@@ -78,25 +78,27 @@ public class UpdateAttachmentJob extends Job {
for (ITaskAttachment taskAttachment : attachment) {
TaskAttribute taskAttribute = taskAttachment.getTaskAttribute();
TaskAttribute deprecated = taskAttribute.getMappedAttribute(TaskAttribute.ATTACHMENT_IS_DEPRECATED);
- if (deprecated.getValue().equals("1") && !obsolete) { //$NON-NLS-1$
- try {
- deprecated.setValue("0"); //$NON-NLS-1$
- ((BugzillaTaskDataHandler) connector.getTaskDataHandler()).postUpdateAttachment(
- taskAttachment.getTaskRepository(), taskAttribute, "update", monitor); //$NON-NLS-1$
- } catch (CoreException e) {
- error = e.getStatus();
- deprecated.setValue("1"); //$NON-NLS-1$
- return Status.OK_STATUS;
- }
- } else if (deprecated.getValue().equals("0") && obsolete) { //$NON-NLS-1$
- try {
- deprecated.setValue("1"); //$NON-NLS-1$
- ((BugzillaTaskDataHandler) connector.getTaskDataHandler()).postUpdateAttachment(
- taskAttachment.getTaskRepository(), taskAttribute, "update", monitor); //$NON-NLS-1$
- } catch (CoreException e) {
- error = e.getStatus();
- deprecated.setValue("0"); //$NON-NLS-1$
- return Status.OK_STATUS;
+ if (deprecated != null) {
+ if (deprecated.getValue().equals("1") && !obsolete) { //$NON-NLS-1$
+ try {
+ deprecated.setValue("0"); //$NON-NLS-1$
+ ((BugzillaTaskDataHandler) connector.getTaskDataHandler()).postUpdateAttachment(
+ taskAttachment.getTaskRepository(), taskAttribute, "update", monitor); //$NON-NLS-1$
+ } catch (CoreException e) {
+ error = e.getStatus();
+ deprecated.setValue("1"); //$NON-NLS-1$
+ return Status.OK_STATUS;
+ }
+ } else if (deprecated.getValue().equals("0") && obsolete) { //$NON-NLS-1$
+ try {
+ deprecated.setValue("1"); //$NON-NLS-1$
+ ((BugzillaTaskDataHandler) connector.getTaskDataHandler()).postUpdateAttachment(
+ taskAttachment.getTaskRepository(), taskAttribute, "update", monitor); //$NON-NLS-1$
+ } catch (CoreException e) {
+ error = e.getStatus();
+ deprecated.setValue("0"); //$NON-NLS-1$
+ return Status.OK_STATUS;
+ }
}
}
monitor.worked(10);

Back to the top