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

LinkedBlockingQueue.extract throws NPE

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 6
    • 5.0
    • core-libs
    • b51
    • x86
    • windows_xp
    • Verified

        FULL PRODUCT VERSION :
        java version "1.5.0"
        Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
        Java HotSpot(TM) Client VM (build 1.5.0-b64, mixed mode, sharing)

        ADDITIONAL OS VERSION INFORMATION :
        windows XP sp1

        A DESCRIPTION OF THE PROBLEM :
        public class TaskPool {
            public static void main( String[] args ) throws InterruptedException {
                LinkedBlockingQueue lbq = new LinkedBlockingQueue();
                Integer one = 1;
                Integer two = 2;
                Integer three = 3;
                lbq.put(one);
                lbq.put(two);
                lbq.remove(one);
                lbq.remove(two);
                lbq.put(three);
                System.out.println(lbq.take());
            }
        }

        java TaskPool

        Exception in thread "main" java.lang.NullPointerException

            at java.util.concurrent.LinkedBlockingQueue.extract(Unknown Source)
            at java.util.concurrent.LinkedBlockingQueue.take(Unknown Source)
            at TaskPool.main(TaskPool.java:23)

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        java TaskPool

        ACTUAL -
        Exception in thread "main" java.lang.NullPointerException

            at java.util.concurrent.LinkedBlockingQueue.extract(Unknown Source)
            at java.util.concurrent.LinkedBlockingQueue.take(Unknown Source)
            at TaskPool.main(TaskPool.java:23)

        ERROR MESSAGES/STACK TRACES THAT OCCUR :
        Exception in thread "main" java.lang.NullPointerException

            at java.util.concurrent.LinkedBlockingQueue.extract(Unknown Source)
            at java.util.concurrent.LinkedBlockingQueue.take(Unknown Source)
            at TaskPool.main(TaskPool.java:23)

        REPRODUCIBILITY :
        This bug can be reproduced always.

        ---------- BEGIN SOURCE ----------
        import java.util.concurrent.LinkedBlockingQueue;

        public class TaskPool {
            public static void main( String[] args ) throws InterruptedException {
                LinkedBlockingQueue lbq = new LinkedBlockingQueue();
                Integer one = 1;
                Integer two = 2;
                Integer three = 3;
                lbq.put(one);
                lbq.put(two);
                lbq.remove(one);
                lbq.remove(two);
                lbq.put(three);
                System.out.println(lbq.take());
            }
        }
        ---------- END SOURCE ----------
        ###@###.### 2005-1-10 12:08:56 GMT

              martin Martin Buchholz
              jssunw Jitender S (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: