@@ -2561,67 +2561,65 @@ public FileLike getStartupPropDirectory()
25612561 private void loadStartupProps ()
25622562 {
25632563 FileLike propsDir = getStartupPropDirectory ();
2564- if (null == propsDir )
2565- return ;
2566-
2567- if (!propsDir .isDirectory ())
2568- return ;
25692564
2570- FileLike newinstall = propsDir .resolveChild ("newinstall" );
2571- if (newinstall .isFile ())
2565+ if (null != propsDir && propsDir .isDirectory ())
25722566 {
2573- _log .debug ("'newinstall' file detected: {}" , newinstall .toNioPathForRead ());
2567+ FileLike newinstall = propsDir .resolveChild ("newinstall" );
2568+ if (newinstall .isFile ())
2569+ {
2570+ _log .debug ("'newinstall' file detected: {}" , newinstall .toNioPathForRead ());
25742571
2575- _newInstall = true ;
2572+ _newInstall = true ;
25762573
2577- // propsDir is readonly, so we need to cheat to get a File
2578- var newInstallFile = newinstall .toNioPathForRead ().toFile ();
2579- if (newInstallFile .canWrite ())
2580- newInstallFile .delete ();
2574+ // propsDir is readonly, so we need to cheat to get a File
2575+ var newInstallFile = newinstall .toNioPathForRead ().toFile ();
2576+ if (newInstallFile .canWrite ())
2577+ newInstallFile .delete ();
2578+ else
2579+ throw new ConfigurationException ("file 'newinstall' exists, but is not writeable: " + newinstall .toNioPathForRead ());
2580+ }
25812581 else
2582- throw new ConfigurationException ("file 'newinstall' exists, but is not writeable: " + newinstall .toNioPathForRead ());
2583- }
2584- else
2585- {
2586- _log .debug ("no 'newinstall' file detected" );
2587- }
2588-
2589- List <FileLike > propFiles = propsDir .getChildren ().stream ().filter (f -> f .getName ().endsWith (".properties" )).toList ();
2582+ {
2583+ _log .debug ("no 'newinstall' file detected" );
2584+ }
25902585
2591- if (!propFiles .isEmpty ())
2592- {
2593- List <FileLike > sortedPropFiles = propFiles .stream ()
2594- .sorted (Comparator .comparing (FileLike ::getName ).reversed ())
2595- .toList ();
2586+ List <FileLike > propFiles = propsDir .getChildren ().stream ().filter (f -> f .getName ().endsWith (".properties" )).toList ();
25962587
2597- for ( FileLike propFile : sortedPropFiles )
2588+ if (! propFiles . isEmpty () )
25982589 {
2599- _log .debug ("loading propsFile: {}" , propFile .toNioPathForRead ());
2590+ List <FileLike > sortedPropFiles = propFiles .stream ()
2591+ .sorted (Comparator .comparing (FileLike ::getName ).reversed ())
2592+ .toList ();
26002593
2601- try ( InputStream in = propFile . openInputStream () )
2594+ for ( FileLike propFile : sortedPropFiles )
26022595 {
2603- Properties props = new Properties ();
2604- props .load (in );
2596+ _log .debug ("loading propsFile: {}" , propFile .toNioPathForRead ());
26052597
2606- for ( Map . Entry < Object , Object > entry : props . entrySet ())
2598+ try ( InputStream in = propFile . openInputStream ())
26072599 {
2608- if (entry .getKey () instanceof String && entry .getValue () instanceof String )
2600+ Properties props = new Properties ();
2601+ props .load (in );
2602+
2603+ for (Map .Entry <Object , Object > entry : props .entrySet ())
26092604 {
2610- _log .trace ("property '{}' resolved to value: '{}'" , entry .getKey (), entry .getValue ());
2605+ if (entry .getKey () instanceof String && entry .getValue () instanceof String )
2606+ {
2607+ _log .trace ("property '{}' resolved to value: '{}'" , entry .getKey (), entry .getValue ());
26112608
2612- addStartupPropertyEntry (entry .getKey ().toString (), entry .getValue ().toString ());
2609+ addStartupPropertyEntry (entry .getKey ().toString (), entry .getValue ().toString ());
2610+ }
26132611 }
26142612 }
2615- }
2616- catch ( Exception e )
2617- {
2618- _log . error ( "Error parsing startup config properties file '{}'" , propFile . toNioPathForRead (), e );
2613+ catch ( Exception e )
2614+ {
2615+ _log . error ( "Error parsing startup config properties file '{}'" , propFile . toNioPathForRead (), e );
2616+ }
26192617 }
26202618 }
2621- }
2622- else
2623- {
2624- _log . debug ( "no propFiles to load" );
2619+ else
2620+ {
2621+ _log . debug ( "no propFiles to load" );
2622+ }
26252623 }
26262624
26272625 // load any system properties with the labkey prop prefix
0 commit comments