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

Jean-Noel Rouvignac
27.27.2015 8b1a3529580def922b2188a998fdebb65c756de0
opendj3-server-dev/src/server/org/opends/server/backends/persistit/PersistItStorage.java
@@ -267,13 +267,13 @@
    }
    @Override
    public void delete(final TreeName treeName, final ByteSequence key)
    public boolean delete(final TreeName treeName, final ByteSequence key)
    {
      try
      {
        final Exchange ex = getExchangeFromCache(treeName);
        bytesToKey(ex.getKey(), key);
        ex.remove();
        return ex.remove();
      }
      catch (final PersistitException e)
      {
@@ -388,21 +388,6 @@
    }
    @Override
    public boolean remove(final TreeName treeName, final ByteSequence key)
    {
      try
      {
        final Exchange ex = getExchangeFromCache(treeName);
        bytesToKey(ex.getKey(), key);
        return ex.remove();
      }
      catch (final PersistitException e)
      {
        throw new StorageRuntimeException(e);
      }
    }
    @Override
    public void renameTree(final TreeName oldTreeName,
        final TreeName newTreeName)
    {
@@ -423,8 +408,7 @@
    }
    @Override
    public void update(final TreeName treeName, final ByteSequence key,
        final UpdateFunction f)
    public boolean update(final TreeName treeName, final ByteSequence key, final UpdateFunction f)
    {
      try
      {
@@ -433,8 +417,13 @@
        ex.fetch();
        final ByteSequence oldValue = valueToBytes(ex.getValue());
        final ByteSequence newValue = f.computeNewValue(oldValue);
        ex.getValue().clear().putByteArray(newValue.toByteArray());
        ex.store();
        if (!equals(newValue, oldValue))
        {
          ex.getValue().clear().putByteArray(newValue.toByteArray());
          ex.store();
          return true;
        }
        return false;
      }
      catch (final Exception e)
      {
@@ -442,6 +431,15 @@
      }
    }
    private boolean equals(ByteSequence b1, ByteSequence b2)
    {
      if (b1 == null)
      {
        return b2 == null;
      }
      return b1.equals(b2);
    }
    private Exchange getExchangeFromCache(final TreeName treeName)
        throws PersistitException
    {