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 2022/08/31 07:38:04 UTC

[camel] branch camel-3.18.x updated: CAMEL-18439: camel-github - Consumer that polls commits crashed when repository has more than 100 commits

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch camel-3.18.x
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/camel-3.18.x by this push:
     new 559ef5b379a CAMEL-18439: camel-github - Consumer that polls commits crashed when repository has more than 100 commits
559ef5b379a is described below

commit 559ef5b379abf691610aea27172677dc9a6fbf2a
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Aug 31 09:37:19 2022 +0200

    CAMEL-18439: camel-github - Consumer that polls commits crashed when repository has more than 100 commits
---
 .../apache/camel/component/github/consumer/CommitConsumer.java    | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/components/camel-github/src/main/java/org/apache/camel/component/github/consumer/CommitConsumer.java b/components/camel-github/src/main/java/org/apache/camel/component/github/consumer/CommitConsumer.java
index 3bf44be6bc7..b78e4922e65 100644
--- a/components/camel-github/src/main/java/org/apache/camel/component/github/consumer/CommitConsumer.java
+++ b/components/camel-github/src/main/java/org/apache/camel/component/github/consumer/CommitConsumer.java
@@ -119,11 +119,16 @@ public class CommitConsumer extends AbstractGitHubConsumer {
         for (RepositoryCommit commit : commits) {
             if (!commitHashes.contains(commit.getSha())) {
                 newCommits.push(commit);
+                // make room when adding new elements
+                while (commitHashes.size() > CAPACITY - 1) {
+                    commitHashes.remove();
+                }
                 commitHashes.add(commit.getSha());
                 lastSha = commit.getSha();
             }
         }
 
+        int counter = 0;
         while (!newCommits.empty()) {
             RepositoryCommit newCommit = newCommits.pop();
             Exchange e = createExchange(true);
@@ -133,7 +138,8 @@ public class CommitConsumer extends AbstractGitHubConsumer {
             e.getMessage().setHeader(GitHubConstants.GITHUB_COMMIT_URL, newCommit.getUrl());
             e.getMessage().setBody(newCommit.getCommit().getMessage());
             getProcessor().process(e);
+            counter++;
         }
-        return newCommits.size();
+        return counter;
     }
 }