Skip to content

Commit 11216e7

Browse files
capture DatabricksError when retrying API calls
1 parent fb97b89 commit 11216e7

File tree

1 file changed

+5
-3
lines changed
  • databricks-sdk-java/src/main/java/com/databricks/sdk/core

1 file changed

+5
-3
lines changed

databricks-sdk-java/src/main/java/com/databricks/sdk/core/ApiClient.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
import java.time.format.DateTimeFormatter;
2323
import java.util.*;
2424
import java.util.function.Function;
25+
26+
import com.google.common.base.Strings;
2527
import org.slf4j.Logger;
2628
import org.slf4j.LoggerFactory;
2729

@@ -219,7 +221,7 @@ private Response executeInner(Request in, String path) {
219221
// after the first invocation to config.authenticate()
220222
String userAgent = UserAgent.asString();
221223
String authType = getAuthTypeFunc.apply(null);
222-
if (authType != "") {
224+
if (!Strings.isNullOrEmpty(authType)) {
223225
userAgent += String.format(" auth/%s", authType);
224226
}
225227
in.withHeader("User-Agent", userAgent);
@@ -247,12 +249,12 @@ private Response executeInner(Request in, String path) {
247249
}
248250
if (attemptNumber == maxAttempts) {
249251
throw new DatabricksException(
250-
String.format("Request %s failed after %d retries", in, maxAttempts), err);
252+
String.format("Request %s failed after %d retries", in, maxAttempts), databricksError);
251253
}
252254

253255
// Retry after a backoff.
254256
long sleepMillis = getBackoffMillis(out, attemptNumber);
255-
LOG.debug(String.format("Retry %s in %dms", in.getRequestLine(), sleepMillis));
257+
LOG.debug(String.format("Retry %s in %dms", in.getRequestLine(), sleepMillis), databricksError);
256258
try {
257259
timer.sleep(sleepMillis);
258260
} catch (InterruptedException ex) {

0 commit comments

Comments
 (0)