-
Bug
-
Resolution: Unresolved
-
P4
-
6u43
-
None
FULL PRODUCT VERSION :
java version " 1.6.0_43 "
Java(TM) SE Runtime Environment (build 1.6.0_43-b01)
Java HotSpot(TM) 64-Bit Server VM (build 20.14-b01, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux hilbert 3.8.0-19-generic #30-Ubuntu SMP Wed May 1 16:35:23 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
EXTRA RELEVANT SYSTEM CONFIGURATION :
Standard linux install
A DESCRIPTION OF THE PROBLEM :
My read of the JavaDoc says that a BlockingQueue only throws an InterruptedException if the thread is waiting:
" InterruptedException - if interrupted while waiting " yet it seems like it always throws an interrupt even if it is not waiting (i.e. the queue is not empty).
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
public static void main(final String[] args) throws InterruptedException {
BlockingQueue<Integer> bg = new LinkedBlockingQueue<Integer>(2);
bg.add(1);
Thread.currentThread().interrupt();
System.out.println(bg.take()); //Should work
System.out.println( " YAY " );
System.out.println(bg.take()); //Should fail
}
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Should see YAY
ACTUAL -
InterruptedException
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class Test {
public static void main(final String[] args) throws InterruptedException {
BlockingQueue<Integer> bg = new LinkedBlockingQueue<Integer>(2);
bg.add(1);
Thread.currentThread().interrupt();
System.out.println(bg.take()); //Should work
System.out.println(bg.take()); //Should fail
}
}
---------- END SOURCE ----------
java version " 1.6.0_43 "
Java(TM) SE Runtime Environment (build 1.6.0_43-b01)
Java HotSpot(TM) 64-Bit Server VM (build 20.14-b01, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux hilbert 3.8.0-19-generic #30-Ubuntu SMP Wed May 1 16:35:23 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
EXTRA RELEVANT SYSTEM CONFIGURATION :
Standard linux install
A DESCRIPTION OF THE PROBLEM :
My read of the JavaDoc says that a BlockingQueue only throws an InterruptedException if the thread is waiting:
" InterruptedException - if interrupted while waiting " yet it seems like it always throws an interrupt even if it is not waiting (i.e. the queue is not empty).
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
public static void main(final String[] args) throws InterruptedException {
BlockingQueue<Integer> bg = new LinkedBlockingQueue<Integer>(2);
bg.add(1);
Thread.currentThread().interrupt();
System.out.println(bg.take()); //Should work
System.out.println( " YAY " );
System.out.println(bg.take()); //Should fail
}
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Should see YAY
ACTUAL -
InterruptedException
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class Test {
public static void main(final String[] args) throws InterruptedException {
BlockingQueue<Integer> bg = new LinkedBlockingQueue<Integer>(2);
bg.add(1);
Thread.currentThread().interrupt();
System.out.println(bg.take()); //Should work
System.out.println(bg.take()); //Should fail
}
}
---------- END SOURCE ----------
- duplicates
-
JDK-8019368 ArrayBlockingQueue.poll can violate BlockingQueue's contract on throws Interrupt
-
- Closed
-