Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-20356

camel-core - LoggerHelper returns wrong name for source code line precise

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 3.20.9, 3.21.3, 3.22.0, 4.3.0
    • 3.21.5, 3.22.1, 4.0.4, 4.4.0
    • camel-core
    • None
    • Patch Available
    • Unknown
    • Patch

    Description

      I noticed that the source for logging and message history was incorrect for this route.

      @Component
      public class TestRoutes extends EndpointRouteBuilder {
      
          @Override
          public void configure() throws Exception {
      
              from(timer("test").repeatCount(1))
                      .routeId("test")
                      .log("Hello world")
                      .throwException(new Exception("Exception message")); 

       

      The following logging is what I got:

      2024-01-22 16:54:19.103  INFO 19752 --- [ - timer://test] java:15                                  : Hello world
      2024-01-22 16:54:19.108 ERROR 19752 --- [ - timer://test] o.a.c.p.e.DefaultErrorHandler            : Failed delivery for (MessageId: F49EB5D651EC2D3-0000000000000000 on ExchangeId: F49EB5D651EC2D3-0000000000000000). Exhausted after delivery attempt: 1 caught: java.lang.Exception: Exception messageMessage History
      ---------------------------------------------------------------------------------------------------------------------------------------
      Source                                   ID                             Processor                                          Elapsed (ms)
      java:13                                  test/test                      from[timer://test?repeatCount=1]                      632443839
      java:15                                  test/log1                      log                                                           2
      java:16                                  test/throwException1           throwException[java.lang.Exception]                           0
       

      Wherever it says: java I would expect TestRoutes.

      Did some digging on my own and I think it's because of this piece of code in the LoggerHelper.getLineNumberLoggerName

      // classname so let us only grab the name
      int pos = name.lastIndexOf('.');
      if (pos > 0) {
          name = name.substring(pos + 1);
      } 

      The name in this case is TestRoutes.java and the substring method grabs java instead of TestRoutes.

       

      Attachments

        1. CAMEL-20356 - LoggerHelper.patch
          0.7 kB
          Marco Bergsma

        Activity

          People

            davsclaus Claus Ibsen
            mbergsma Marco Bergsma
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: