jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r632232 - in /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core: ./ config/ fs/ fs/db/ fs/mem/ lock/ nodetype/ persistence/bundle/ persistence/bundle/util/ persistence/db/ persistence/util/ persistence/xml/ query/luc...
Date Fri, 29 Feb 2008 06:39:16 GMT
Author: jukka
Date: Thu Feb 28 22:39:11 2008
New Revision: 632232

URL: http://svn.apache.org/viewvc?rev=632232&view=rev
Log:
JCR-1395: Use Commons IO 1.4
    - Use IOUtils.closeQuietly to simplify code
    - Note that I prefer not to eat exceptions like this,
      but that's a functional change that should be handled
      in another issue

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/RepositoryConfig.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/FileSystemResource.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/db/DatabaseFileSystem.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/db/OracleFileSystem.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/mem/MemoryFileSystem.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeRegistry.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleDbPersistenceManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleFsPersistenceManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/BundleBinding.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/db/DatabasePersistenceManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/db/OraclePersistenceManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/Serializer.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/xml/XMLPersistenceManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NodeIndexer.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/TextExtractorJob.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/BLOBFileValue.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/BLOBInTempFile.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/InternalValue.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java?rev=632232&r1=632231&r2=632232&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
Thu Feb 28 22:39:11 2008
@@ -21,6 +21,7 @@
 import EDU.oswego.cs.dl.util.concurrent.ReentrantWriterPreferenceReadWriteLock;
 import EDU.oswego.cs.dl.util.concurrent.WriterPreferenceReadWriteLock;
 import org.apache.commons.collections.map.ReferenceMap;
+import org.apache.commons.io.IOUtils;
 import org.apache.jackrabbit.api.JackrabbitRepository;
 import org.apache.jackrabbit.commons.AbstractRepository;
 import org.apache.jackrabbit.core.cluster.ClusterContext;
@@ -455,11 +456,7 @@
                     try {
                         reader.read(chars);
                     } finally {
-                        try {
-                            reader.close();
-                        } catch (IOException ioe) {
-                            // ignore
-                        }
+                        IOUtils.closeQuietly(reader);
                     }
                     return NodeId.valueOf(new String(chars));
                 } catch (Exception e) {
@@ -499,11 +496,7 @@
                     try {
                         writer.write(ROOT_NODE_ID.toString());
                     } finally {
-                        try {
-                            writer.close();
-                        } catch (IOException ioe) {
-                            // ignore
-                        }
+                        IOUtils.closeQuietly(writer);
                     }
                     return ROOT_NODE_ID;
                 } catch (Exception e) {

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/RepositoryConfig.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/RepositoryConfig.java?rev=632232&r1=632231&r2=632232&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/RepositoryConfig.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/config/RepositoryConfig.java
Thu Feb 28 22:39:11 2008
@@ -16,6 +16,7 @@
  */
 package org.apache.jackrabbit.core.config;
 
+import org.apache.commons.io.IOUtils;
 import org.apache.jackrabbit.core.fs.FileSystem;
 import org.apache.jackrabbit.core.fs.FileSystemException;
 import org.apache.jackrabbit.core.fs.FileSystemPathUtil;
@@ -419,12 +420,7 @@
         } catch (FileSystemException e) {
             throw new ConfigurationException("Failed to load workspace configuration", e);
         } finally {
-            if (configReader != null) {
-                try {
-                    configReader.close();
-                } catch (IOException ignore) {
-                }
-            }
+            IOUtils.closeQuietly(configReader);
         }
     }
 
@@ -540,10 +536,7 @@
                 throw new ConfigurationException(
                         "Cannot create a workspace configuration file", e);
             } finally {
-                try {
-                    configWriter.close();
-                } catch (IOException ignore) {
-                }
+                IOUtils.closeQuietly(configWriter);
             }
 
             // Load the created workspace configuration.

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/FileSystemResource.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/FileSystemResource.java?rev=632232&r1=632231&r2=632232&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/FileSystemResource.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/FileSystemResource.java
Thu Feb 28 22:39:11 2008
@@ -20,6 +20,8 @@
 import java.io.InputStream;
 import java.io.OutputStream;
 
