Commits

Anonymous committed 7bb0a8f

Better handle packages loaded twice from the same file

git-svn-id: http://svn.opensymphony.com/svn/xwork/trunk@1141e221344d-f017-0410-9bd5-d282ab1896d7

Comments (0)

Files changed (1)

src/java/com/opensymphony/xwork2/config/impl/DefaultConfiguration.java

     public void addPackageConfig(String name, PackageConfig packageContext) {
         PackageConfig check = packageContexts.get(name);
         if (check != null) {
-            throw new ConfigurationException("The package name '" + name 
-                    + "' is already been used by another package: " + check.getLocation(),
-                    packageContext);
-            // would be better to throw ConfigurationException("name already used");
+            if (check.getLocation() != null && packageContext.getLocation() != null
+                    && check.getLocation().equals(packageContext.getLocation())) {
+                if (LOG.isDebugEnabled()) {
+                    LOG.debug("The package name '" + name 
+                    + "' is already been loaded by the same location and could be removed: " 
+                    + packageContext.getLocation());
+                } 
+            } else {
+                throw new ConfigurationException("The package name '" + name 
+                        + "' is already been used by another package: " + check.getLocation(),
+                        packageContext);
+            }
         }
         packageContexts.put(name, packageContext);
     }