You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by km...@apache.org on 2010/09/29 03:12:46 UTC
svn commit: r1002439 - in /db/derby/code/branches/10.5: ./
java/engine/org/apache/derby/impl/store/replication/net/ReplicationMessageReceive.java
java/engine/org/apache/derby/impl/store/replication/net/ReplicationMessageTransmit.java
Author: kmarsden
Date: Wed Sep 29 01:12:46 2010
New Revision: 1002439
URL: http://svn.apache.org/viewvc?rev=1002439&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/branches/10.5/ (props changed)
db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/store/replication/net/ReplicationMessageReceive.java
db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/store/replication/net/ReplicationMessageTransmit.java
Propchange: db/derby/code/branches/10.5/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Sep 29 01:12:46 2010
@@ -1,2 +1,2 @@
/db/derby/code/branches/10.6:942027,957000,962738,965351,987678
-/db/derby/code/trunk:757811,769596,769602,769606,769962,772090,772337,772449,772534,774281,777105,779681,782991,785131,785139,785163,785570,785662,788369,788670,788674,788968,789264,790218,791027,792434,793089,793588,794106,794303,794955,795166,795459,796020,796027,796316,796372,797147,798347,798742,800523,803548,803948,805696,808494,808850,809643,810860,812669,816531,816536,819006,822289,823659,824694,827505,829022,829410,830545,831304,831319,832379,833430,835286,881074,881444,882732,884163,885421,885659,887246,888311,892912,897161,898635,901165,901648,901760,902857,903108,905224,908418,908586,909176,910481,910511,911315,911793,915733,916075,916897,918152,918359,921028,927430,928065,929085,934474,936215,938959,940462,940469,942286,942476,942480,942587,946794,948045,948069,951346,951366,952138,952581,954748,955001,955634,956075,956445,956659,958163,959550,962716,965647,967304,980684,986689,986834,999119
+/db/derby/code/trunk:757811,769596,769602,769606,769962,772090,772337,772449,772534,774281,777105,779681,782991,785131,785139,785163,785570,785662,788369,788670,788674,788968,789264,790218,791027,792434,793089,793588,794106,794303,794955,795166,795459,796020,796027,796316,796372,797147,798347,798742,800523,803548,803948,805696,808494,808850,809643,810860,812669,816531,816536,819006,822289,823659,824694,827505,829022,829410,830545,831304,831319,832379,833430,835286,881074,881444,882732,884163,885421,885659,887246,888311,892912,897161,898635,901165,901648,901760,902857,903108,905224,908418,908586,909176,910481,910511,911315,911793,915733,916075,916897,918152,918359,921028,927430,928065,929085,934474,936215,938959,940462,940469,942286,942476,942480,942587,946794,948045,948069,951346,951366,952138,952581,954748,955001,955634,956075,956445,956659,958163,959550,962716,965647,967304,980684,986689,986834,999119,1002291
Modified: db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/store/replication/net/ReplicationMessageReceive.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/store/replication/net/ReplicationMessageReceive.java?rev=1002439&r1=1002438&r2=1002439&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/store/replication/net/ReplicationMessageReceive.java (original)
+++ db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/store/replication/net/ReplicationMessageReceive.java Wed Sep 29 01:12:46 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/branches/10.5/java/engine/org/apache/derby/impl/store/replication/net/ReplicationMessageTransmit.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/store/replication/net/ReplicationMessageTransmit.java?rev=1002439&r1=1002438&r2=1002439&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/store/replication/net/ReplicationMessageTransmit.java (original)
+++ db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/store/replication/net/ReplicationMessageTransmit.java Wed Sep 29 01:12:46 2010
@@ -101,11 +101,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
@@ -115,7 +113,6 @@ public class ReplicationMessageTransmit
* be found.
*/
public void initConnection(int timeout, long synchOnInstant) throws
- PrivilegedActionException,
IOException,
StandardException,
ClassNotFoundException {
@@ -123,20 +120,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);