+import org.apache.commons.io.IOUtils;
+
 /**
  * A <code>FileSystemResource</code> represents a resource (i.e. file) in a
  * <code>FileSystem</code>.
@@ -165,10 +167,7 @@
                 out.write(buffer, 0, read);
             }
         } finally {
-            try {
-                in.close();
-            } catch (IOException ioe) {
-            }
+            IOUtils.closeQuietly(in);
         }
     }
 

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/db/DatabaseFileSystem.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/db/DatabaseFileSystem.java?rev=632232&r1=632231&r2=632232&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/db/DatabaseFileSystem.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/db/DatabaseFileSystem.java
Thu Feb 28 22:39:11 2008
@@ -16,6 +16,7 @@
  */
 package org.apache.jackrabbit.core.fs.db;
 
+import org.apache.commons.io.IOUtils;
 import org.apache.jackrabbit.core.fs.FileSystem;
 import org.apache.jackrabbit.core.fs.FileSystemException;
 import org.apache.jackrabbit.core.fs.FileSystemPathUtil;
@@ -1186,7 +1187,7 @@
                     sql = reader.readLine();
                 }
             } finally {
-                closeStream(in);
+                IOUtils.closeQuietly(in);
                 closeStatement(stmt);
             }
         }
@@ -1509,16 +1510,6 @@
                 rs.close();
             } catch (SQLException se) {
                 log.error("failed closing ResultSet", se);
-            }
-        }
-    }
-
-    protected void closeStream(InputStream in) {
-        if (in != null) {
-            try {
-                in.close();
-            } catch (IOException ignore) {
-                // ignore
             }
         }
     }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/db/OracleFileSystem.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/db/OracleFileSystem.java?rev=632232&r1=632231&r2=632232&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/db/OracleFileSystem.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/db/OracleFileSystem.java
Thu Feb 28 22:39:11 2008
@@ -16,6 +16,7 @@
  */
 package org.apache.jackrabbit.core.fs.db;
 
+import org.apache.commons.io.IOUtils;
 import org.apache.jackrabbit.util.Text;
 import org.apache.jackrabbit.util.TransientFileFactory;
 import org.apache.jackrabbit.core.fs.FileSystemException;
@@ -215,7 +216,7 @@
                     sql = reader.readLine();
                 }
             } finally {
-                closeStream(in);
+                IOUtils.closeQuietly(in);
                 closeStatement(stmt);
             }
         }
@@ -408,12 +409,7 @@
                             } catch (Exception e1) {
                             }
                         }
-                        if (in != null) {
-                            try {
-                                in.close();
-                            } catch (Exception e1) {
-                            }
-                        }
+                        IOUtils.closeQuietly(in);
                         // temp file can now safely be removed
                         tmpFile.delete();
                     }
@@ -521,12 +517,7 @@
                             } catch (Exception e1) {
                             }
                         }
-                        if (in != null) {
-                            try {
-                                in.close();
-                            } catch (Exception e1) {
-                            }
-                        }
+                        IOUtils.closeQuietly(in);
                         // temp file can now safely be removed
                         tmpFile.delete();
                     }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/mem/MemoryFileSystem.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/mem/MemoryFileSystem.java?rev=632232&r1=632231&r2=632232&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/mem/MemoryFileSystem.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/fs/mem/MemoryFileSystem.java
Thu Feb 28 22:39:11 2008
@@ -28,6 +28,7 @@
 import java.util.Map;
 import java.util.Set;
 
+import org.apache.commons.io.IOUtils;
 import org.apache.jackrabbit.core.fs.FileSystem;
 import org.apache.jackrabbit.core.fs.FileSystemException;
 import org.apache.jackrabbit.core.fs.RandomAccessOutputStream;
