jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r964365 - in /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data: FileDataStore.java GarbageCollector.java
Date Thu, 15 Jul 2010 10:12:07 GMT
Author: thomasm
Date: Thu Jul 15 10:12:07 2010
New Revision: 964365

URL: http://svn.apache.org/viewvc?rev=964365&view=rev
Log:
JCR-2674 FileDataStore ignores return code from setLastModified

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/FileDataStore.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/GarbageCollector.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/FileDataStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/FileDataStore.java?rev=964365&r1=964364&r2=964365&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/FileDataStore.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/FileDataStore.java
Thu Jul 15 10:12:07 2010
@@ -116,13 +116,6 @@ public class FileDataStore implements Da
         Collections.synchronizedMap(new WeakHashMap<DataIdentifier, WeakReference<DataIdentifier>>());
 
     /**
-     * Creates a uninitialized data store.
-     *
-     */
-    public FileDataStore() {
-    }
-
-    /**
      * Initialized the data store.
      * If the path is not set, &lt;repository home&gt;/repository/datastore is used.
      * This directory is automatically created if it does not yet exist.
@@ -137,10 +130,7 @@ public class FileDataStore implements Da
         directory.mkdirs();
     }
 
-    /**
-     * {@inheritDoc}
-     */
-    public DataRecord getRecordIfStored(DataIdentifier identifier) {
+    public DataRecord getRecordIfStored(DataIdentifier identifier) throws DataStoreException
{
         File file = getFile(identifier);
         synchronized (this) {
             if (!file.exists()) {
@@ -148,7 +138,10 @@ public class FileDataStore implements Da
             }
             if (minModifiedDate != 0 && file.canWrite()) {
                 if (file.lastModified() < minModifiedDate) {
-                    file.setLastModified(System.currentTimeMillis() + ACCESS_TIME_RESOLUTION);
+                	    // The current GC approach depends on this call succeeding
+                    if (!file.setLastModified(System.currentTimeMillis() + ACCESS_TIME_RESOLUTION))
{
+                        throw new DataStoreException("Failed to update record modified date:
" + identifier);
+                    }
                 }
             }
             usesIdentifier(identifier);
@@ -228,8 +221,13 @@ public class FileDataStore implements Da
                     }
                 } else {
                     long now = System.currentTimeMillis();
-                    if (file.lastModified() < now) {
-                        file.setLastModified(now);
+                    if (file.lastModified() < now + ACCESS_TIME_RESOLUTION) {
+                        // The current GC approach depends on this call succeeding (for writable
files)
+                        if (!file.setLastModified(now + ACCESS_TIME_RESOLUTION)) {
+                            if (file.canWrite()) {
+                                throw new DataStoreException("Failed to update record modified
date: " + identifier);
+                            }
+                        }
                     }
                 }
                 // Sanity checks on the record file. These should never fail,
@@ -289,16 +287,10 @@ public class FileDataStore implements Da
         return File.createTempFile(TMP, null, directory);
     }
 
-    /**
-     * {@inheritDoc}
-     */
     public void updateModifiedDateOnAccess(long before) {
         minModifiedDate = before;
     }
 
-    /**
-     * {@inheritDoc}
-     */
     public int deleteAllOlderThan(long min) {
         return deleteOlderRecursive(directory, min);
     }
@@ -350,9 +342,6 @@ public class FileDataStore implements Da
         }
     }
 
-    /**
-     * {@inheritDoc}
-     */
     public Iterator<DataIdentifier> getAllIdentifiers() {
         ArrayList<File> files = new ArrayList<File>();
         listRecursive(files, directory);
@@ -367,9 +356,6 @@ public class FileDataStore implements Da
         return identifiers.iterator();
     }
 
-    /**
-     * {@inheritDoc}
-     */
     public void clearInUse() {
         inUse.clear();
     }
@@ -392,9 +378,6 @@ public class FileDataStore implements Da
         this.path = directoryName;
     }
 
-    /**
-     * {@inheritDoc}
-     */
     public int getMinRecordLength() {
         return minRecordLength;
     }
@@ -408,10 +391,8 @@ public class FileDataStore implements Da
         this.minRecordLength = minRecordLength;
     }
 
-    /**
-     * {@inheritDoc}
-     */
     public void close() {
+        // nothing to do
     }
 
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/GarbageCollector.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/GarbageCollector.java?rev=964365&r1=964364&r2=964365&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/GarbageCollector.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/GarbageCollector.java
Thu Jul 15 10:12:07 2010
@@ -82,7 +82,7 @@ public class GarbageCollector implements
 
     private long sleepBetweenNodes;
 
-    private int testDelay;
+    protected int testDelay;
 
     private final DataStore store;
 
@@ -268,7 +268,7 @@ public class GarbageCollector implements
         return store;
     }
 
-    private void recurse(final Node n, long sleep) throws RepositoryException {
+    void recurse(final Node n, long sleep) throws RepositoryException {
         if (sleep > 0) {
             try {
                 Thread.sleep(sleep);
@@ -290,9 +290,9 @@ public class GarbageCollector implements
                             rememberNode(n.getPath());
                         }
                         if (p.isMultiple()) {
-                            p.getLengths();
+                            checkLengths(p.getLengths());
                         } else {
-                            p.getLength();
+                        	checkLengths(p.getLength());
                         }
                     }
                 } catch (InvalidItemStateException e) {
@@ -347,6 +347,14 @@ public class GarbageCollector implements
          */
     }
 
+    private void checkLengths(long... lengths) throws RepositoryException {
+        for (long length : lengths) {
+            if (length == -1) {
+                throw new RepositoryException("mark failed to access a property");
+            }
+        }
+    }
+
     public void close() {
         if (!closed.getAndSet(true)) {
             try {



Mime
View raw message