diff options
-rw-r--r-- | org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClient.java | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClient.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClient.java index 078dee213..639674150 100644 --- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClient.java +++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClient.java @@ -591,6 +591,9 @@ public class BugzillaClient { public void postAttachment(String bugReportID, String comment, ITaskAttachment attachment) throws HttpException, IOException, CoreException { + + // TODO: Throw IllegalArgumentException if passed null parameter + WebClientUtil.setupHttpClient(httpClient, proxy, repositoryUrl.toString(), htAuthUser, htAuthPass); if (!authenticated && hasAuthenticationCredentials()) { authenticate(); @@ -607,12 +610,18 @@ public class BugzillaClient { postMethod.getParams().setBooleanParameter(HttpMethodParams.USE_EXPECT_CONTINUE, true); List<PartBase> parts = new ArrayList<PartBase>(); parts.add(new StringPart(IBugzillaConstants.POST_INPUT_ACTION, VALUE_ACTION_INSERT, characterEncoding)); - parts.add(new StringPart(IBugzillaConstants.POST_INPUT_BUGZILLA_LOGIN, username, characterEncoding)); - parts.add(new StringPart(IBugzillaConstants.POST_INPUT_BUGZILLA_PASSWORD, password, characterEncoding)); + if (username != null && password != null) { + parts.add(new StringPart(IBugzillaConstants.POST_INPUT_BUGZILLA_LOGIN, username, characterEncoding)); + parts.add(new StringPart(IBugzillaConstants.POST_INPUT_BUGZILLA_PASSWORD, password, characterEncoding)); + } parts.add(new StringPart(IBugzillaConstants.POST_INPUT_BUGID, bugReportID, characterEncoding)); - parts.add(new StringPart(IBugzillaConstants.POST_INPUT_DESCRIPTION, attachment.getDescription(), - characterEncoding)); - parts.add(new StringPart(IBugzillaConstants.POST_INPUT_COMMENT, comment, characterEncoding)); + if (attachment.getDescription() != null) { + parts.add(new StringPart(IBugzillaConstants.POST_INPUT_DESCRIPTION, attachment.getDescription(), + characterEncoding)); + } + if (comment != null) { + parts.add(new StringPart(IBugzillaConstants.POST_INPUT_COMMENT, comment, characterEncoding)); + } parts.add(new FilePart(IBugzillaConstants.POST_INPUT_DATA, new AttachmentPartSource(attachment))); if (attachment.isPatch()) { |