-
Bug
-
Resolution: Fixed
-
P4
-
6u19
-
b89
-
x86
-
windows_xp
FULL PRODUCT VERSION :
java version "1.6.0_19"
Java(TM) SE Runtime Environment (build 1.6.0_19-b04)
Java HotSpot(TM) 64-Bit Server VM (build 16.2-b04, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7600]
A DESCRIPTION OF THE PROBLEM :
I was enountering a hang in some code and it turned out that it was occuring on a call to Semaphore.acquire(). This occurs when you release past Integer.MAX_VALUE permits. I was able to put together a small script that reproduces the problem. I realize that this may not be the intended usage, and it's probably an edge condition, but, In my opinion, if Semaphore cannot handle releasing past that value, it should inform the user by throwing an exception.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the attached code.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Semaphore constructed
Semaphore released
Semaphore released again
Semaphore acquired
ACTUAL -
Semaphore constructed
Semaphore released
Semaphore released again
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.util.concurrent.Semaphore;
class SemaphoreTest {
public static void main(final String[] args) {
Semaphore semaphore = new Semaphore(Integer.MAX_VALUE);
System.out.println("Semaphore constructed");
semaphore.release();
System.out.println("Semaphore released");
semaphore.release();
System.out.println("Semaphore released again");
try {
semaphore.acquire();
} catch (Throwable e) {
System.out.println("Exception encountered");
e.printStackTrace();
}
System.out.println("Semaphore acquired");
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Don't release past Integer.MAX_VALUE...
java version "1.6.0_19"
Java(TM) SE Runtime Environment (build 1.6.0_19-b04)
Java HotSpot(TM) 64-Bit Server VM (build 16.2-b04, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7600]
A DESCRIPTION OF THE PROBLEM :
I was enountering a hang in some code and it turned out that it was occuring on a call to Semaphore.acquire(). This occurs when you release past Integer.MAX_VALUE permits. I was able to put together a small script that reproduces the problem. I realize that this may not be the intended usage, and it's probably an edge condition, but, In my opinion, if Semaphore cannot handle releasing past that value, it should inform the user by throwing an exception.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the attached code.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Semaphore constructed
Semaphore released
Semaphore released again
Semaphore acquired
ACTUAL -
Semaphore constructed
Semaphore released
Semaphore released again
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.util.concurrent.Semaphore;
class SemaphoreTest {
public static void main(final String[] args) {
Semaphore semaphore = new Semaphore(Integer.MAX_VALUE);
System.out.println("Semaphore constructed");
semaphore.release();
System.out.println("Semaphore released");
semaphore.release();
System.out.println("Semaphore released again");
try {
semaphore.acquire();
} catch (Throwable e) {
System.out.println("Exception encountered");
e.printStackTrace();
}
System.out.println("Semaphore acquired");
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Don't release past Integer.MAX_VALUE...
- relates to
-
JDK-6945187 Numeric overflow of j.u.c.semaphore permits doesn't throw an exception
-
- Closed
-