(struts) 01/01: WW-5423 Fixes returning null instead of empty array in case of non-existing param
This is an automated email from the ASF dual-hosted git repository. lukaszlenart pushed a commit to branch fix/WW-5423-query-params in repository https://gitbox.apache.org/repos/asf/struts.git commit 3e72844fd042a874803029c84ce159dc8e7a4e18 Author: Lukasz Lenart AuthorDate: Tue Jun 4 11:52:19 2024 +0200 WW-5423 Fixes returning null instead of empty array in case of non-existing param --- .../struts2/dispatcher/multipart/AbstractMultiPartRequest.java | 7 +-- .../org/apache/struts2/dispatcher/multipart/MultiPartRequest.java | 1 + .../struts2/dispatcher/multipart/AbstractMultiPartRequestTest.java | 2 ++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/org/apache/struts2/dispatcher/multipart/AbstractMultiPartRequest.java b/core/src/main/java/org/apache/struts2/dispatcher/multipart/AbstractMultiPartRequest.java index 630d2ca43..f1b254238 100644 --- a/core/src/main/java/org/apache/struts2/dispatcher/multipart/AbstractMultiPartRequest.java +++ b/core/src/main/java/org/apache/struts2/dispatcher/multipart/AbstractMultiPartRequest.java @@ -372,8 +372,11 @@ public abstract class AbstractMultiPartRequest implements MultiPartRequest { * @see org.apache.struts2.dispatcher.multipart.MultiPartRequest#getParameterValues(java.lang.String) */ public String[] getParameterValues(String name) { -return parameters.getOrDefault(name, Collections.emptyList()) -.toArray(String[]::new); +List values = parameters.get(name); +if (values == null) { +return null; +} +return values.toArray(new String[0]); } /* (non-Javadoc) diff --git a/core/src/main/java/org/apache/struts2/dispatcher/multipart/MultiPartRequest.java b/core/src/main/java/org/apache/struts2/dispatcher/multipart/MultiPartRequest.java index 72392cd6f..dd801d306 100644 --- a/core/src/main/java/org/apache/struts2/dispatcher/multipart/MultiPartRequest.java +++ b/core/src/main/java/org/apache/struts2/dispatcher/multipart/MultiPartRequest.java @@ -95,6 +95,7 @@ public interface MultiPartRequest { /** * Returns a list of all parameter values associated with a parameter name. If there is only * one parameter value per name the resulting array will be of length 1. + * If the parameter doesn't exist, null should be returned instead of empty array. * * @param name the name of the parameter. * @return an array of all values associated with the parameter name. diff --git a/core/src/test/java/org/apache/struts2/dispatcher/multipart/AbstractMultiPartRequestTest.java b/core/src/test/java/org/apache/struts2/dispatcher/multipart/AbstractMultiPartRequestTest.java index fb30bb289..25b86d6b2 100644 --- a/core/src/test/java/org/apache/struts2/dispatcher/multipart/AbstractMultiPartRequestTest.java +++ b/core/src/test/java/org/apache/struts2/dispatcher/multipart/AbstractMultiPartRequestTest.java @@ -458,6 +458,8 @@ abstract class AbstractMultiPartRequestTest { .isEqualTo("short text"); assertThat(multiPart.getParameterValues("multi")) .containsOnly("multi1", "multi2"); +assertThat(multiPart.getParameterValues("not-existing")) +.isNull(); } @Test
(struts) branch fix/WW-5423-query-params created (now 3e72844fd)
This is an automated email from the ASF dual-hosted git repository. lukaszlenart pushed a change to branch fix/WW-5423-query-params in repository https://gitbox.apache.org/repos/asf/struts.git at 3e72844fd WW-5423 Fixes returning null instead of empty array in case of non-existing param This branch includes the following new commits: new 3e72844fd WW-5423 Fixes returning null instead of empty array in case of non-existing param The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference.
(struts) branch dependabot/maven/com.sun.xml.bind-jaxb-core-4.0.5 deleted (was 78105871b)
This is an automated email from the ASF dual-hosted git repository. lukaszlenart pushed a change to branch dependabot/maven/com.sun.xml.bind-jaxb-core-4.0.5 in repository https://gitbox.apache.org/repos/asf/struts.git was 78105871b Bump com.sun.xml.bind:jaxb-core from 2.3.0.1 to 4.0.5 The revisions that were on this branch are still contained in other references; therefore, this change does not discard any commits from the repository.
(struts) branch fix/WW-5424-class-cast-exception deleted (was 4a8ff99b1)
This is an automated email from the ASF dual-hosted git repository. lukaszlenart pushed a change to branch fix/WW-5424-class-cast-exception in repository https://gitbox.apache.org/repos/asf/struts.git was 4a8ff99b1 WW-5424 Fixes ClassCastException when using short var name in s:set tag The revisions that were on this branch are still contained in other references; therefore, this change does not discard any commits from the repository.
(struts) branch master updated (ee040babd -> 0cdce0574)
This is an automated email from the ASF dual-hosted git repository. lukaszlenart pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/struts.git from ee040babd Merge pull request #953 from apache/dependabot/maven/org.freemarker-freemarker-2.3.33 add 4a8ff99b1 WW-5424 Fixes ClassCastException when using short var name in s:set tag new 0cdce0574 Merge pull request #946 from apache/fix/WW-5424-class-cast-exception The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference. Summary of changes: .../java/org/apache/struts2/components/Set.java| 12 ++--- .../org/apache/struts2/views/jsp/SetTagTest.java | 58 ++ 2 files changed, 55 insertions(+), 15 deletions(-)
(struts) 01/01: Merge pull request #946 from apache/fix/WW-5424-class-cast-exception
This is an automated email from the ASF dual-hosted git repository. lukaszlenart pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/struts.git commit 0cdce05745c3c8ed201039bb48091c0a1d2b05d8 Merge: ee040babd 4a8ff99b1 Author: Lukasz Lenart AuthorDate: Wed Jun 5 07:05:11 2024 +0200 Merge pull request #946 from apache/fix/WW-5424-class-cast-exception [WW-5424] Fixes ClassCastException when using short var name in s:set tag .../java/org/apache/struts2/components/Set.java| 12 ++--- .../org/apache/struts2/views/jsp/SetTagTest.java | 58 ++ 2 files changed, 55 insertions(+), 15 deletions(-)
(struts) branch master updated (0cdce0574 -> a25173f65)
This is an automated email from the ASF dual-hosted git repository. lukaszlenart pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/struts.git from 0cdce0574 Merge pull request #946 from apache/fix/WW-5424-class-cast-exception add 00752e33c Disables required reviewers option This option doesn't play with Silence Consensus new a25173f65 Merge pull request #947 from apache/fix/no-reviewers-required The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference. Summary of changes: .asf.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
(struts) 01/01: Merge pull request #947 from apache/fix/no-reviewers-required
This is an automated email from the ASF dual-hosted git repository. lukaszlenart pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/struts.git commit a25173f65db8d0f0d6e319c481d06fb53eb78d50 Merge: 0cdce0574 00752e33c Author: Lukasz Lenart AuthorDate: Wed Jun 5 07:05:33 2024 +0200 Merge pull request #947 from apache/fix/no-reviewers-required Disables required reviewers option .asf.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
(struts) branch fix/no-reviewers-required deleted (was 00752e33c)
This is an automated email from the ASF dual-hosted git repository. lukaszlenart pushed a change to branch fix/no-reviewers-required in repository https://gitbox.apache.org/repos/asf/struts.git was 00752e33c Disables required reviewers option This option doesn't play with Silence Consensus The revisions that were on this branch are still contained in other references; therefore, this change does not discard any commits from the repository.
(struts) branch feature/WW-5412-master deleted (was 855b95e55)
This is an automated email from the ASF dual-hosted git repository. lukaszlenart pushed a change to branch feature/WW-5412-master in repository https://gitbox.apache.org/repos/asf/struts.git was 855b95e55 WW-5412 Upgrades struts-master to ver 15 The revisions that were on this branch are still contained in other references; therefore, this change does not discard any commits from the repository.
(struts) 01/01: Merge pull request #948 from apache/feature/WW-5412-master
This is an automated email from the ASF dual-hosted git repository. lukaszlenart pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/struts.git commit dcaff0bf108466442801c153bd4e20239afc1470 Merge: a25173f65 855b95e55 Author: Lukasz Lenart AuthorDate: Wed Jun 5 07:06:01 2024 +0200 Merge pull request #948 from apache/feature/WW-5412-master [WW-5412] Upgrades struts-master to ver 15 pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
(struts) branch master updated (a25173f65 -> dcaff0bf1)
This is an automated email from the ASF dual-hosted git repository. lukaszlenart pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/struts.git from a25173f65 Merge pull request #947 from apache/fix/no-reviewers-required add 855b95e55 WW-5412 Upgrades struts-master to ver 15 new dcaff0bf1 Merge pull request #948 from apache/feature/WW-5412-master The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference. Summary of changes: pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
(struts) branch fix/WW-5423-query-params updated (3e72844fd -> 5015ea0d9)
This is an automated email from the ASF dual-hosted git repository. lukaszlenart pushed a change to branch fix/WW-5423-query-params in repository https://gitbox.apache.org/repos/asf/struts.git discard 3e72844fd WW-5423 Fixes returning null instead of empty array in case of non-existing param add 5015ea0d9 WW-5423 Fixes returning null instead of empty array in case of non-existing param This update added new revisions after undoing existing revisions. That is to say, some revisions that were in the old version of the branch are not in the new version. This situation occurs when a user --force pushes a change and generates a repository containing something like this: * -- * -- B -- O -- O -- O (3e72844fd) \ N -- N -- N refs/heads/fix/WW-5423-query-params (5015ea0d9) You should already have received notification emails for all of the O revisions, and so the following emails describe only the N revisions from the common base, B. Any revisions marked "omit" are not gone; other references still refer to them. Any revisions marked "discard" are gone forever. No new revisions were added by this update. Summary of changes: .../dispatcher/multipart/AbstractMultiPartRequestTest.java | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-)
(struts) 01/01: WW-5414 Simplifies how CspSettings is created
This is an automated email from the ASF dual-hosted git repository. lukaszlenart pushed a commit to branch feature/WW-5414-refactor in repository https://gitbox.apache.org/repos/asf/struts.git commit 55b0483b33aa0a91ae930ce9c9a27f7b7452c52a Author: Lukasz Lenart AuthorDate: Wed Jun 5 07:35:42 2024 +0200 WW-5414 Simplifies how CspSettings is created --- .../struts2/interceptor/csp/CspInterceptor.java| 43 + .../struts2/interceptor/CspInterceptorTest.java| 55 +++--- 2 files changed, 60 insertions(+), 38 deletions(-) diff --git a/core/src/main/java/org/apache/struts2/interceptor/csp/CspInterceptor.java b/core/src/main/java/org/apache/struts2/interceptor/csp/CspInterceptor.java index 54d9eeab1..627825407 100644 --- a/core/src/main/java/org/apache/struts2/interceptor/csp/CspInterceptor.java +++ b/core/src/main/java/org/apache/struts2/interceptor/csp/CspInterceptor.java @@ -19,7 +19,9 @@ package org.apache.struts2.interceptor.csp; import com.opensymphony.xwork2.ActionInvocation; +import com.opensymphony.xwork2.config.ConfigurationException; import com.opensymphony.xwork2.interceptor.AbstractInterceptor; +import com.opensymphony.xwork2.util.ClassLoaderUtil; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.struts2.action.CspSettingsAware; @@ -48,7 +50,7 @@ public final class CspInterceptor extends AbstractInterceptor { private String reportUri; private String reportTo; -private String defaultCspSettingsClassName = DefaultCspSettings.class.getName(); +private String cspSettingsClassName = DefaultCspSettings.class.getName(); @Override public String intercept(ActionInvocation invocation) throws Exception { @@ -57,26 +59,28 @@ public final class CspInterceptor extends AbstractInterceptor { LOG.trace("Using CspSettings provided by the action: {}", action); applySettings(invocation, ((CspSettingsAware) action).getCspSettings()); } else { -LOG.trace("Using {} with action: {}", defaultCspSettingsClassName, action); +LOG.trace("Using {} with action: {}", cspSettingsClassName, action); +CspSettings cspSettings = createCspSettings(invocation); +applySettings(invocation, cspSettings); +} +return invocation.invoke(); +} -// if the defaultCspSettingsClassName is not a real class, throw an exception -try { -Class.forName(defaultCspSettingsClassName, false, Thread.currentThread().getContextClassLoader()); -} -catch (ClassNotFoundException e) { -throw new IllegalArgumentException("The defaultCspSettingsClassName must be a real class."); -} +private CspSettings createCspSettings(ActionInvocation invocation) throws ClassNotFoundException { +Class cspSettingsClass; -// if defaultCspSettingsClassName does not implement CspSettings, throw an exception -if (!CspSettings.class.isAssignableFrom(Class.forName(defaultCspSettingsClassName))) { -throw new IllegalArgumentException("The defaultCspSettingsClassName must implement CspSettings."); -} +try { +cspSettingsClass = ClassLoaderUtil.loadClass(cspSettingsClassName, getClass()); +} catch (ClassNotFoundException e) { +throw new ConfigurationException(String.format("The class %s doesn't exist!", cspSettingsClassName)); +} -CspSettings cspSettings = (CspSettings) Class.forName(defaultCspSettingsClassName) -.getDeclaredConstructor().newInstance(); -applySettings(invocation, cspSettings); +if (!CspSettings.class.isAssignableFrom(Class.forName(cspSettingsClassName))) { +throw new ConfigurationException(String.format("The class %s doesn't implement %s!", +cspSettingsClassName, CspSettings.class.getName())); } -return invocation.invoke(); + +return (CspSettings) invocation.getInvocationContext().getContainer().inject(cspSettingsClass); } private void applySettings(ActionInvocation invocation, CspSettings cspSettings) { @@ -127,7 +131,6 @@ public final class CspInterceptor extends AbstractInterceptor { * only be used if the reportUri is set. * * @param reportTo the report group where csp violation reports will be sent - * * @since Struts 6.5.0 */ public void setReportTo(String reportTo) { @@ -167,7 +170,7 @@ public final class CspInterceptor extends AbstractInterceptor { * * @since Struts 6.5.0 */ -public void setDefaultCspSettingsClassName(String defaultCspSettingsClassName) { -this.defaultCspSettingsClassName = defaultCspSettingsClassName; +public void setCspSettingsClassName(String cspSettingsClassName) { +this.cspSettings
(struts) branch feature/WW-5414-refactor created (now 55b0483b3)
This is an automated email from the ASF dual-hosted git repository. lukaszlenart pushed a change to branch feature/WW-5414-refactor in repository https://gitbox.apache.org/repos/asf/struts.git at 55b0483b3 WW-5414 Simplifies how CspSettings is created This branch includes the following new commits: new 55b0483b3 WW-5414 Simplifies how CspSettings is created The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference.
(struts) 01/01: WW-5400 Simplifies how CspSettings is created
This is an automated email from the ASF dual-hosted git repository. lukaszlenart pushed a commit to branch feature/WW-5400-refactor in repository https://gitbox.apache.org/repos/asf/struts.git commit eae2c834b3c3a3bfb064f4ba3aab52345d88df1a Author: Lukasz Lenart AuthorDate: Wed Jun 5 07:37:36 2024 +0200 WW-5400 Simplifies how CspSettings is created --- .../struts2/interceptor/csp/CspInterceptor.java| 43 + .../struts2/interceptor/CspInterceptorTest.java| 55 +++--- 2 files changed, 60 insertions(+), 38 deletions(-) diff --git a/core/src/main/java/org/apache/struts2/interceptor/csp/CspInterceptor.java b/core/src/main/java/org/apache/struts2/interceptor/csp/CspInterceptor.java index 54d9eeab1..627825407 100644 --- a/core/src/main/java/org/apache/struts2/interceptor/csp/CspInterceptor.java +++ b/core/src/main/java/org/apache/struts2/interceptor/csp/CspInterceptor.java @@ -19,7 +19,9 @@ package org.apache.struts2.interceptor.csp; import com.opensymphony.xwork2.ActionInvocation; +import com.opensymphony.xwork2.config.ConfigurationException; import com.opensymphony.xwork2.interceptor.AbstractInterceptor; +import com.opensymphony.xwork2.util.ClassLoaderUtil; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.struts2.action.CspSettingsAware; @@ -48,7 +50,7 @@ public final class CspInterceptor extends AbstractInterceptor { private String reportUri; private String reportTo; -private String defaultCspSettingsClassName = DefaultCspSettings.class.getName(); +private String cspSettingsClassName = DefaultCspSettings.class.getName(); @Override public String intercept(ActionInvocation invocation) throws Exception { @@ -57,26 +59,28 @@ public final class CspInterceptor extends AbstractInterceptor { LOG.trace("Using CspSettings provided by the action: {}", action); applySettings(invocation, ((CspSettingsAware) action).getCspSettings()); } else { -LOG.trace("Using {} with action: {}", defaultCspSettingsClassName, action); +LOG.trace("Using {} with action: {}", cspSettingsClassName, action); +CspSettings cspSettings = createCspSettings(invocation); +applySettings(invocation, cspSettings); +} +return invocation.invoke(); +} -// if the defaultCspSettingsClassName is not a real class, throw an exception -try { -Class.forName(defaultCspSettingsClassName, false, Thread.currentThread().getContextClassLoader()); -} -catch (ClassNotFoundException e) { -throw new IllegalArgumentException("The defaultCspSettingsClassName must be a real class."); -} +private CspSettings createCspSettings(ActionInvocation invocation) throws ClassNotFoundException { +Class cspSettingsClass; -// if defaultCspSettingsClassName does not implement CspSettings, throw an exception -if (!CspSettings.class.isAssignableFrom(Class.forName(defaultCspSettingsClassName))) { -throw new IllegalArgumentException("The defaultCspSettingsClassName must implement CspSettings."); -} +try { +cspSettingsClass = ClassLoaderUtil.loadClass(cspSettingsClassName, getClass()); +} catch (ClassNotFoundException e) { +throw new ConfigurationException(String.format("The class %s doesn't exist!", cspSettingsClassName)); +} -CspSettings cspSettings = (CspSettings) Class.forName(defaultCspSettingsClassName) -.getDeclaredConstructor().newInstance(); -applySettings(invocation, cspSettings); +if (!CspSettings.class.isAssignableFrom(Class.forName(cspSettingsClassName))) { +throw new ConfigurationException(String.format("The class %s doesn't implement %s!", +cspSettingsClassName, CspSettings.class.getName())); } -return invocation.invoke(); + +return (CspSettings) invocation.getInvocationContext().getContainer().inject(cspSettingsClass); } private void applySettings(ActionInvocation invocation, CspSettings cspSettings) { @@ -127,7 +131,6 @@ public final class CspInterceptor extends AbstractInterceptor { * only be used if the reportUri is set. * * @param reportTo the report group where csp violation reports will be sent - * * @since Struts 6.5.0 */ public void setReportTo(String reportTo) { @@ -167,7 +170,7 @@ public final class CspInterceptor extends AbstractInterceptor { * * @since Struts 6.5.0 */ -public void setDefaultCspSettingsClassName(String defaultCspSettingsClassName) { -this.defaultCspSettingsClassName = defaultCspSettingsClassName; +public void setCspSettingsClassName(String cspSettingsClassName) { +this.cspSettings
(struts) branch feature/WW-5400-refactor created (now eae2c834b)
This is an automated email from the ASF dual-hosted git repository. lukaszlenart pushed a change to branch feature/WW-5400-refactor in repository https://gitbox.apache.org/repos/asf/struts.git at eae2c834b WW-5400 Simplifies how CspSettings is created This branch includes the following new commits: new eae2c834b WW-5400 Simplifies how CspSettings is created The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference.
(struts) branch feature/WW-5414-refactor deleted (was 55b0483b3)
This is an automated email from the ASF dual-hosted git repository. lukaszlenart pushed a change to branch feature/WW-5414-refactor in repository https://gitbox.apache.org/repos/asf/struts.git was 55b0483b3 WW-5414 Simplifies how CspSettings is created The revisions that were on this branch are still contained in other references; therefore, this change does not discard any commits from the repository.
(struts) 01/01: WW-5400 Simplifies how CspSettings is created
This is an automated email from the ASF dual-hosted git repository. lukaszlenart pushed a commit to branch feature/WW-5400-refactor in repository https://gitbox.apache.org/repos/asf/struts.git commit 3a6ad5a5576f9a30957b5a93f06f950af5e616db Author: Lukasz Lenart AuthorDate: Wed Jun 5 07:37:36 2024 +0200 WW-5400 Simplifies how CspSettings is created --- .../struts2/interceptor/csp/CspInterceptor.java| 45 +- .../struts2/interceptor/CspInterceptorTest.java| 55 +++--- 2 files changed, 61 insertions(+), 39 deletions(-) diff --git a/core/src/main/java/org/apache/struts2/interceptor/csp/CspInterceptor.java b/core/src/main/java/org/apache/struts2/interceptor/csp/CspInterceptor.java index 54d9eeab1..49bc04d30 100644 --- a/core/src/main/java/org/apache/struts2/interceptor/csp/CspInterceptor.java +++ b/core/src/main/java/org/apache/struts2/interceptor/csp/CspInterceptor.java @@ -19,7 +19,9 @@ package org.apache.struts2.interceptor.csp; import com.opensymphony.xwork2.ActionInvocation; +import com.opensymphony.xwork2.config.ConfigurationException; import com.opensymphony.xwork2.interceptor.AbstractInterceptor; +import com.opensymphony.xwork2.util.ClassLoaderUtil; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.struts2.action.CspSettingsAware; @@ -48,7 +50,7 @@ public final class CspInterceptor extends AbstractInterceptor { private String reportUri; private String reportTo; -private String defaultCspSettingsClassName = DefaultCspSettings.class.getName(); +private String cspSettingsClassName = DefaultCspSettings.class.getName(); @Override public String intercept(ActionInvocation invocation) throws Exception { @@ -57,26 +59,28 @@ public final class CspInterceptor extends AbstractInterceptor { LOG.trace("Using CspSettings provided by the action: {}", action); applySettings(invocation, ((CspSettingsAware) action).getCspSettings()); } else { -LOG.trace("Using {} with action: {}", defaultCspSettingsClassName, action); +LOG.trace("Using {} with action: {}", cspSettingsClassName, action); +CspSettings cspSettings = createCspSettings(invocation); +applySettings(invocation, cspSettings); +} +return invocation.invoke(); +} -// if the defaultCspSettingsClassName is not a real class, throw an exception -try { -Class.forName(defaultCspSettingsClassName, false, Thread.currentThread().getContextClassLoader()); -} -catch (ClassNotFoundException e) { -throw new IllegalArgumentException("The defaultCspSettingsClassName must be a real class."); -} +private CspSettings createCspSettings(ActionInvocation invocation) throws ClassNotFoundException { +Class cspSettingsClass; -// if defaultCspSettingsClassName does not implement CspSettings, throw an exception -if (!CspSettings.class.isAssignableFrom(Class.forName(defaultCspSettingsClassName))) { -throw new IllegalArgumentException("The defaultCspSettingsClassName must implement CspSettings."); -} +try { +cspSettingsClass = ClassLoaderUtil.loadClass(cspSettingsClassName, getClass()); +} catch (ClassNotFoundException e) { +throw new ConfigurationException(String.format("The class %s doesn't exist!", cspSettingsClassName)); +} -CspSettings cspSettings = (CspSettings) Class.forName(defaultCspSettingsClassName) -.getDeclaredConstructor().newInstance(); -applySettings(invocation, cspSettings); +if (!CspSettings.class.isAssignableFrom(Class.forName(cspSettingsClassName))) { +throw new ConfigurationException(String.format("The class %s doesn't implement %s!", +cspSettingsClassName, CspSettings.class.getName())); } -return invocation.invoke(); + +return (CspSettings) invocation.getInvocationContext().getContainer().inject(cspSettingsClass); } private void applySettings(ActionInvocation invocation, CspSettings cspSettings) { @@ -127,7 +131,6 @@ public final class CspInterceptor extends AbstractInterceptor { * only be used if the reportUri is set. * * @param reportTo the report group where csp violation reports will be sent - * * @since Struts 6.5.0 */ public void setReportTo(String reportTo) { @@ -167,7 +170,7 @@ public final class CspInterceptor extends AbstractInterceptor { * * @since Struts 6.5.0 */ -public void setDefaultCspSettingsClassName(String defaultCspSettingsClassName) { -this.defaultCspSettingsClassName = defaultCspSettingsClassName; +public void setCspSettingsClassName(String cspSettingsClassName) { +this.cspSetting
(struts) branch feature/WW-5400-refactor updated (eae2c834b -> 3a6ad5a55)
This is an automated email from the ASF dual-hosted git repository. lukaszlenart pushed a change to branch feature/WW-5400-refactor in repository https://gitbox.apache.org/repos/asf/struts.git discard eae2c834b WW-5400 Simplifies how CspSettings is created new 3a6ad5a55 WW-5400 Simplifies how CspSettings is created This update added new revisions after undoing existing revisions. That is to say, some revisions that were in the old version of the branch are not in the new version. This situation occurs when a user --force pushes a change and generates a repository containing something like this: * -- * -- B -- O -- O -- O (eae2c834b) \ N -- N -- N refs/heads/feature/WW-5400-refactor (3a6ad5a55) You should already have received notification emails for all of the O revisions, and so the following emails describe only the N revisions from the common base, B. Any revisions marked "omit" are not gone; other references still refer to them. Any revisions marked "discard" are gone forever. The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference. Summary of changes: .../main/java/org/apache/struts2/interceptor/csp/CspInterceptor.java| 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)