@@ -49,11 +50,7 @@
         } catch (IOException e) {
             throw new FileSystemException(e.getMessage(), e);
         } finally {
-            try {
-                destinationOutputStream.close();
-            } catch (IOException e) {
-                // ignore
-            }
+            IOUtils.closeQuietly(destinationOutputStream);
         }
     }
 

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java?rev=632232&r1=632231&r2=632232&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/lock/LockManagerImpl.java
Thu Feb 28 22:39:11 2008
@@ -18,6 +18,7 @@
 
 import EDU.oswego.cs.dl.util.concurrent.ReentrantLock;
 import org.apache.commons.collections.map.LinkedMap;
+import org.apache.commons.io.IOUtils;
 import org.apache.jackrabbit.spi.commons.conversion.MalformedPathException;
 import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
 import org.apache.jackrabbit.core.ItemId;
@@ -163,13 +164,7 @@
         } catch (IOException e) {
             throw new FileSystemException("error while reading locks file", e);
         } finally {
-            if (reader != null) {
-                try {
-                    reader.close();
-                } catch (IOException e2) {
-                    /* ignore */
-                }
-            }
+            IOUtils.closeQuietly(reader);
         }
     }
 
@@ -235,13 +230,7 @@
                     + locksFile.getPath() + "': " + ioe.getMessage());
             log.debug("Root cause: ", ioe);
         } finally {
-            if (writer != null) {
-                try {
-                    writer.close();
-                } catch (IOException e) {
-                    // ignore
-                }
-            }
+            IOUtils.closeQuietly(writer);
         }
     }
 

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeRegistry.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeRegistry.java?rev=632232&r1=632231&r2=632232&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeRegistry.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/NodeTypeRegistry.java
Thu Feb 28 22:39:11 2008
@@ -18,6 +18,7 @@
 
 import EDU.oswego.cs.dl.util.concurrent.ConcurrentReaderHashMap;
 import org.apache.commons.collections.map.ReferenceMap;
+import org.apache.commons.io.IOUtils;
 import org.apache.jackrabbit.core.cluster.NodeTypeEventChannel;
 import org.apache.jackrabbit.core.cluster.NodeTypeEventListener;
 import org.apache.jackrabbit.core.fs.FileSystem;
@@ -800,13 +801,7 @@
             log.debug(error);
             throw new RepositoryException(error, intde);
         } finally {
-            if (in != null) {
-                try {
-                    in.close();
-                } catch (IOException ioe) {
-                    // ignore
-                }
-            }
+            IOUtils.closeQuietly(in);
         }
     }
 

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleDbPersistenceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleDbPersistenceManager.java?rev=632232&r1=632231&r2=632232&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleDbPersistenceManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleDbPersistenceManager.java
Thu Feb 28 22:39:11 2008
@@ -18,6 +18,7 @@
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.apache.commons.io.IOUtils;
 import org.apache.jackrabbit.util.Text;
 import org.apache.jackrabbit.core.state.ChangeLog;
 import org.apache.jackrabbit.core.state.ItemStateException;
@@ -443,11 +444,7 @@
                 log.debug(msg);
                 throw new RepositoryException(msg, e);
             } finally {
-                try {
-                    in.close();
-                } catch (IOException e) {
-                    // ignore
-                }
+                IOUtils.closeQuietly(in);
                 stmt.close();
             }
         }
@@ -762,7 +759,7 @@
         } catch (Exception e) {
             log.error("Error in bundle", e);
         } finally {
-            closeStream(din);
+            IOUtils.closeQuietly(din);
             closeResultSet(rs);
         }
 
@@ -993,7 +990,7 @@
             log.error(msg);
             throw new ItemStateException(msg, e);
         } finally {
-            closeStream(in);
+            IOUtils.closeQuietly(in);
             closeResultSet(rs);
         }
     }
@@ -1085,7 +1082,7 @@
             log.error(msg, e);
             throw new ItemStateException(msg, e);
         } finally {
-            closeStream(in);
+            IOUtils.closeQuietly(in);
             closeResultSet(rs);
         }
     }
@@ -1201,20 +1198,6 @@
                 rs.close();
             } catch (SQLException se) {
                 logException("Failed closing ResultSet", se);
-            }
-        }
-    }
-
-    /**
-     * closes the input stream
-     * @param ins the input stream
-     */
-    protected void closeStream(InputStream ins) {
-        if (ins != null) {
-            try {
-                ins.close();
-            } catch (IOException ignore) {
-                // ignore
             }
         }
     }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleFsPersistenceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleFsPersistenceManager.java?rev=632232&r1=632231&r2=632232&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleFsPersistenceManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/BundleFsPersistenceManager.java
Thu Feb 28 22:39:11 2008
@@ -18,6 +18,7 @@
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.apache.commons.io.IOUtils;
 import org.apache.jackrabbit.core.fs.FileSystem;
 import org.apache.jackrabbit.core.fs.BasedFileSystem;
 import org.apache.jackrabbit.core.fs.FileSystemException;
@@ -42,7 +43,6 @@
 import java.io.DataInputStream;
 import java.io.DataOutputStream;
 import java.io.File;
-import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.sql.SQLException;
@@ -254,7 +254,7 @@
             log.error(msg);
             throw new ItemStateException(msg, e);
         } finally {
-            closeStream(din);
+            IOUtils.closeQuietly(din);
         }
     }
 
@@ -376,7 +376,7 @@
             BundleFsPersistenceManager.log.error(msg, e);
             throw new ItemStateException(msg, e);
         } finally {
-            closeStream(in);
+            IOUtils.closeQuietly(in);
         }
     }
 
@@ -441,20 +441,6 @@
             String msg = "failed to check existence of node references: " + targetId;
             BundleFsPersistenceManager.log.error(msg, e);
             throw new ItemStateException(msg, e);
-        }
-    }
-
-    /**
-     * closes the input stream
-     * @param ins
-     */
-    protected void closeStream(InputStream ins) {
-        if (ins != null) {
-            try {
-                ins.close();
-            } catch (IOException ignore) {
-                // ignore
-            }
         }
     }
 

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/BundleBinding.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/BundleBinding.java?rev=632232&r1=632231&r2=632232&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/BundleBinding.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/bundle/util/BundleBinding.java
Thu Feb 28 22:39:11 2008
@@ -18,6 +18,7 @@
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.apache.commons.io.IOUtils;
 import org.apache.jackrabbit.core.persistence.util.BLOBStore;
 import org.apache.jackrabbit.core.persistence.util.ResourceBasedBLOBStore;
 import org.apache.jackrabbit.core.NodeId;
@@ -592,11 +593,7 @@
                                     blobStore.put(blobId, in, size);
                                     state.setBlobId(blobId, i);
                                 } finally {
-                                    try {
-                                        in.close();
-                                    } catch (IOException e) {
-                                        // ignore
-                                    }
+                                    IOUtils.closeQuietly(in);
                                 }
                             } catch (Exception e) {
                                 String msg = "Error while storing blob. id="

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/db/DatabasePersistenceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/db/DatabasePersistenceManager.java?rev=632232&r1=632231&r2=632232&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/db/DatabasePersistenceManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/db/DatabasePersistenceManager.java
Thu Feb 28 22:39:11 2008
@@ -16,6 +16,7 @@
  */
 package org.apache.jackrabbit.core.persistence.db;
 
+import org.apache.commons.io.IOUtils;
 import org.apache.jackrabbit.core.NodeId;
 import org.apache.jackrabbit.core.PropertyId;
 import org.apache.jackrabbit.core.fs.FileSystem;
@@ -367,7 +368,7 @@
                 log.error(msg, e);
                 throw new ItemStateException(msg, e);
             } finally {
-                closeStream(in);
+                IOUtils.closeQuietly(in);
                 closeResultSet(rs);
             }
         }
@@ -405,7 +406,7 @@
                 log.error(msg, e);
                 throw new ItemStateException(msg, e);
             } finally {
-                closeStream(in);
+                IOUtils.closeQuietly(in);
                 closeResultSet(rs);
             }
         }
@@ -583,7 +584,7 @@
                 log.error(msg, e);
                 throw new ItemStateException(msg, e);
             } finally {
-                closeStream(in);
+                IOUtils.closeQuietly(in);
                 closeResultSet(rs);
             }
         }
@@ -924,15 +925,6 @@
         }
     }
 
-    protected void closeStream(InputStream in) {
-        if (in != null) {
-            try {
-                in.close();
-            } catch (IOException ignore) {
-            }
-        }
-    }
-
     protected void closeStatement(Statement stmt) {
         if (stmt != null) {
             try {
@@ -1030,7 +1022,7 @@
                 // commit the changes
                 con.commit();
             } finally {
-                closeStream(in);
+                IOUtils.closeQuietly(in);
                 closeStatement(stmt);
             }
         }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/db/OraclePersistenceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/db/OraclePersistenceManager.java?rev=632232&r1=632231&r2=632232&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/db/OraclePersistenceManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/db/OraclePersistenceManager.java
Thu Feb 28 22:39:11 2008
@@ -16,6 +16,7 @@
  */
 package org.apache.jackrabbit.core.persistence.db;
 
+import org.apache.commons.io.IOUtils;
 import org.apache.jackrabbit.core.persistence.PMContext;
 import org.apache.jackrabbit.core.persistence.util.Serializer;
 import org.apache.jackrabbit.core.state.NodeReferences;
@@ -345,7 +346,7 @@
                 // commit the changes
                 con.commit();
             } finally {
-                closeStream(in);
+                IOUtils.closeQuietly(in);
                 closeStatement(stmt);
             }
         }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/Serializer.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/Serializer.java?rev=632232&r1=632231&r2=632232&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/Serializer.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/util/Serializer.java
Thu Feb 28 22:39:11 2008
@@ -16,6 +16,7 @@
  */
 package org.apache.jackrabbit.core.persistence.util;
 
+import org.apache.commons.io.IOUtils;
 import org.apache.jackrabbit.core.NodeId;
 import org.apache.jackrabbit.core.PropertyId;
 import org.apache.jackrabbit.core.fs.FileSystemResource;
@@ -200,11 +201,7 @@
                 try {
                     blobStore.put(blobId, in, blobVal.getLength());
                 } finally {
-                    try {
-                        in.close();
-                    } catch (IOException e) {
-                        // ignore
-                    }
+                    IOUtils.closeQuietly(in);
                 }
                 // store id of BLOB as property value
                 out.writeUTF(blobId);   // value
@@ -222,11 +219,7 @@
                     try {
                         values[i] = InternalValue.create(in);
                     } finally {
-                        try {
-                            in.close();
-                        } catch (IOException e) {
-                            // ignore
-                        }
+                        IOUtils.closeQuietly(in);
                     }
                 }
                 blobVal.discard();

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/xml/XMLPersistenceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/xml/XMLPersistenceManager.java?rev=632232&r1=632231&r2=632232&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/xml/XMLPersistenceManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/xml/XMLPersistenceManager.java
Thu Feb 28 22:39:11 2008
@@ -16,6 +16,7 @@
  */
 package org.apache.jackrabbit.core.persistence.xml;
 
+import org.apache.commons.io.IOUtils;
 import org.apache.jackrabbit.core.NodeId;
 import org.apache.jackrabbit.core.PropertyId;
 import org.apache.jackrabbit.core.fs.BasedFileSystem;
@@ -361,11 +362,7 @@
                                 try {
                                     values.add(InternalValue.create(in));
                                 } finally {
-                                    try {
-                                        in.close();
-                                    } catch (IOException e) {
-                                        // ignore
-                                    }
+                                    IOUtils.closeQuietly(in);
                                 }
                             }
                         } catch (Exception e) {
@@ -680,11 +677,7 @@
                                 try {
                                     blobStore.put(blobId, in, blobVal.getLength());
                                 } finally {
-                                    try {
-                                        in.close();
-                                    } catch (IOException e) {
-                                        // ignore
-                                    }
+                                    IOUtils.closeQuietly(in);
                                 }
                                 // store id of BLOB as property value
                                 writer.write(blobId);

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NodeIndexer.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NodeIndexer.java?rev=632232&r1=632231&r2=632232&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NodeIndexer.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/NodeIndexer.java
Thu Feb 28 22:39:11 2008
@@ -16,6 +16,7 @@
  */
 package org.apache.jackrabbit.core.query.lucene;
 
+import org.apache.commons.io.IOUtils;
 import org.apache.jackrabbit.core.PropertyId;
 import org.apache.jackrabbit.core.NodeId;
 import org.apache.jackrabbit.core.state.ItemStateException;
@@ -681,11 +682,7 @@
                         + e.getMessage());
                 log.debug("Dump:", e);
             } finally {
-                try {
-                    value.close();
-                } catch (IOException e) {
-                    // ignore
-                }
+                IOUtils.closeQuietly(value);
             }
             return createFulltextField(textExtract.toString());
         } else {

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/TextExtractorJob.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/TextExtractorJob.java?rev=632232&r1=632231&r2=632232&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/TextExtractorJob.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/TextExtractorJob.java
Thu Feb 28 22:39:11 2008
@@ -18,6 +18,8 @@
 
 import EDU.oswego.cs.dl.util.concurrent.FutureResult;
 import EDU.oswego.cs.dl.util.concurrent.Callable;
+
+import org.apache.commons.io.IOUtils;
 import org.apache.jackrabbit.extractor.TextExtractor;
 import org.apache.jackrabbit.util.LazyFileInputStream;
 import org.slf4j.LoggerFactory;
@@ -225,19 +227,8 @@
             };
         } catch (IOException e) {
             // do some clean up
-            try {
-                out.close();
-            } catch (IOException e1) {
-                // ignore
-            }
-
-            if (in != null) {
-                try {
-                    in.close();
-                } catch (IOException e1) {
-                    // ignore
-                }
-            }
+            IOUtils.closeQuietly(out);
+            IOUtils.closeQuietly(in);
 
             if (!temp.delete()) {
                 temp.deleteOnExit();

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/BLOBFileValue.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/BLOBFileValue.java?rev=632232&r1=632231&r2=632232&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/BLOBFileValue.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/BLOBFileValue.java
Thu Feb 28 22:39:11 2008
@@ -22,6 +22,8 @@
 
 import javax.jcr.RepositoryException;
 
+import org.apache.commons.io.IOUtils;
+
 /**
  * Represents binary data which is backed by a resource or byte[].
  * Unlike <code>BinaryValue</code> it has no state, i.e.
@@ -104,10 +106,7 @@
                 out.write(buffer, 0, read);
             }
         } finally {
-            try {
-                in.close();
-            } catch (IOException ignore) {
-            }
+            IOUtils.closeQuietly(in);
         }
     }
 

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/BLOBInTempFile.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/BLOBInTempFile.java?rev=632232&r1=632231&r2=632232&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/BLOBInTempFile.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/BLOBInTempFile.java
Thu Feb 28 22:39:11 2008
@@ -16,6 +16,7 @@
  */
 package org.apache.jackrabbit.core.value;
 
+import org.apache.commons.io.IOUtils;
 import org.apache.jackrabbit.util.TransientFileFactory;
 
 import java.io.File;
@@ -68,11 +69,7 @@
         } catch (IOException e) {
             throw new RepositoryException("Error creating temporary file", e);
         } finally {
-            try {
-                in.close();
-            } catch (IOException e) {
-                // ignore
-            }
+            IOUtils.closeQuietly(in);
             if (out != null) {
                 try {
                     out.close();

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/InternalValue.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/InternalValue.java?rev=632232&r1=632231&r2=632232&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/InternalValue.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/value/InternalValue.java
Thu Feb 28 22:39:11 2008
@@ -16,6 +16,7 @@
  */
 package org.apache.jackrabbit.core.value;
 
+import org.apache.commons.io.IOUtils;
 import org.apache.jackrabbit.core.data.DataStore;
 import org.apache.jackrabbit.core.fs.FileSystemResource;
 import org.apache.jackrabbit.spi.commons.conversion.MalformedPathException;
@@ -130,11 +131,7 @@
                     try {
                         return createTemporary(stream);
                     } finally {
-                        try {
-                            stream.close();
-                        } catch (IOException e) {
-                            // ignore
-                        }
+                        IOUtils.closeQuietly(stream);
                     }
                 }
             case PropertyType.BOOLEAN:



Mime
View raw message