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);
     }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.