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

Default implementation of Destroyable.destroy should not throw exception

XMLWordPrintable

      A DESCRIPTION OF THE PROBLEM :
      The default implementation of javax.security.auth.Destroyable implements
      - isDestroyed() to return false
      - destroy() to throw an exception

      This is a very awkward combination because it prevents writing code which handles Destroyables in general. The user whould need to know what kind of Destroyable they are dealing with before trying to destroy it.

      For example when using the following:

      if (!destroyable.isDestroyed()) {
          destroyable.destroy();
      }

      When an DestroyFailedException is thrown the reason could be that the class does not override the Destroyable methods. In this case there is nothing the caller can do to handle this correctly. They have to treat it as destruction failure even though it isn't one.


            mullan Sean Mullan
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: