Index: src/test/java/org/apache/commons/compress/archivers/TarTestCase.java
===================================================================
--- src/test/java/org/apache/commons/compress/archivers/TarTestCase.java	(revision 1625774)
+++ src/test/java/org/apache/commons/compress/archivers/TarTestCase.java	(working copy)
@@ -18,19 +18,26 @@
  */
 package org.apache.commons.compress.archivers;
 
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.security.MessageDigest;
+import java.util.Date;
 
+import javax.xml.bind.DatatypeConverter;
+
 import org.apache.commons.compress.AbstractTestCase;
 import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
 import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
 import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream;
 import org.apache.commons.compress.utils.CharsetNames;
 import org.apache.commons.compress.utils.IOUtils;
+import org.junit.Assert;
 
 public final class TarTestCase extends AbstractTestCase {
     public void testTarArchiveCreation() throws Exception {
@@ -104,6 +111,58 @@
         }
     }
 
+    /**
+     * When using long file names the longLinkEntry included the current timestamp as the Entry modification date. This was
+     * never exposed to the client but it caused identical archives to have different MD5 hashes.
+     *  
+     * @throws Exception
+     */
+    public void testLongNameMd5Hash() throws Exception {
+          final String longFileName = "a/considerably/longer/file/name/which/forces/use/of/the/long/link/header/which/appears/to/always/use/the/current/time/as/modification/date";
+          String fname = longFileName;
+          final Date modificationDate = new Date();
+       
+          byte[] archive1 = createTarArchiveContainingOneDirectory(fname, modificationDate);        
+          String digest1 = DatatypeConverter.printHexBinary(MessageDigest.getInstance("MD5").digest(archive1));
+         
+          // let a second elapse otherwise the modification dates will be equal
+          Thread.sleep(1000L);
+         
+          // now recreate exactly the same tar file
+          byte[] archive2 = createTarArchiveContainingOneDirectory(fname, modificationDate);        
+          // end I would expect the MD5 hash to be the same, but for long names it isn't
+          String digest2 = DatatypeConverter.printHexBinary(MessageDigest.getInstance("MD5").digest(archive2));
+
+          Assert.assertEquals(digest1, digest2);
+        
+          // do I still have the correct modification date?
+          // let a second elapse so we don't get the current time
+          Thread.sleep(1000);
+          TarArchiveInputStream tarIn = new TarArchiveInputStream(new ByteArrayInputStream(archive2));
+          ArchiveEntry nextEntry = tarIn.getNextEntry();
+          Assert.assertEquals(longFileName, nextEntry.getName());
+          // tar archive stores modification time to second granularity only (floored)
+          Assert.assertEquals(modificationDate.getTime() / 1000, nextEntry.getLastModifiedDate().getTime() / 1000);
+          // yes, yes, should be in final block, but I can't be bothered with pre-7 resource handling any more
+          tarIn.close();
+    }
+
+    private static byte[] createTarArchiveContainingOneDirectory(String fname, Date modificationDate) throws IOException {
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        TarArchiveOutputStream tarOut = new TarArchiveOutputStream(baos, 1024);
+        tarOut.setLongFileMode(TarArchiveOutputStream.LONGFILE_GNU);
+        TarArchiveEntry tarEntry = new TarArchiveEntry("d");
+        tarEntry.setModTime(modificationDate);
+        tarEntry.setMode(TarArchiveEntry.DEFAULT_DIR_MODE);
+        tarEntry.setModTime(modificationDate.getTime());
+        tarEntry.setName(fname);
+        tarOut.putArchiveEntry(tarEntry);
+        tarOut.closeArchiveEntry();
+        tarOut.close();
+     
+        return baos.toByteArray();
+    }
+    
     public void testTarUnarchive() throws Exception {
         final File input = getFile("bla.tar");
         final InputStream is = new FileInputStream(input);
