@@ -215,8 +215,8 @@ public void proceed(Void v)
215
215
}
216
216
});
217
217
}
218
+ }
218
219
}
219
- }
220
220
catch (IOException e )
221
221
{
222
222
throw new IllegalStateException (e );
@@ -1816,24 +1816,24 @@ public int getProtocolVersion()
1816
1816
* @param runnable the runnable to invoke
1817
1817
*/
1818
1818
protected synchronized void invoke (Runnable runnable )
1819
- {
1820
- Queue <Runnable > queueDeferred = m_queueDeferred ;
1821
- if (queueDeferred == null )
1822
1819
{
1823
- try
1820
+ Queue <Runnable > queueDeferred = m_queueDeferred ;
1821
+ if (queueDeferred == null )
1824
1822
{
1825
- getSelectionService ().invoke (m_channel , runnable , /*cMillisDelay*/ 0 );
1823
+ try
1824
+ {
1825
+ getSelectionService ().invoke (m_channel , runnable , /*cMillisDelay*/ 0 );
1826
+ }
1827
+ catch (IOException e )
1828
+ {
1829
+ throw new RuntimeException (e );
1830
+ }
1826
1831
}
1827
- catch ( IOException e )
1832
+ else
1828
1833
{
1829
- throw new RuntimeException ( e );
1834
+ queueDeferred . add ( runnable );
1830
1835
}
1831
1836
}
1832
- else
1833
- {
1834
- queueDeferred .add (runnable );
1835
- }
1836
- }
1837
1837
1838
1838
// ----- Channel interface ------------------------------------------
1839
1839
@@ -2090,69 +2090,70 @@ public int read(ByteBuffer dst) throws IOException
2090
2090
*/
2091
2091
public synchronized void migrate (Throwable eReason )
2092
2092
{
2093
- SocketBusDriver . Dependencies depsDriver = f_driver .getDependencies ();
2094
- int cSocketReconnectLimit = depsDriver .getSocketReconnectLimit ();
2093
+ SocketBusDriver . Dependencies depsDriver = f_driver .getDependencies ();
2094
+ int cSocketReconnectLimit = depsDriver .getSocketReconnectLimit ();
2095
2095
2096
- // COH-24389 - a reconnect limit of < 0 indicates that migrations are disabled
2097
- if (getProtocolVersion () == 0 || cSocketReconnectLimit < 0 )
2098
- {
2099
- scheduleDisconnect (eReason );
2100
- }
2101
- else // protocol not yet negotiated or >= 1, in either case we can attempt a migration
2102
- {
2103
- if (eReason instanceof ConnectException && ++m_cReconnectAttempts > cSocketReconnectLimit )
2096
+ // COH-24389 - a reconnect limit of < 0 indicates that migrations are disabled
2097
+ if (getProtocolVersion () == 0 || cSocketReconnectLimit < 0 )
2104
2098
{
2105
- // we've exhausted our reconnect attempts, disconnect
2106
2099
scheduleDisconnect (eReason );
2107
- return ;
2108
2100
}
2101
+ else // protocol not yet negotiated or >= 1, in either case we can attempt a migration
2102
+ {
2103
+ if (eReason instanceof ConnectException && ++m_cReconnectAttempts > cSocketReconnectLimit )
2104
+ {
2105
+ // we've exhausted our reconnect attempts, disconnect
2106
+ scheduleDisconnect (eReason );
2107
+ return ;
2108
+ }
2109
2109
2110
- // delay reconnect on initial connect and to also help avoid an endless conflict
2111
- // if both sides were to keep trying to simultaneously reconnect and in doing so invalidate the other
2112
- // side's reconnect attempt.
2113
- long cMillisDelay = eReason instanceof ConnectException ||
2114
- getLocalEndPoint ().getCanonicalName ().compareTo (getPeer ().getCanonicalName ()) > 0
2115
- ? depsDriver .getSocketReconnectDelayMillis ()
2116
- : 0 ;
2110
+ // delay reconnect on initial connect and to also help avoid an endless conflict
2111
+ // if both sides were to keep trying to simultaneously reconnect and in doing so invalidate the other
2112
+ // side's reconnect attempt.
2113
+ long cMillisDelay = eReason instanceof ConnectException ||
2114
+ getLocalEndPoint ().getCanonicalName ().compareTo (getPeer ().getCanonicalName ()) > 0
2115
+ ? depsDriver .getSocketReconnectDelayMillis ()
2116
+ : 0 ;
2117
2117
2118
- SocketChannel chan = m_channel ;
2119
- String sChan = chan .toString (); // to preserve port info for subsequent logging
2118
+ SocketChannel chan = m_channel ;
2119
+ String sChan = chan .toString (); // to preserve port info for subsequent logging
2120
2120
2121
- closeChannel (chan );
2121
+ closeChannel (chan );
2122
2122
2123
- scheduleUnsafeTask (chan , new Runnable ()
2124
- {
2125
- @ Override
2126
- public void run ()
2123
+ scheduleUnsafeTask (chan , new Runnable ()
2127
2124
{
2128
- synchronized (Connection .this )
2125
+ @ Override
2126
+ public void run ()
2129
2127
{
2130
- if ( m_state . ordinal () < ConnectionState . DEFUNCT . ordinal () && chan == m_channel )
2128
+ synchronized ( Connection . this )
2131
2129
{
2132
- getLogger ().log (makeExceptionRecord (Level .FINER , eReason ,
2133
- "{0} migrating connection with {1} off of {2} on {3}" ,
2134
- getLocalEndPoint (), getPeer (), sChan , Connection .this ));
2130
+ if (m_state .ordinal () < ConnectionState .DEFUNCT .ordinal () && chan == m_channel )
2131
+ {
2132
+ // COH-24703 - not adding the exception to the LogRecord because logging the stack trace is not useful in this case
2133
+ getLogger ().log (makeRecord (Level .FINER ,
2134
+ "{0} migrating connection with {1} off of {2} on {3}: {4}" ,
2135
+ getLocalEndPoint (), getPeer (), sChan , Connection .this , eReason ));
2135
2136
2136
- m_eMigrationCause = eReason ;
2137
- onMigration ();
2137
+ m_eMigrationCause = eReason ;
2138
+ onMigration ();
2138
2139
2139
- // we're sync'd on the connection so nothing new can be scheduled
2140
- try
2141
- {
2142
- getSelectionService ().register (chan , null );
2143
- m_handler = null ;
2144
- }
2140
+ // we're sync'd on the connection so nothing new can be scheduled
2141
+ try
2142
+ {
2143
+ getSelectionService ().register (chan , null );
2144
+ m_handler = null ;
2145
+ }
2145
2146
catch (IOException e ) {}
2146
2147
2147
- // replaces m_channel, so any subsequent exceptions on the old channel won't make it into this if block
2148
- // schedule task to ensure register and connect are processed sequentially
2149
- scheduleUnsafeTask (chan , ()-> connect (), cMillisDelay );
2148
+ // replaces m_channel, so any subsequent exceptions on the old channel won't make it into this if block
2149
+ // schedule task to ensure register and connect are processed sequentially
2150
+ scheduleUnsafeTask (chan , () -> connect (), cMillisDelay );
2151
+ }
2150
2152
}
2151
2153
}
2152
- }
2153
- }, cMillisDelay );
2154
+ }, cMillisDelay );
2155
+ }
2154
2156
}
2155
- }
2156
2157
2157
2158
/**
2158
2159
* Called when the channel has been selected.
@@ -3114,11 +3115,11 @@ public void run()
3114
3115
throw new IllegalStateException ("state = " + connOld .m_state );
3115
3116
}
3116
3117
}
3118
+ }
3117
3119
}
3118
3120
}
3119
- }
3120
- finally
3121
- {
3121
+ finally
3122
+ {
3122
3123
if (m_connection != connNew )
3123
3124
{
3124
3125
connNew .dispose ();
0 commit comments