@@ -492,7 +492,8 @@ CreateUploadUrlResponse getCreateUploadUrlResponse(String objectPath)
492492 CreateUploadUrlRequest request = new CreateUploadUrlRequest (objectPath );
493493 try {
494494 Request req = new Request (Request .POST , CREATE_UPLOAD_URL_PATH , apiClient .serialize (request ));
495- req .withHeaders (JSON_HTTP_HEADERS ).withHeaders (connectionContext .getCustomHeaders ());
495+ req .withHeaders (JSON_HTTP_HEADERS )
496+ .withHeaders (connectionContext != null ? connectionContext .getCustomHeaders () : Map .of ());
496497 return apiClient .execute (req , CreateUploadUrlResponse .class );
497498 } catch (IOException | DatabricksException e ) {
498499 String errorMessage =
@@ -514,7 +515,8 @@ CreateDownloadUrlResponse getCreateDownloadUrlResponse(String objectPath)
514515 try {
515516 Request req =
516517 new Request (Request .POST , CREATE_DOWNLOAD_URL_PATH , apiClient .serialize (request ));
517- req .withHeaders (JSON_HTTP_HEADERS ).withHeaders (connectionContext .getCustomHeaders ());
518+ req .withHeaders (JSON_HTTP_HEADERS )
519+ .withHeaders (connectionContext != null ? connectionContext .getCustomHeaders () : Map .of ());
518520 return apiClient .execute (req , CreateDownloadUrlResponse .class );
519521 } catch (IOException | DatabricksException e ) {
520522 String errorMessage =
@@ -534,7 +536,8 @@ CreateDeleteUrlResponse getCreateDeleteUrlResponse(String objectPath)
534536
535537 try {
536538 Request req = new Request (Request .POST , CREATE_DELETE_URL_PATH , apiClient .serialize (request ));
537- req .withHeaders (JSON_HTTP_HEADERS ).withHeaders (connectionContext .getCustomHeaders ());
539+ req .withHeaders (JSON_HTTP_HEADERS )
540+ .withHeaders (connectionContext != null ? connectionContext .getCustomHeaders () : Map .of ());
538541 return apiClient .execute (req , CreateDeleteUrlResponse .class );
539542 } catch (IOException | DatabricksException e ) {
540543 String errorMessage =
@@ -551,7 +554,8 @@ ListResponse getListResponse(String listPath) throws DatabricksVolumeOperationEx
551554 ListRequest request = new ListRequest (listPath );
552555 try {
553556 Request req = new Request (Request .GET , LIST_PATH );
554- req .withHeaders (JSON_HTTP_HEADERS ).withHeaders (connectionContext .getCustomHeaders ());
557+ req .withHeaders (JSON_HTTP_HEADERS )
558+ .withHeaders (connectionContext != null ? connectionContext .getCustomHeaders () : Map .of ());
555559 ApiClient .setQuery (req , request );
556560 return apiClient .execute (req , ListResponse .class );
557561 } catch (IOException | DatabricksException e ) {
@@ -888,7 +892,9 @@ private CompletableFuture<CreateUploadUrlResponse> requestPresignedUrlWithRetry(
888892 Map <String , String > authHeaders = workspaceClient .config ().authenticate ();
889893 authHeaders .forEach (requestBuilder ::addHeader );
890894 JSON_HTTP_HEADERS .forEach (requestBuilder ::addHeader );
891- connectionContext .getCustomHeaders ().forEach (requestBuilder ::addHeader );
895+ if (connectionContext != null ) {
896+ connectionContext .getCustomHeaders ().forEach (requestBuilder ::addHeader );
897+ }
892898
893899 requestBuilder .setEntity (
894900 AsyncEntityProducers .create (requestBody .getBytes (), ContentType .APPLICATION_JSON ));
0 commit comments