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

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

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P4
    • 8
    • 8
    • core-libs
    • None
    • b52
    • 8
    • b93
    • 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

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

              Dates

                Created:
                Updated:
                Resolved: