@@ -135,6 +135,7 @@ public boolean send(Transmission transmission) {
135135
136136 HttpResponse response = null ;
137137 HttpPost request = null ;
138+ boolean shouldBackoff = false ;
138139 try {
139140 request = createTransmissionPostRequest (transmission );
140141 httpClient .enhanceRequest (request );
@@ -160,32 +161,32 @@ public boolean send(Transmission transmission) {
160161 }
161162 } catch (ConnectionPoolTimeoutException e ) {
162163 InternalLogger .INSTANCE .error ("Failed to send, connection pool timeout exception" );
164+ shouldBackoff = true ;
163165 } catch (SocketException e ) {
164166 InternalLogger .INSTANCE .error ("Failed to send, socket timeout exception" );
165- // backoff retry if no connection is found
166- if (e instanceof ConnectException ) {
167- transmissionPolicyManager .suspendInSeconds (TransmissionPolicy .BLOCKED_BUT_CAN_BE_PERSISTED , DEFAULT_BACKOFF_TIME_SECONDS );
168- }
167+ shouldBackoff = true ;
169168 } catch (UnknownHostException e ) {
170169 InternalLogger .INSTANCE .error ("Failed to send, wrong host address or cannot reach address due to network issues, exception: %s" , e .getMessage ());
171- // backoff retry if host unknown
172- transmissionPolicyManager .suspendInSeconds (TransmissionPolicy .BLOCKED_BUT_CAN_BE_PERSISTED , DEFAULT_BACKOFF_TIME_SECONDS );
170+ shouldBackoff = true ;
173171 } catch (IOException ioe ) {
174172 InternalLogger .INSTANCE .error ("Failed to send, exception: %s" , ioe .getMessage ());
175- // backoff retry if no connection is found
176- if (ioe instanceof ConnectTimeoutException ) {
177- transmissionPolicyManager .suspendInSeconds (TransmissionPolicy .BLOCKED_BUT_CAN_BE_PERSISTED , DEFAULT_BACKOFF_TIME_SECONDS );
178- }
173+ shouldBackoff = true ;
179174 } catch (Exception e ) {
180175 InternalLogger .INSTANCE .error ("Failed to send, unexpected exception: %s" , e .getMessage ());
176+ shouldBackoff = true ;
181177 } catch (Throwable t ) {
182178 InternalLogger .INSTANCE .error ("Failed to send, unexpected error: %s" , t .getMessage ());
179+ shouldBackoff = true ;
183180 }
184181 finally {
185182 if (request != null ) {
186183 request .releaseConnection ();
187184 }
188185 httpClient .dispose (response );
186+ // backoff before trying again
187+ if (shouldBackoff ) {
188+ transmissionPolicyManager .suspendInSeconds (TransmissionPolicy .BLOCKED_BUT_CAN_BE_PERSISTED , DEFAULT_BACKOFF_TIME_SECONDS );
189+ }
189190 }
190191 }
191192
0 commit comments