Index: jackrabbit-data/src/main/java/org/apache/jackrabbit/core/data/FileDataStore.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- jackrabbit-data/src/main/java/org/apache/jackrabbit/core/data/FileDataStore.java	(revision d41ab68914c47d9939dd4807daec73bf07bbccbc)
+++ jackrabbit-data/src/main/java/org/apache/jackrabbit/core/data/FileDataStore.java	(revision )
@@ -68,11 +68,6 @@
      */
     private static Logger log = LoggerFactory.getLogger(FileDataStore.class);
 
-    /**
-     * The digest algorithm used to uniquely identify records.
-     */
-    private static final String DIGEST = "SHA-1";
-
     /**
      * The default value for the minimum object size.
      */
@@ -163,8 +158,8 @@
     /**
      * Creates a new data record.
      * The stream is first consumed and the contents are saved in a temporary file
-     * and the SHA-1 message digest of the stream is calculated. If a
-     * record with the same SHA-1 digest (and length) is found then it is
+     * and the {@link #DIGEST} message digest of the stream is calculated. If a
+     * record with the same {@link #DIGEST} digest (and length) is found then it is
      * returned. Otherwise the temporary file is moved in place to become
      * the new data record that gets returned.
      *
Index: jackrabbit-data/src/main/java/org/apache/jackrabbit/core/data/db/DbDataStore.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- jackrabbit-data/src/main/java/org/apache/jackrabbit/core/data/db/DbDataStore.java	(revision d41ab68914c47d9939dd4807daec73bf07bbccbc)
+++ jackrabbit-data/src/main/java/org/apache/jackrabbit/core/data/db/DbDataStore.java	(revision )
@@ -125,11 +125,6 @@
      */
     public static final String STORE_SIZE_MAX = "max";
 
-    /**
-     * The digest algorithm used to uniquely identify records.
-     */
-    protected static final String DIGEST = "SHA-1";
-
     /**
      * The prefix used for temporary objects.
      */
Index: jackrabbit-data/src/main/java/org/apache/jackrabbit/core/data/AbstractDataStore.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- jackrabbit-data/src/main/java/org/apache/jackrabbit/core/data/AbstractDataStore.java	(revision d41ab68914c47d9939dd4807daec73bf07bbccbc)
+++ jackrabbit-data/src/main/java/org/apache/jackrabbit/core/data/AbstractDataStore.java	(revision )
@@ -36,6 +36,11 @@
      */
     private static final char[] HEX = "0123456789abcdef".toCharArray();
 
+    /**
+     * The digest algorithm used to uniquely identify records.
+     */
+    protected String DIGEST = System.getProperty("ds.digest.algorithm", "SHA-256");
+
     /**
      * Cached copy of the reference key of this data store. Initialized in
      * {@link #getReferenceKey()} when the key is first accessed.
@@ -138,4 +143,4 @@
         return referenceKey;
     }
 
-}
\ No newline at end of file
+}
Index: jackrabbit-data/src/main/java/org/apache/jackrabbit/core/data/CachingDataStore.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- jackrabbit-data/src/main/java/org/apache/jackrabbit/core/data/CachingDataStore.java	(revision d41ab68914c47d9939dd4807daec73bf07bbccbc)
+++ jackrabbit-data/src/main/java/org/apache/jackrabbit/core/data/CachingDataStore.java	(revision )
@@ -90,11 +90,6 @@
      */
     private static final Logger LOG = LoggerFactory.getLogger(CachingDataStore.class);
 
-    /**
-     * The digest algorithm used to uniquely identify records.
-     */
-    private static final String DIGEST = "SHA-1";
-
     private static final String DS_STORE = ".DS_Store";
 
     /**
@@ -389,9 +384,9 @@
 
     /**
      * Creates a new data record in {@link Backend}. The stream is first
-     * consumed and the contents are saved in a temporary file and the SHA-1
+     * consumed and the contents are saved in a temporary file and the {@link #DIGEST}
      * message digest of the stream is calculated. If a record with the same
-     * SHA-1 digest (and length) is found then it is returned. Otherwise new
+     * {@link #DIGEST} digest (and length) is found then it is returned. Otherwise new
      * record is created in {@link Backend} and the temporary file is moved in
      * place to {@link LocalCache}.
      * 
@@ -423,7 +418,7 @@
             long currTime = System.currentTimeMillis();
             DataIdentifier identifier = new DataIdentifier(
                 encodeHexString(digest.digest()));
-            LOG.debug("SHA1 of [{}], length =[{}] took [{}]ms ",
+            LOG.debug("Digest of [{}], length =[{}] took [{}]ms ",
                 new Object[] { identifier, length, (currTime - startTime) });
             String fileName = getFileName(identifier);
             AsyncUploadCacheResult result = null;
Index: jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/DataStoreTest.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/DataStoreTest.java	(revision d41ab68914c47d9939dd4807daec73bf07bbccbc)
+++ jackrabbit-core/src/test/java/org/apache/jackrabbit/core/data/DataStoreTest.java	(revision )
@@ -24,12 +24,18 @@
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.File;
+import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.OutputStream;
+import java.nio.ByteBuffer;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
 import java.sql.DriverManager;
 import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Random;
 
 /**
@@ -103,14 +109,35 @@
         }
     }
 
+    public static void main(String... args) throws NoSuchAlgorithmException {
+        // create and print a "directory-collision", that is, two byte arrays
+        // where the hash starts with the same bytes
+        // those values can be used for testDeleteRecordWithParentCollision
+        HashMap<Long, Long> map = new HashMap<Long, Long>();
+        MessageDigest digest = MessageDigest.getInstance("SHA-256");
+        ByteBuffer input = ByteBuffer.allocate(8);
+        byte[] array = input.array();
+        for(long x = 0;; x++) {
+            input.putLong(x).flip();
+            long h = ByteBuffer.wrap(digest.digest(array)).getLong();
+            Long old = map.put(h & 0xffffffffff000000L, x);
+            if (old != null) {
+                System.out.println(Long.toHexString(old) + " " + Long.toHexString(x));
+                break;
+            }
+        }
+    }
+
     public void testDeleteRecordWithParentCollision() throws Exception {
         FileDataStore fds = new FileDataStore();
         fds.init(testDir + "/fileDeleteCollision");
 
-        String c1 = "06b2f82fd81b2c20";
-        String c2 = "02c60cb75083ceef";
-        DataRecord d1 = fds.addRecord(IOUtils.toInputStream(c1));
-        DataRecord d2 = fds.addRecord(IOUtils.toInputStream(c2));
+        ByteArrayInputStream c1 = new ByteArrayInputStream(ByteBuffer
+                .allocate(8).putLong(0x181c7).array());
+        ByteArrayInputStream c2 = new ByteArrayInputStream(ByteBuffer
+                .allocate(8).putLong(0x11fd78).array());
+        DataRecord d1 = fds.addRecord(c1);
+        DataRecord d2 = fds.addRecord(c2);
         fds.deleteRecord(d1.getIdentifier());
         DataRecord testRecord = fds.getRecordIfStored(d2.getIdentifier());
 
