1111import java .net .MalformedURLException ;
1212import java .net .URL ;
1313import java .util .Map ;
14+ import java .util .Optional ;
1415import java .util .Properties ;
1516import java .util .concurrent .Callable ;
1617
@@ -1095,9 +1096,10 @@ public static Config parseResourcesAnySyntax(String resourceBasename) {
10951096 * Parse only any application replacement (specified by one of config.{resource,file,url}), returning
10961097 * an empty Config if no overrides were set.
10971098 * @param parseOptions parse options
1098- * @return the parsed configuration
1099+ * @return a {@link java.util.Optional} containing any specified replacement, or {@link Optional#empty()}
1100+ * if none was specified.
10991101 */
1100- public static Config parseApplicationReplacement (ConfigParseOptions parseOptions ) {
1102+ public static java . util . Optional < Config > parseApplicationReplacement (ConfigParseOptions parseOptions ) {
11011103 ClassLoader loader = parseOptions .getClassLoader ();
11021104
11031105 if (loader == null )
@@ -1120,7 +1122,7 @@ public static Config parseApplicationReplacement(ConfigParseOptions parseOptions
11201122 specified += 1 ;
11211123
11221124 if (specified == 0 ) {
1123- return ConfigImpl . emptyConfig ( "TODO: what to put here? Should something else be returned?" );
1125+ return java . util . Optional . empty ( );
11241126 } else if (specified > 1 ) {
11251127 throw new ConfigException .Generic ("You set more than one of config.file='" + file
11261128 + "', config.url='" + url + "', config.resource='" + resource
@@ -1133,12 +1135,12 @@ public static Config parseApplicationReplacement(ConfigParseOptions parseOptions
11331135 resource = resource .substring (1 );
11341136 // this deliberately does not parseResourcesAnySyntax; if
11351137 // people want that they can use an include statement.
1136- return ConfigFactory .parseResources (loader , resource , overrideOptions );
1138+ return java . util . Optional . of ( ConfigFactory .parseResources (loader , resource , overrideOptions ) );
11371139 } else if (file != null ) {
1138- return ConfigFactory .parseFile (new File (file ), overrideOptions );
1140+ return java . util . Optional . of ( ConfigFactory .parseFile (new File (file ), overrideOptions ) );
11391141 } else {
11401142 try {
1141- return ConfigFactory .parseURL (new URL (url ), overrideOptions );
1143+ return java . util . Optional . of ( ConfigFactory .parseURL (new URL (url ), overrideOptions ) );
11421144 } catch (MalformedURLException e ) {
11431145 throw new ConfigException .Generic ("Bad URL in config.url system property: '"
11441146 + url + "': " + e .getMessage (), e );
0 commit comments