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

AQS should not handle RuntimeException during acquire specially

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 7
    • 6
    • core-libs
    • b06
    • generic
    • generic
    • Verified

      AbstractQueuedSynchronizer and AbstractQueuedLongSynchronizer
      handle exceptions during acquire like this

      try { ... }
      catch (RuntimeException e) { handle(); throw e; }

      This fails to handle errors or other pathological throwables
      (e.g. a checked Exception can always be thrown using Thread.stop(Throwable))

      More robust and clear is to use the idiom

      boolean failed = true;
      try { ... ; failed = false; }
      finally { if (failed) handle(); }

            martin Martin Buchholz
            martin Martin Buchholz
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: