Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8249016

Naming logical bug with someString.replace() and someString.replaceAll()

    Details

    • Subcomponent:
    • CPU:
      x86_64
    • OS:
      windows_10

      Description

      A DESCRIPTION OF THE PROBLEM :
      If there are two fields that start with the same sequence of chars, for example, invoiceTo and invoiceTotal, and on calling replace or replaceAll functions for both fields like the code below, there is a logical error that instead of getting the value that is passed, it results with the field named invoiceTotal getting "tal" as a value, which is the rest of the fields' name.

      Code sample:
      String invoiceTo = "some value";
      String invoiceTotal = "some other value"
      bodyInvoice = Config.getProperty("invoiceBody")
      .replace("@invoiceTo", invoiceTo)
      .replace("@invoiceTotal", invoiceTotal);

      -----------------------------------
      the value of invoiceTotal is "tal" instead of "some other value"

      REGRESSION : Last worked in version 8u251


      FREQUENCY : always


        Attachments

          Activity

            People

            • Assignee:
              tongwan Andrew Wang
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: