Browse Source

fixed bio socket

七锋 7 years ago
parent
commit
af002f4e24

+ 3 - 3
driver/src/main/java/com/alibaba/otter/canal/parse/driver/mysql/socket/BioSocketChannel.java

@@ -2,12 +2,12 @@ package com.alibaba.otter.canal.parse.driver.mysql.socket;
 
 import java.io.IOException;
 import java.io.InputStream;
-import java.io.InterruptedIOException;
 import java.io.OutputStream;
 import java.net.Socket;
 import java.net.SocketAddress;
 import java.net.SocketException;
 import java.net.SocketTimeoutException;
+import java.nio.channels.ClosedByInterruptException;
 
 /**
  * 使用BIO进行dump
@@ -56,7 +56,7 @@ public class BioSocketChannel implements SocketChannel {
                 }
             } catch (SocketTimeoutException te) {
                 if (Thread.interrupted()) {
-                    throw new InterruptedIOException("Interrupted while reading.");
+                    throw new ClosedByInterruptException("Interrupted while reading.");
                 }
             }
         }
@@ -81,7 +81,7 @@ public class BioSocketChannel implements SocketChannel {
                 }
             } catch (SocketTimeoutException te) {
                 if (Thread.interrupted()) {
-                    throw new InterruptedIOException("Interrupted while reading.");
+                    throw new ClosedByInterruptException();
                 }
                 accTimeout += SO_TIMEOUT;
             }

+ 1 - 1
example/src/main/java/com/alibaba/otter/canal/example/AbstractCanalClientTest.java

@@ -56,7 +56,7 @@ public class AbstractCanalClientTest {
         context_format += "****************************************************" + SEP;
 
         row_format = SEP
-                     + "----------------> binlog[{}:{}] , name[{},{}] , eventType : {} , executeTime : {}({}) , delay : {}ms"
+                     + "----------------> binlog[{}:{}] , name[{},{}] , eventType : {} , executeTime : {}({}) , delay : {} ms"
                      + SEP;
 
         transaction_format = SEP + "================> binlog[{}:{}] , executeTime : {}({}) , delay : {}ms" + SEP;