77
88import java .io .IOException ;
99import java .io .InputStream ;
10+ import java .net .SocketException ;
1011import java .util .concurrent .ThreadLocalRandom ;
1112import java .util .concurrent .TimeUnit ;
1213import java .util .concurrent .atomic .AtomicBoolean ;
@@ -76,14 +77,14 @@ public void run() {
7677 try {
7778 this .retrieveBlock ();
7879 needRetry = false ;
79- } catch (IOException ioException ) {
80+ } catch (SocketException socketException ) {
8081 // if we get stream success, but exceptions occurs when read cos input stream
8182 String errMsg = String .format ("retrieve block sdk socket failed, " +
8283 "retryIndex: [%d / %d], key: %s, range: [%d , %d], exception: %s" ,
8384 retryIndex , this .socketErrMaxRetryTimes , this .key ,
84- this .readBuffer .getStart (), this .readBuffer .getEnd (), ioException .toString ());
85+ this .readBuffer .getStart (), this .readBuffer .getEnd (), socketException .toString ());
8586 if (retryIndex <= this .socketErrMaxRetryTimes ) {
86- LOG .info (errMsg , ioException );
87+ LOG .info (errMsg , socketException );
8788 long sleepLeast = retryIndex * 300L ;
8889 long sleepBound = retryIndex * 500L ;
8990 try {
@@ -96,11 +97,19 @@ public void run() {
9697 break ;
9798 }
9899 } else {
99- this .setFailResult (errMsg , ioException );
100+ this .setFailResult (errMsg , socketException );
100101 break ;
101102 }
103+ } catch (IOException ioException ) {
104+ String errMsg = String .format ("retrieve block failed, " +
105+ "retryIndex: [%d / %d], key: %s, range: [%d , %d], io exception: %s" ,
106+ retryIndex , this .socketErrMaxRetryTimes , this .key ,
107+ this .readBuffer .getStart (), this .readBuffer .getEnd (), ioException );
108+ this .setFailResult (errMsg , ioException );
109+ break ;
102110 } catch (Throwable throwable ) {
103111 this .setFailResult ("retrieve block failed" , new IOException (throwable ));
112+ break ;
104113 }
105114
106115 if (!needRetry ) {
0 commit comments