[jboss-remoting-commits] JBoss Remoting SVN: r3826 - remoting2/branches/2.x/src/main/org/jboss/remoting/callback.

jboss-remoting-commits at lists.jboss.org jboss-remoting-commits at lists.jboss.org
Tue Apr 1 23:29:52 EDT 2008


Author: ron.sigal at jboss.com
Date: 2008-04-01 23:29:52 -0400 (Tue, 01 Apr 2008)
New Revision: 3826

Modified:
   remoting2/branches/2.x/src/main/org/jboss/remoting/callback/CallbackStore.java
Log:
JBREM-934: (1) Put File.delete() and new FileOutputStream() in AccessController.doPrivileged() calls; (2) replace System.getProperty() with SystemUtility.getSystemProperty().

Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/callback/CallbackStore.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/callback/CallbackStore.java	2008-04-02 03:07:03 UTC (rev 3825)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/callback/CallbackStore.java	2008-04-02 03:29:52 UTC (rev 3826)
@@ -24,8 +24,11 @@
 import org.jboss.logging.Logger;
 import org.jboss.remoting.InvokerLocator;
 import org.jboss.remoting.serialization.SerializationStreamFactory;
+import org.jboss.remoting.util.SystemUtility;
+
 import java.io.File;
 import java.io.FileInputStream;
+import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.FilenameFilter;
 import java.io.IOException;
@@ -205,9 +208,18 @@
       {
          try
          {
-            fileToDelete = filePath + System.getProperty("file.separator") + fileList[x];
-            File currentFile = new File(fileToDelete);
-            boolean deleted = currentFile.delete();
+            String separator = SystemUtility.getSystemProperty("file.separator");
+            fileToDelete = filePath + separator + fileList[x];
+            final File currentFile = new File(fileToDelete);
+            
+            boolean deleted = ((Boolean)AccessController.doPrivileged( new PrivilegedAction()
+            {
+               public Object run()
+               {
+                  return new Boolean(currentFile.delete());
+               }
+            })).booleanValue();
+            
             if (!deleted)
             {
                log.warn("Error purging file " + fileToDelete);
@@ -346,7 +358,8 @@
             {
                // only getting the first one, which will be first one entered since the getting
                // of the list is automatically ordered by the OS and all file names are numeric by time.
-               objectFilePath = filePath + System.getProperty("file.separator") + objectFileList[0];
+               String separator = SystemUtility.getSystemProperty("file.separator");
+               objectFilePath = filePath + separator + objectFileList[0];
                inFile = new FileInputStream(objectFilePath);
                in = SerializationStreamFactory.getManagerInstance(serializationType).createRegularInput(inFile);
 
@@ -386,8 +399,14 @@
                if (objectFilePath != null)
                {
                   // now remove the file
-                  File objectFile = new File(objectFilePath);
-                  boolean isDeleted = objectFile.delete();
+                  final File objectFile = new File(objectFilePath);
+                  boolean isDeleted = ((Boolean) AccessController.doPrivileged( new PrivilegedAction()
+                  {
+                     public Object run()
+                     {
+                        return new Boolean(objectFile.delete());
+                     }
+                  })).booleanValue();
                   if (log.isTraceEnabled())
                   {
                      log.trace("object file (" + objectFilePath + ") has been deleted - " + isDeleted);
@@ -443,15 +462,30 @@
          }
          
          StringBuffer path = new StringBuffer(filePath);
-         path.append(System.getProperty("file.separator")).append(String.valueOf(currentTimestamp));
+         String separator = SystemUtility.getSystemProperty("file.separator");
+         path.append(separator).append(String.valueOf(currentTimestamp));
          path.append("-").append(timestampCounter).append(".").append(fileSuffix);
-         File storeFile = new File(path.toString());
+         final File storeFile = new File(path.toString());
          FileOutputStream outFile = null;
          ObjectOutputStream out = null;
 
          try
-         {
-            outFile = new FileOutputStream(storeFile, false);
+         {  
+            try
+            {
+               outFile = (FileOutputStream)AccessController.doPrivileged( new PrivilegedExceptionAction()
+               {
+                  public Object run() throws FileNotFoundException
+                  {
+                     return new FileOutputStream(storeFile, false);
+                  }
+               });
+            }
+            catch (PrivilegedActionException e)
+            {
+               throw (IOException) e.getCause();
+            }
+            
             out = SerializationStreamFactory.getManagerInstance(serializationType).createOutput(outFile);
             out.writeObject(object);
             out.flush();




More information about the jboss-remoting-commits mailing list