@@ -239,25 +239,27 @@ private Response executeInner(Request in, String path, RequestOptions options) {
239239 options .applyOptions (in );
240240
241241 Response response ;
242+ DatabricksError databricksError ;
243+
242244 try {
243245 response = httpClient .execute (in );
244246 if (LOG .isDebugEnabled ()) {
245247 LOG .debug (makeLogRecord (in , response ));
246248 }
249+
250+ if (isResponseSuccessful (response )) {
251+ return response ; // stop here if the request succeeded
252+ }
253+
254+ // The request did not succeed. Though, some errors are retriable and
255+ // should be retried with exponential backoff.
256+ databricksError = ApiErrors .getDatabricksError (response );
247257 } catch (IOException e ) {
248258 LOG .debug ("Request {} failed" , in , e );
249- // TODO: Evaluate whether this is actually the right thing to do
250- // compared to propagating the exception "as is".
251- throw new DatabricksError ("IO_ERROR" , 523 , e );
252- }
253-
254- if (isResponseSuccessful (response )) {
255- return response ; // stop here if the request succeeded
259+ databricksError = new DatabricksError ("IO_ERROR" , 523 , e );
260+ response = null ;
256261 }
257262
258- // The request did not succeed. Though, some errors are retriable and
259- // should be retried with exponential backoff.
260- DatabricksError databricksError = ApiErrors .getDatabricksError (response );
261263 if (!retryStrategy .isRetriable (databricksError )) {
262264 throw databricksError ;
263265 }
@@ -267,7 +269,7 @@ private Response executeInner(Request in, String path, RequestOptions options) {
267269 }
268270
269271 // Retry after a backoff.
270- long sleepMillis = getBackoffMillis (response , attemptNumber );
272+ long sleepMillis = response != null ? getBackoffMillis (response , attemptNumber ) : 1000 ;
271273 LOG .debug (
272274 String .format ("Retry %s in %dms" , in .getRequestLine (), sleepMillis ), databricksError );
273275 try {
0 commit comments