Skip to content

Commit

Permalink
Merge pull request #1170 from apache/fix/WW-5498-s7
Browse files Browse the repository at this point in the history
WW-5498 Adds devMode errors as action messages to avoid breaking validation logic
  • Loading branch information
lukaszlenart authored Jan 5, 2025
2 parents 026300b + db9684e commit fd24a4a
Show file tree
Hide file tree
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
Expand Up @@ -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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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'"));
}

Expand Down

0 comments on commit fd24a4a

Please sign in to comment.