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

(str) Race condition in String.contentEquals when comparing with StringBuffer

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 8
    • Fix Version/s: 8
    • Component/s: core-libs
    • Labels:
      None
    • Subcomponent:
    • Introduced In Build:
      b52
    • Introduced In Version:
      8
    • Resolved In Build:
      b93
    • Verification:
      Verified

      Description

      On 05/14/2013 12:09 AM, Peter Levart wrote:
      >> I noticed a synchronization bug in String.contentEquals method. If called with a StringBuffer
      >> argument while concurrent thread is modifying the StringBuffer, the method can either throw
      >> ArrayIndexOutOfBoundsException or return true even though the content of the StringBuffer has
      >> never been the same as the String's.
      >>
      >> Here's a proposed patch:
      >>
      >> http://cr.openjdk.java.net/~plevart/jdk8-tl/String.contentEquals/webrev.01/
      >>
      >> Regards, Peter

      Or even better (with some code clean-up):

      http://cr.openjdk.java.net/~plevart/jdk8-tl/String.contentEquals/webrev.02/

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                plevart Peter Levart
                Reporter:
                dholmes David Holmes
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: