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

Numeric overflow of j.u.c.semaphore permits doesn't throw an exception

XMLWordPrintable

      The following core doesn't throw an Error as expected:

      import java.util.concurrent.Semaphore;

      public class PermitOverflow {

          public static void main(String[] args) throws Throwable {
              for (boolean fair : new boolean[] { true, false }) {
                  Semaphore sem = new Semaphore(Integer.MAX_VALUE - 1, fair);
                  if (sem.availablePermits() != Integer.MAX_VALUE - 1)
                      throw new RuntimeException();
                  try {
                      sem.release(2);
                  } catch (Error expected) {
                  }
      ...
      }

            Unassigned Unassigned
            kshiroko Kirill Shirokov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: