commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tcu...@apache.org
Subject svn commit: r515303 - in /jakarta/commons/sandbox/jci/trunk/core/src/main/java/org/apache/commons/jci: listeners/ReloadingListener.java stores/FileResourceStore.java
Date Tue, 06 Mar 2007 21:08:50 GMT
Author: tcurdt
Date: Tue Mar  6 13:08:49 2007
New Revision: 515303

URL: http://svn.apache.org/viewvc?view=rev&rev=515303
Log:
hopefully make windows happy


Modified:
    jakarta/commons/sandbox/jci/trunk/core/src/main/java/org/apache/commons/jci/listeners/ReloadingListener.java
    jakarta/commons/sandbox/jci/trunk/core/src/main/java/org/apache/commons/jci/stores/FileResourceStore.java

Modified: jakarta/commons/sandbox/jci/trunk/core/src/main/java/org/apache/commons/jci/listeners/ReloadingListener.java
URL: http://svn.apache.org/viewvc/jakarta/commons/sandbox/jci/trunk/core/src/main/java/org/apache/commons/jci/listeners/ReloadingListener.java?view=diff&rev=515303&r1=515302&r2=515303
==============================================================================
--- jakarta/commons/sandbox/jci/trunk/core/src/main/java/org/apache/commons/jci/listeners/ReloadingListener.java
(original)
+++ jakarta/commons/sandbox/jci/trunk/core/src/main/java/org/apache/commons/jci/listeners/ReloadingListener.java
Tue Mar  6 13:08:49 2007
@@ -91,12 +91,16 @@
         if (created.size() > 0) {
             for (Iterator it = created.iterator(); it.hasNext();) {
                 final File file = (File) it.next();
+                FileInputStream is = null;
                 try {
-                    final byte[] bytes = IOUtils.toByteArray(new FileInputStream(file));
+                	is = new FileInputStream(file);
+                    final byte[] bytes = IOUtils.toByteArray(is);
                     final String resourceName = getResourceNameFromRelativeFileName(ClassUtils.relative(pObserver.getRootDirectory(),
file));
                      store.write(resourceName, bytes);
                 } catch(final Exception e) {
                     log.error("could not load " + file, e);
+                } finally {
+                	IOUtils.closeQuietly(is);
                 }
             }
         }
@@ -104,12 +108,16 @@
         if (changed.size() > 0) {
             for (Iterator it = changed.iterator(); it.hasNext();) {
                 final File file = (File) it.next();
+                FileInputStream is = null;
                 try {
+                	is = new FileInputStream(file);
                     final byte[] bytes = IOUtils.toByteArray(new FileInputStream(file));
                     final String resourceName = getResourceNameFromRelativeFileName(ClassUtils.relative(pObserver.getRootDirectory(),
file));
                     store.write(resourceName, bytes);
                 } catch(final Exception e) {
                     log.error("could not load " + file, e);
+                } finally {
+                	IOUtils.closeQuietly(is);
                 }
             }
             reload = true;

Modified: jakarta/commons/sandbox/jci/trunk/core/src/main/java/org/apache/commons/jci/stores/FileResourceStore.java
URL: http://svn.apache.org/viewvc/jakarta/commons/sandbox/jci/trunk/core/src/main/java/org/apache/commons/jci/stores/FileResourceStore.java?view=diff&rev=515303&r1=515302&r2=515303
==============================================================================
--- jakarta/commons/sandbox/jci/trunk/core/src/main/java/org/apache/commons/jci/stores/FileResourceStore.java
(original)
+++ jakarta/commons/sandbox/jci/trunk/core/src/main/java/org/apache/commons/jci/stores/FileResourceStore.java
Tue Mar  6 13:08:49 2007
@@ -18,13 +18,13 @@
 
 import java.io.File;
 import java.io.FileInputStream;
-import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.util.ArrayList;
 import java.util.List;
+
 import org.apache.commons.io.IOUtils;
 
 
@@ -45,21 +45,11 @@
             is = new FileInputStream(getFile(pResourceName));
             final byte[] data = IOUtils.toByteArray(is);
             return data;
-        } catch (FileNotFoundException e) {
-        	// TODO
-        } catch (IOException e) {
-        	// TODO
+        } catch (Exception e) {
+        	return null;
         } finally {
-            if (is != null) {
-                try {
-                    is.close();
-                } catch (IOException e) {
-                	//TODO
-                }
-            }
+        	IOUtils.closeQuietly(is);
         }
-
-        return null;
     }
     
     public void write( final String pResourceName, final byte[] pData ) {
@@ -74,18 +64,10 @@
             }
             os = new FileOutputStream(file);
             os.write(pData);
-        } catch (FileNotFoundException e) {
-        	// TODO
-        } catch (IOException e) {
-        	// TODO        	
+        } catch (Exception e) {
+        	// FIXME: now what?
         } finally {
-            if (os != null) {
-                try {
-                    os.close();
-                } catch (IOException e) {
-                	//TODO
-                }
-            }
+        	IOUtils.closeQuietly(os);
         }
     }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message