@@ -374,13 +374,17 @@ public DatabricksConfig setAzureUseMsi(boolean azureUseMsi) {
374374 return this ;
375375 }
376376
377- /** @deprecated Use {@link #getAzureUseMsi()} instead. */
377+ /**
378+ * @deprecated Use {@link #getAzureUseMsi()} instead.
379+ */
378380 @ Deprecated ()
379381 public boolean getAzureUseMSI () {
380382 return azureUseMsi ;
381383 }
382384
383- /** @deprecated Use {@link #setAzureUseMsi(boolean)} instead. */
385+ /**
386+ * @deprecated Use {@link #setAzureUseMsi(boolean)} instead.
387+ */
384388 @ Deprecated
385389 public DatabricksConfig setAzureUseMSI (boolean azureUseMsi ) {
386390 this .azureUseMsi = azureUseMsi ;
@@ -631,6 +635,25 @@ public DatabricksEnvironment getDatabricksEnvironment() {
631635 return DatabricksEnvironment .getEnvironmentFromHostname (this .host );
632636 }
633637
638+ private DatabricksConfig clone (Set <String > fieldsToSkip ) {
639+ DatabricksConfig newConfig = new DatabricksConfig ();
640+ for (Field f : DatabricksConfig .class .getDeclaredFields ()) {
641+ if (fieldsToSkip .contains (f .getName ())) {
642+ continue ;
643+ }
644+ try {
645+ f .set (newConfig , f .get (this ));
646+ } catch (IllegalAccessException e ) {
647+ throw new RuntimeException (e );
648+ }
649+ }
650+ return newConfig ;
651+ }
652+
653+ public DatabricksConfig clone () {
654+ return clone (new HashSet <>());
655+ }
656+
634657 public DatabricksConfig newWithWorkspaceHost (String host ) {
635658 Set <String > fieldsToSkip =
636659 new HashSet <>(
@@ -645,18 +668,6 @@ public DatabricksConfig newWithWorkspaceHost(String host) {
645668 // don't cache the
646669 // header factory.
647670 "headerFactory" ));
648- DatabricksConfig newConfig = new DatabricksConfig ();
649- for (Field f : DatabricksConfig .class .getDeclaredFields ()) {
650- if (fieldsToSkip .contains (f .getName ())) {
651- continue ;
652- }
653- try {
654- f .set (newConfig , f .get (this ));
655- } catch (IllegalAccessException e ) {
656- throw new RuntimeException (e );
657- }
658- }
659- newConfig .setHost (host );
660- return newConfig ;
671+ return clone (fieldsToSkip ).setHost (host );
661672 }
662673}
0 commit comments