You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@river.apache.org by pe...@apache.org on 2010/09/24 13:29:00 UTC

svn commit: r1000818 - /incubator/river/jtsk/skunk/pepe/src/org/apache/river/api/delegates/FileInputStream.java

Author: peter_firmstone
Date: Fri Sep 24 11:29:00 2010
New Revision: 1000818

URL: http://svn.apache.org/viewvc?rev=1000818&view=rev
Log:
Add close() by default after SecurityException to FileInputStream delegate

Modified:
    incubator/river/jtsk/skunk/pepe/src/org/apache/river/api/delegates/FileInputStream.java

Modified: incubator/river/jtsk/skunk/pepe/src/org/apache/river/api/delegates/FileInputStream.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/skunk/pepe/src/org/apache/river/api/delegates/FileInputStream.java?rev=1000818&r1=1000817&r2=1000818&view=diff
==============================================================================
--- incubator/river/jtsk/skunk/pepe/src/org/apache/river/api/delegates/FileInputStream.java (original)
+++ incubator/river/jtsk/skunk/pepe/src/org/apache/river/api/delegates/FileInputStream.java Fri Sep 24 11:29:00 2010
@@ -28,6 +28,8 @@ import java.security.Guard;
 import java.security.PrivilegedAction;
 import java.security.PrivilegedActionException;
 import java.security.PrivilegedExceptionAction;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 import org.apache.river.api.security.DelegatePermission;
 import sun.security.util.SecurityConstants;
 
@@ -76,32 +78,49 @@ public class FileInputStream extends jav
 
     @Override
     public int read() throws IOException {
-	g.checkGuard(this);
+	checkGuard();
 	return in.read();
     }
     
     @Override
     public int read(byte b[]) throws IOException {
-	g.checkGuard(this);
+	checkGuard();
 	return in.read(b);
     }
     
     @Override
     public int read(byte b[], int off, int len) throws IOException {
-	g.checkGuard(this);
+	checkGuard();
 	return in.read(b, off, len);
     }
     
     @Override
     public long skip(long n) throws IOException {
-	g.checkGuard(this);
+	checkGuard();
 	return in.skip(n);
     }
     
     @Override
     public int available() throws IOException {
-	g.checkGuard(this);
+	checkGuard();
 	return in.available();
     }
     
+    @Override
+    public void close() throws IOException {
+	in.close();
+    }
+    
+    private void checkGuard() {
+	try {
+	    g.checkGuard(this);
+	} catch (SecurityException e){
+	    try {
+		this.close();
+	    } catch (IOException ex) {
+		Logger.getLogger(FileInputStream.class.getName()).log(Level.SEVERE, null, ex);
+	    }
+	    throw e;
+	}
+    }
 }