You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2019/06/04 03:23:46 UTC
[camel] branch master updated: Only poll after the initial load,
as querying jira with "id > lastId" the backend jira throws an
error when lastId = -1
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/master by this push:
new b509df3 Only poll after the initial load, as querying jira with "id > lastId" the backend jira throws an error when lastId = -1
b509df3 is described below
commit b509df3d30fc14896ebdf0e1d2db239173d56bff
Author: Claudio Miranda <cl...@claudius.com.br>
AuthorDate: Mon Jun 3 15:14:19 2019 -0300
Only poll after the initial load, as querying jira with "id > lastId" the backend jira throws an error when lastId = -1
---
.../component/jira/consumer/NewIssuesConsumer.java | 22 ++++++++++++++--------
.../jira/producer/UpdateIssueProducer.java | 13 ++++++++++---
2 files changed, 24 insertions(+), 11 deletions(-)
diff --git a/components/camel-jira/src/main/java/org/apache/camel/component/jira/consumer/NewIssuesConsumer.java b/components/camel-jira/src/main/java/org/apache/camel/component/jira/consumer/NewIssuesConsumer.java
index 9cb123c..8b26a65 100644
--- a/components/camel-jira/src/main/java/org/apache/camel/component/jira/consumer/NewIssuesConsumer.java
+++ b/components/camel-jira/src/main/java/org/apache/camel/component/jira/consumer/NewIssuesConsumer.java
@@ -53,15 +53,21 @@ public class NewIssuesConsumer extends AbstractJiraConsumer {
@Override
protected int poll() throws Exception {
- List<Issue> newIssues = getNewIssues();
- // In the end, we want only *new* issues oldest to newest.
- for (int i = newIssues.size() - 1; i > -1; i--) {
- Issue newIssue = newIssues.get(i);
- Exchange e = getEndpoint().createExchange();
- e.getIn().setBody(newIssue);
- getProcessor().process(e);
+ // it may happen the poll() is called while the route is doing the initial load,
+ // this way we need to wait for the latestIssueId being associated to the last indexed issue id
+ int nMessages = 0;
+ if (latestIssueId > -1) {
+ List<Issue> newIssues = getNewIssues();
+ // In the end, we want only *new* issues oldest to newest.
+ for (int i = newIssues.size() - 1; i > -1; i--) {
+ Issue newIssue = newIssues.get(i);
+ Exchange e = getEndpoint().createExchange();
+ e.getIn().setBody(newIssue);
+ getProcessor().process(e);
+ }
+ nMessages = newIssues.size();
}
- return newIssues.size();
+ return nMessages;
}
private List<Issue> getNewIssues() {
diff --git a/components/camel-jira/src/main/java/org/apache/camel/component/jira/producer/UpdateIssueProducer.java b/components/camel-jira/src/main/java/org/apache/camel/component/jira/producer/UpdateIssueProducer.java
index c10729a..7f8fbda 100644
--- a/components/camel-jira/src/main/java/org/apache/camel/component/jira/producer/UpdateIssueProducer.java
+++ b/components/camel-jira/src/main/java/org/apache/camel/component/jira/producer/UpdateIssueProducer.java
@@ -71,15 +71,22 @@ public class UpdateIssueProducer extends DefaultProducer {
if (issueTypeId != null) {
builder.setIssueTypeId(issueTypeId);
}
- builder.setSummary(summary);
- builder.setDescription(exchange.getIn().getBody(String.class));
+ if (summary != null) {
+ builder.setSummary(summary);
+ }
+ String description = exchange.getIn().getBody(String.class);
+ if (description != null) {
+ builder.setDescription(description);
+ }
if (components != null && components.size() > 0) {
builder.setComponentsNames(components);
}
if (priorityId != null) {
builder.setPriorityId(priorityId);
}
- builder.setAssigneeName(assigneeName);
+ if (assigneeName != null) {
+ builder.setAssigneeName(assigneeName);
+ }
IssueRestClient issueClient = client.getIssueClient();
issueClient.updateIssue(issueKey, builder.build()).claim();
}