@@ -93,9 +93,9 @@ static void loadFromConfig(DatabricksConfig cfg) throws IllegalAccessException {
9393 INIConfiguration ini = parseDatabricksCfg (configFile , isDefaultConfig );
9494 if (ini == null ) return ;
9595
96- String [] resolved = resolveProfile (cfg .getProfile (), ini , configFile .toString ());
97- String profile = resolved [ 0 ] ;
98- boolean isFallback = "true" . equals ( resolved [ 1 ]) ;
96+ ResolvedProfile resolved = resolveProfile (cfg .getProfile (), ini , configFile .toString ());
97+ String profile = resolved . name ;
98+ boolean isFallback = resolved . isFallback ;
9999
100100 SubnodeConfiguration section = ini .getSection (profile );
101101 boolean sectionNotPresent = section == null || section .isEmpty ();
@@ -121,6 +121,16 @@ static void loadFromConfig(DatabricksConfig cfg) throws IllegalAccessException {
121121 }
122122 }
123123
124+ static class ResolvedProfile {
125+ final String name ;
126+ final boolean isFallback ;
127+
128+ ResolvedProfile (String name , boolean isFallback ) {
129+ this .name = name ;
130+ this .isFallback = isFallback ;
131+ }
132+ }
133+
124134 /**
125135 * Resolves which profile to use from the config file.
126136 *
@@ -132,18 +142,18 @@ static void loadFromConfig(DatabricksConfig cfg) throws IllegalAccessException {
132142 * <li>{@code "DEFAULT"} with isFallback=true
133143 * </ol>
134144 *
135- * @return a two-element array: [profileName, "true"/"false" for isFallback]
136145 * @throws DatabricksException if the resolved profile is the reserved __settings__ section
137146 */
138- static String [] resolveProfile (String requestedProfile , INIConfiguration ini , String configFile ) {
147+ static ResolvedProfile resolveProfile (
148+ String requestedProfile , INIConfiguration ini , String configFile ) {
139149 if (!isNullOrEmpty (requestedProfile )) {
140150 if (SETTINGS_SECTION .equals (requestedProfile )) {
141151 throw new DatabricksException (
142152 String .format (
143153 "%s: %s is a reserved section name and cannot be used as a profile" ,
144154 configFile , SETTINGS_SECTION ));
145155 }
146- return new String [] { requestedProfile , " false" } ;
156+ return new ResolvedProfile ( requestedProfile , false ) ;
147157 }
148158
149159 SubnodeConfiguration settings = ini .getSection (SETTINGS_SECTION );
@@ -159,11 +169,11 @@ static String[] resolveProfile(String requestedProfile, INIConfiguration ini, St
159169 "%s: %s is a reserved section name and cannot be used as a profile" ,
160170 configFile , SETTINGS_SECTION ));
161171 }
162- return new String [] { defaultProfile , " false" } ;
172+ return new ResolvedProfile ( defaultProfile , false ) ;
163173 }
164174 }
165175
166- return new String [] { "DEFAULT" , " true" } ;
176+ return new ResolvedProfile ( "DEFAULT" , true ) ;
167177 }
168178
169179 private static INIConfiguration parseDatabricksCfg (String configFile , boolean isDefaultConfig ) {
0 commit comments