You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by "LANGER Manuel (ICS460-BAI.ext)" <Ma...@spar-ics.com.INVALID> on 2022/10/21 05:38:12 UTC

Wrong debug log output when using MockEndpoint

Hi,

I’m using the class org.apache.camel.component.mock.MockEndPoint to test my Camel routes. I was wondering why each test case (actually the reset) takes more than 10sec, although the DEBUG log said “Waiting on the latch for: 0 millis”. Turns out this is a wrong log output, and this happens if the resultWaitTime (= timeout parameter) is set to 0. In this case, a default wait time of 10sec is used, but log stills shows 0sec.

The affected method is:

protected void waitForCompleteLatch(long timeout) throws InterruptedException {
    // Wait for a default 10 seconds if resultWaitTime is not set
    long waitTime = timeout == 0 ? 10000L : timeout;

    // now let's wait for the results
    LOG.debug("Waiting on the latch for: {} millis", timeout);
    if (!latch.await(waitTime, TimeUnit.MILLISECONDS)) {
        LOG.warn("The latch did not reach 0 within the specified time");
    }
}

Here, waitTime should be used instead of timeout for the debug logging.

BR,
Manuel
Sollten Sie diese E-Mail unbeabsichtigt bzw. irrtümlich erhalten haben, so weisen wir Sie darauf hin, dass gemäß § 161 Abs 4 TKG 2021 der Inhalt sowie die Tatsache des Empfangs dieser E-Mail weder aufgezeichnet noch verwertet oder Unbefugten mitgeteilt werden dürfen. Wir ersuchen Sie, die Nachricht von Ihrem System zu löschen und sich mit uns in Verbindung zu setzen. If you have received this email accidentally or in error, we point out that, in accordance with § 161 para. 4 TKG 2021 (Telecommunications Act), the contents of this email and the fact of its receipt must not be recorded, exploited or communicated to unauthorized persons. We ask you to delete the message from your system and to contact us.

Allgemein | General

Manuel LANGER

im Auftrag von

[SPAR Business Services GmbH]<http://www.spar-ics.com>

SPAR Business Services GmbH
Information & Communication Services
Europastrasse 3, 5015 Salzburg, Austria
FN 68396 h


Mobile: +43 664 8833 8301
E-Mail: Manuel.LANGER@spar-ics.com<ma...@spar-ics.com>
Internet: http://www.spar.at<http://>


Re: Wrong debug log output when using MockEndpoint

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

You are welcome to send a PR to fix this thanks.


On Fri, Oct 21, 2022 at 10:00 AM LANGER Manuel (ICS460-BAI.ext)
<Ma...@spar-ics.com.invalid> wrote:

> Hi,
>
>
>
> I’m using the class org.apache.camel.component.mock.MockEndPoint to test
> my Camel routes. I was wondering why each test case (actually the reset)
> takes more than 10sec, although the DEBUG log said “Waiting on the latch
> for: 0 millis”. Turns out this is a wrong log output, and this happens if
> the resultWaitTime (= timeout parameter) is set to 0. In this case, a
> default wait time of 10sec is used, but log stills shows 0sec.
>
>
>
> The affected method is:
>
>
>
> protected void waitForCompleteLatch(long timeout) throws
> InterruptedException {
>     // Wait for a default 10 seconds if resultWaitTime is not set
>     long waitTime = timeout == 0 ? 10000L : timeout
>
> *;     *// now let's wait for the results
>     *LOG*.debug("Waiting on the latch for: {} millis"*, *timeout)
> *;     *if (!latch.await(waitTime*, *TimeUnit.*MILLISECONDS*)) {
>         *LOG*.warn("The latch did not reach 0 within the specified time")
> *;     *}
> }
>
>
>
> Here, waitTime should be used instead of timeout for the debug logging.
>
>
>
> BR,
>
> Manuel
> Sollten Sie diese E-Mail unbeabsichtigt bzw. irrtümlich erhalten haben, so
> weisen wir Sie darauf hin, dass gemäß § 161 Abs 4 TKG 2021 der Inhalt sowie
> die Tatsache des Empfangs dieser E-Mail weder aufgezeichnet noch verwertet
> oder Unbefugten mitgeteilt werden dürfen. Wir ersuchen Sie, die Nachricht
> von Ihrem System zu löschen und sich mit uns in Verbindung zu setzen. If
> you have received this email accidentally or in error, we point out that,
> in accordance with § 161 para. 4 TKG 2021 (Telecommunications Act), the
> contents of this email and the fact of its receipt must not be recorded,
> exploited or communicated to unauthorized persons. We ask you to delete the
> message from your system and to contact us.
>
> Allgemein | General
>
>
> Manuel LANGER
>
> im Auftrag von
>
> [image: SPAR Business Services GmbH] <http://www.spar-ics.com>
>
> SPAR Business Services GmbH
> Information & Communication Services
> Europastrasse 3, 5015 Salzburg, Austria
> FN 68396 h
>
>
> Mobile: +43 664 8833 8301
> E-Mail: Manuel.LANGER@spar-ics.com
> Internet: http://www.spar.at
>
>

-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2