db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmars...@apache.org
Subject svn commit: r1002291 - in /db/derby/code/trunk/java/engine/org/apache/derby/impl/store/replication/net: ReplicationMessageReceive.java ReplicationMessageTransmit.java
Date Tue, 28 Sep 2010 17:42:59 GMT
Author: kmarsden
Date: Tue Sep 28 17:42:59 2010
New Revision: 1002291

URL: http://svn.apache.org/viewvc?rev=1002291&view=rev
Log:
DERBY-4812 ReplicationMessageTransmit run does not unwrap PrivilegedActionException which
can lead to failure of replicationTests.ReplicationRun_Local_StateTest_part1_1



Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/store/replication/net/ReplicationMessageReceive.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/store/replication/net/ReplicationMessageTransmit.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/store/replication/net/ReplicationMessageReceive.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/store/replication/net/ReplicationMessageReceive.java?rev=1002291&r1=1002290&r2=1002291&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/store/replication/net/ReplicationMessageReceive.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/store/replication/net/ReplicationMessageReceive.java
Tue Sep 28 17:42:59 2010
@@ -113,7 +113,7 @@ public class ReplicationMessageReceive {
      * @param timeout The amount of time, in milliseconds, this method
      * will wait for a connection to be established. If no connection
      * has been established before the timeout, a
-     * PrivilegedExceptionAction is raised with cause
+     * IOException is raised with cause
      * java.net.SocketTimeoutException
      * @param synchOnInstant the slave log instant, used to check that
      * the master and slave log files are in synch. If no chunks of log
@@ -123,11 +123,11 @@ public class ReplicationMessageReceive {
      * Note that there is a difference!
      * @param dbname the name of the replicated database
      *
-     * @throws PrivilegedActionException if an exception occurs while trying
-     *                                   to open a connection.
+     *
      *
      * @throws IOException if an exception occurs while trying to create the
-     *                     <code>SocketConnection</code> class.
+     *                     <code>SocketConnection</code> class or while
+     *                     trying to open a connection.
      *
      * @throws ClassNotFoundException Class of a serialized object cannot
      *                                be found.
@@ -136,7 +136,6 @@ public class ReplicationMessageReceive {
      */
     public void initConnection(int timeout, long synchOnInstant, String dbname)
         throws
-        PrivilegedActionException,
         IOException,
         StandardException,
         ClassNotFoundException {
@@ -148,16 +147,20 @@ public class ReplicationMessageReceive {
             serverSocket = createServerSocket();
         }
         serverSocket.setSoTimeout(timeout);
-        
-        //Start listening on the socket and accepting the connection
-        Socket client =
-            (Socket)
-            AccessController.doPrivileged(new PrivilegedExceptionAction() {
-            public Object run() throws IOException {
-                return serverSocket.accept();
-            }
-        });
-        
+        Socket client = null;
+        try {
+            //Start listening on the socket and accepting the connection
+            client =
+                (Socket)
+                AccessController.doPrivileged(new PrivilegedExceptionAction() {
+                    public Object run() throws IOException {
+                        return serverSocket.accept();
+                    }
+                });
+        } catch(PrivilegedActionException pea) {
+            throw (IOException) pea.getException();
+        }
+
         //create the SocketConnection object using the client connection.
         socketConn = new SocketConnection(client);
         
@@ -180,20 +183,26 @@ public class ReplicationMessageReceive {
      *
      * @return an instance of the <code>ServerSocket</code> class.
      *
-     * @throws PrivilegedActionException if an exception occurs while trying
+     * @throws IOException if an exception occurs while trying
      *                                   to open a connection.
      */
-    private ServerSocket createServerSocket() throws PrivilegedActionException {
+    private ServerSocket createServerSocket() throws IOException {
         //create a ServerSocket at the specified host name and the
         //port number.
-        return   (ServerSocket) AccessController.doPrivileged
+        ServerSocket ss = null;
+        try { 
+            ss =   (ServerSocket) AccessController.doPrivileged
             (new PrivilegedExceptionAction() {
-            public Object run() throws IOException, StandardException {
-                ServerSocketFactory sf = ServerSocketFactory.getDefault();
-                return sf.createServerSocket(slaveAddress.getPortNumber(),
-                    0, slaveAddress.getHostAddress());
-            }
-        });
+                public Object run() throws IOException  {
+                    ServerSocketFactory sf = ServerSocketFactory.getDefault();
+                    return sf.createServerSocket(slaveAddress.getPortNumber(),
+                            0, slaveAddress.getHostAddress());
+                }
+            });
+            return ss;
+        } catch(PrivilegedActionException pea) {
+            throw (IOException) pea.getException();
+        }
     }
     
     /**

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/store/replication/net/ReplicationMessageTransmit.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/store/replication/net/ReplicationMessageTransmit.java?rev=1002291&r1=1002290&r2=1002291&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/store/replication/net/ReplicationMessageTransmit.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/store/replication/net/ReplicationMessageTransmit.java
Tue Sep 28 17:42:59 2010
@@ -98,11 +98,9 @@ public class ReplicationMessageTransmit 
      * end position in the current log file. If a chunk of log has
      * been shipped, this is the instant of the log record shipped
      * last. Note that there is a difference!
-     * @throws PrivilegedActionException if an exception occurs while trying
-     *                                   to open a connection.
-     *
+     * 
      * @throws IOException if an exception occurs while trying to create the
-     *         <code>SocketConnection</code> class.
+     *         <code>SocketConnection</code> class or open a connection.
      *
      * @throws StandardException If an error message is received from the
      *         server indicating incompatible software versions of master
@@ -112,7 +110,6 @@ public class ReplicationMessageTransmit 
      *         be found.
      */
     public void initConnection(int timeout, long synchOnInstant) throws
-        PrivilegedActionException,
         IOException,
         StandardException,
         ClassNotFoundException {
@@ -120,20 +117,23 @@ public class ReplicationMessageTransmit 
         Socket s = null;
         
         final int timeout_ = timeout;
-        
-        //create a connection to the slave.
-        s = (Socket)
-        AccessController.doPrivileged(new PrivilegedExceptionAction() {
-            public Object run() throws IOException {
-                SocketFactory sf = SocketFactory.getDefault();
-                InetSocketAddress sockAddr = new InetSocketAddress(
-                        slaveAddress.getHostAddress(), 
-                        slaveAddress.getPortNumber());
-                Socket s_temp = sf.createSocket();
-                s_temp.connect(sockAddr, timeout_);
-                return s_temp;
-            }
-        });
+        try {
+            //create a connection to the slave.
+            s = (Socket)
+            AccessController.doPrivileged(new PrivilegedExceptionAction() {
+                public Object run() throws IOException {
+                    SocketFactory sf = SocketFactory.getDefault();
+                    InetSocketAddress sockAddr = new InetSocketAddress(
+                            slaveAddress.getHostAddress(), 
+                            slaveAddress.getPortNumber());
+                    Socket s_temp = sf.createSocket();
+                    s_temp.connect(sockAddr, timeout_);
+                    return s_temp;
+                }
+            });
+        } catch(PrivilegedActionException pea) {
+            throw (IOException) pea.getException();
+        }
         
         // keep socket alive even if no log is shipped for a long time
         s.setKeepAlive(true);



Mime
View raw message