You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by gt...@apache.org on 2009/11/05 17:30:20 UTC

svn commit: r833074 - /activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/async/DataFile.java

Author: gtully
Date: Thu Nov  5 16:29:47 2009
New Revision: 833074

URL: http://svn.apache.org/viewvc?rev=833074&view=rev
Log:
resolve https://issues.apache.org/activemq/browse/AMQ-2478 - patch applied with thanks. test case works with the new kahaDB also, it is a little neater w.r.t exception handling

Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/async/DataFile.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/async/DataFile.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/async/DataFile.java?rev=833074&r1=833073&r2=833074&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/async/DataFile.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/async/DataFile.java Thu Nov  5 16:29:47 2009
@@ -88,10 +88,19 @@
     public synchronized RandomAccessFile openRandomAccessFile(boolean appender) throws IOException {
         RandomAccessFile rc = new RandomAccessFile(file, "rw");
         // When we start to write files size them up so that the OS has a chance
-        // to allocate the file contigously.
+        // to allocate the file contiguously.
         if (appender) {
             if (length < preferedSize) {
-                rc.setLength(preferedSize);
+                try {
+                    // this can throw if we run out of disk space
+                    rc.setLength(preferedSize);
+                } catch (IOException ioe) {            
+                    try {
+                        rc.close();
+                    } catch(Exception ignored) {
+                    }
+                    throw ioe;
+                }
             }
         }
         return rc;