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

Concurrency : contains() method of ArrayBlockingQueue doesn't return the expecte

    XMLWordPrintable

    Details

      Description

      Execute the following code with Concurrency preliminary test release 1
      and see the result. contains() method doesn't return correct boolean value.
      It return false even if the element is present.

      /* start of sample test code */
      //If the array ArrayBlockingQueue size is 3, then contains() method of the queue
      //doesn't return correct boolean value. But if the array size is 4, it works correctly.
      ArrayBlockingQueue < String > queue = new ArrayBlockingQueue < String> (3);
      // Code doesn't works if used above constructor.

      //ArrayBlockingQueue < String > queue = new ArrayBlockingQueue < String> (4);
      // Code works if used above constructor.
             
      queue.add("str1");
      queue.add("str2");
      queue.add("str3");
                     
      ArrayList list = new ArrayList();
      list.add("str1");
      list.add("str2");
      System.out.println("status = " + queue.contains("str1"));
      System.out.println(queue.toString());
      /* end of sample test code */

      This is only a backlog bug and added to bugtraq just for tracking purpose.
      It has been fixed.

        Attachments

          Activity

            People

            Assignee:
            martin Martin Buchholz
            Reporter:
            duke J. Duke (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: