diff --git a/core/src/main/java/com/opensymphony/xwork2/config/entities/PackageConfig.java b/core/src/main/java/com/opensymphony/xwork2/config/entities/PackageConfig.java index e297b49f6..1e7a4dd78 100644 --- a/core/src/main/java/com/opensymphony/xwork2/config/entities/PackageConfig.java +++ b/core/src/main/java/com/opensymphony/xwork2/config/entities/PackageConfig.java @@ -600,22 +600,12 @@ public class PackageConfig extends Located implements Comparable, Serializable, } public Builder strictMethodInvocation(boolean strict) { - strictDMI = strict; + target.strictMethodInvocation = strict; return this; } public boolean isStrictMethodInvocation() { - // if Strict DMI was disabled in this package, - // return without evaluating parent packages - if (!strictDMI) { - return false; - } - for (PackageConfig parent : target.parents) { - if (parent.isStrictMethodInvocation()) { - return true; - } - } - return true; + return target.strictMethodInvocation; } public PackageConfig build() { diff --git a/core/src/test/java/com/opensymphony/xwork2/config/entities/PackageConfigTest.java b/core/src/test/java/com/opensymphony/xwork2/config/entities/PackageConfigTest.java index e2f2868c2..4a25ccba0 100644 --- a/core/src/test/java/com/opensymphony/xwork2/config/entities/PackageConfigTest.java +++ b/core/src/test/java/com/opensymphony/xwork2/config/entities/PackageConfigTest.java @@ -30,5 +30,63 @@ public class PackageConfigTest extends XWorkTestCase { assertEquals("ref2", cfg.getFullDefaultInterceptorRef()); } - -} \ No newline at end of file + + public void testStrictDMIInheritance() { + // given + PackageConfig parent = new PackageConfig.Builder("parent").build(); + + // when + PackageConfig child = new PackageConfig.Builder("child") + .addParent(parent) + .build(); + + // then + assertTrue(child.isStrictMethodInvocation()); + } + + public void testStrictDMIInheritanceDisabledInParentPackage() { + // given + PackageConfig parent = new PackageConfig.Builder("parent") + .strictMethodInvocation(false) + .build(); + + // when + PackageConfig child = new PackageConfig.Builder("child") + .addParent(parent) + .build(); + + // then + assertTrue(child.isStrictMethodInvocation()); + } + + public void testStrictDMIInheritanceDisabledInBothPackage() { + // given + PackageConfig parent = new PackageConfig.Builder("parent") + .strictMethodInvocation(false) + .build(); + + // when + PackageConfig child = new PackageConfig.Builder("child") + .addParent(parent) + .strictMethodInvocation(false) + .build(); + + // then + assertFalse(child.isStrictMethodInvocation()); + } + + public void testStrictDMIInheritanceDisabledInChildPackage() { + // given + PackageConfig parent = new PackageConfig.Builder("parent").build(); + + // when + PackageConfig child = new PackageConfig.Builder("child") + .addParent(parent) + .strictMethodInvocation(false) + .build(); + + // then + assertFalse(child.isStrictMethodInvocation()); + } + +}