@@ -1027,11 +1027,11 @@ public synchronized void reloadConfiguration() {
10271027 properties = null ; // trigger reload
10281028 finalParameters .clear (); // clear site-limits
10291029 }
1030-
1030+
10311031 private synchronized void addResourceObject (Resource resource ) {
10321032 resources .add (resource ); // add to resources
10331033 restrictSystemProps |= resource .isParserRestricted ();
1034- reloadConfiguration ( );
1034+ loadProps ( properties , resources . size () - 1 , false );
10351035 }
10361036
10371037 private static final int MAX_SUBST = 20 ;
@@ -2876,12 +2876,28 @@ public Set<String> getFinalParameters() {
28762876 protected synchronized Properties getProps () {
28772877 if (properties == null ) {
28782878 properties = new Properties ();
2879- Map <String , String []> backup = updatingResource != null ?
2880- new ConcurrentHashMap <String , String []>(updatingResource ) : null ;
2881- loadResources (properties , resources , quietmode );
2879+ loadProps (properties , 0 , true );
2880+ }
2881+ return properties ;
2882+ }
28822883
2884+ /**
2885+ * Loads the resource at a given index into the properties.
2886+ * @param props the object containing the loaded properties.
2887+ * @param startIdx the index where the new resource has been added.
2888+ * @param fullReload flag whether we do complete reload of the conf instead
2889+ * of just loading the new resource.
2890+ * @return the properties loaded from the resource.
2891+ */
2892+ private synchronized Properties loadProps (final Properties props ,
2893+ final int startIdx , final boolean fullReload ) {
2894+ if (props != null ) {
2895+ Map <String , String []> backup =
2896+ updatingResource != null
2897+ ? new ConcurrentHashMap <>(updatingResource ) : null ;
2898+ loadResources (props , resources , startIdx , fullReload , quietmode );
28832899 if (overlay != null ) {
2884- properties .putAll (overlay );
2900+ props .putAll (overlay );
28852901 if (backup != null ) {
28862902 for (Map .Entry <Object , Object > item : overlay .entrySet ()) {
28872903 String key = (String ) item .getKey ();
@@ -2893,7 +2909,7 @@ protected synchronized Properties getProps() {
28932909 }
28942910 }
28952911 }
2896- return properties ;
2912+ return props ;
28972913 }
28982914
28992915 /**
@@ -2995,14 +3011,16 @@ private XMLStreamReader parse(InputStream is, String systemIdStr,
29953011
29963012 private void loadResources (Properties properties ,
29973013 ArrayList <Resource > resources ,
3014+ int startIdx ,
3015+ boolean fullReload ,
29983016 boolean quiet ) {
2999- if (loadDefaults ) {
3017+ if (loadDefaults && fullReload ) {
30003018 for (String resource : defaultResources ) {
30013019 loadResource (properties , new Resource (resource , false ), quiet );
30023020 }
30033021 }
30043022
3005- for (int i = 0 ; i < resources .size (); i ++) {
3023+ for (int i = startIdx ; i < resources .size (); i ++) {
30063024 Resource ret = loadResource (properties , resources .get (i ), quiet );
30073025 if (ret != null ) {
30083026 resources .set (i , ret );
0 commit comments