Skip to content

Commit

Permalink
WW-5498 Adds devMode errors as action messages to avoid breaking vali…
Browse files Browse the repository at this point in the history
…dation logic
lukaszlenart committed Jan 5, 2025
1 parent ac9a02c commit db9684e
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion core/src/main/java/org/apache/struts2/util/DebugUtils.java
Original file line number Diff line number Diff line change
@@ -38,7 +38,7 @@ public static void notifyDeveloperOfError(Logger log, Object action, String mess
}
log.error(message);
if (action instanceof ValidationAware validationAware) {
validationAware.addActionError(message);
validationAware.addActionMessage(message);
}
}

Original file line number Diff line number Diff line change
@@ -117,9 +117,9 @@ public void testInsecureParameters() throws Exception {
pi.applyParameters(action, vs, HttpParameters.create(params).build());

// then
assertEquals(3, action.getActionErrors().size());
assertEquals(3, action.getActionMessages().size());

List<String> actionErrors = new ArrayList<>(action.getActionErrors());
List<String> actionErrors = new ArrayList<>(action.getActionMessages());

String msg1 = actionErrors.get(0);
String msg2 = actionErrors.get(1);
@@ -204,9 +204,9 @@ protected boolean isExcluded(String paramName) {
pi.applyParameters(action, vs, HttpParameters.create(params).build());

// then
assertEquals(3, action.getActionErrors().size());
assertEquals(3, action.getActionMessages().size());

List<String> actionErrors = new ArrayList<>(action.getActionErrors());
List<String> actionErrors = new ArrayList<>(action.getActionMessages());
String msg1 = actionErrors.get(0);
String msg2 = actionErrors.get(1);
String msg3 = actionErrors.get(2);
@@ -586,7 +586,7 @@ public void testNonexistentParametersGetLoggedInDevMode() throws Exception {
container.inject(config.getInterceptors().get(0).getInterceptor());
ActionProxy proxy = actionProxyFactory.createActionProxy("", MockConfigurationProvider.PARAM_INTERCEPTOR_ACTION_NAME, null, extraContext.getContextMap());
proxy.execute();
final String actionError = "" + ((SimpleAction) proxy.getAction()).getActionErrors().toArray()[0];
final String actionError = "" + ((SimpleAction) proxy.getAction()).getActionMessages().toArray()[0];
assertTrue(actionError.contains("Error setting expression 'not_a_property' with value 'There is no action property named like this'"));
}

0 comments on commit db9684e

Please sign in to comment.