mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Jean-Noel Rouvignac
03.17.2015 12300e9ede17e7c8b1e35436b88565b285c3fb70
OPENDJ-1762 (CR-5923) verify-index on non existing index fails with NullPointerException when the server is stopped

Verifying a non existing index triggers some untested unhappy paths.
Faulty exception handling was creating the issue.


PersistItStorage.java:
In read(), only throw the cause if there is a cause.

VerifyJob.java:
Do not wrap StorageRuntimeException inside StorageRuntimeException.

BackendImpl.java:
Chain the original exception.
3 files modified
18 ■■■■ changed files
opendj3-server-dev/src/server/org/opends/server/backends/persistit/PersistItStorage.java 12 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/backends/pluggable/BackendImpl.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/backends/pluggable/VerifyJob.java 4 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/backends/persistit/PersistItStorage.java
@@ -592,7 +592,11 @@
        }
        catch (final StorageRuntimeException e)
        {
          throw (Exception) e.getCause();
          if (e.getCause() != null)
          {
              throw (Exception) e.getCause();
          }
          throw e;
        }
        finally
        {
@@ -655,7 +659,11 @@
        }
        catch (final StorageRuntimeException e)
        {
          throw (Exception) e.getCause();
          if (e.getCause() != null)
          {
              throw (Exception) e.getCause();
          }
          throw e;
        }
        finally
        {
opendj3-server-dev/src/server/org/opends/server/backends/pluggable/BackendImpl.java
@@ -947,7 +947,7 @@
      {
        return new DirectoryException(
            DirectoryServer.getServerErrorResultCode(),
            LocalizableMessage.raw(e.getMessage()));
            LocalizableMessage.raw(e.getMessage()), e);
      }
    }
    if (/*e instanceof EnvironmentFailureException && */ !rootContainer.isValid()) {
opendj3-server-dev/src/server/org/opends/server/backends/pluggable/VerifyJob.java
@@ -150,6 +150,10 @@
        }
      });
    }
    catch (StorageRuntimeException e)
    {
      throw e;
    }
    catch (Exception e)
    {
      throw new StorageRuntimeException(e);