Uploaded image for project: 'Product Technical Learning'
  1. Product Technical Learning
  2. PTL-2226

DO378-143: Accurate string comparative method required.

XMLWordPrintable

    • 4
    • ROLE
    • en-US (English)

      URL: https://role.rhu.redhat.com/rol-rhu/app/courses/do378-2.13/pages/ch04s05
      Reporter RHNID: ggastald
      Section: 5 - Event-driven Architecture (EDA)
      Language: en-US (English)||
      Workaround:

      Description: Issue 1

      event.profile == "business" does not work in Java (unless the String is in an intern pool, which is not the case). Use "business".equals(event.profile) instead

      In Java, when comparing strings for equality, it is recommended to use the equals() method instead of the == operator. The equals() method compares the actual contents of the strings, whereas the == operator checks for reference equality.

      So, to compare the event.profile string with the value "business", you should use "business".equals(event.profile) as follows:

       
      javaCopy code
      {{if ("business".equals(event.profile))

      { notifyMarketingAboutNewBusiness(event.id); }

      }}
      This ensures that the comparison is performed correctly, regardless of whether the strings are interned or not.

       

      Issue 2 

      There is a missing closing parenthesis in the given code. The correct code should be:

      Given code screenshot attached. 

       
      Correct javaCopy code
      {{return Message.of(
      high.await().atMost(Duration.ofSeconds(1)).doubleValue()
      /
      total.await().atMost(Duration.ofSeconds(1)).doubleValue()
      );}}
       

       

      Please ping me on the ticket for any further information regarding this.

        1. Screenshot_98.png
          17 kB
          deepak singh
        2. Screenshot_99.png
          19 kB
          deepak singh

              vinaybelagavi Vinay Belagavi (Inactive)
              deepasin@redhat.com deepak singh (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: