-
Notifications
You must be signed in to change notification settings - Fork 810
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WW-5429 Log parameter annotation issues at ERROR level when in DevMode #969
Conversation
f1ddc88
to
35ca03c
Compare
35ca03c
to
b96cf2c
Compare
@@ -119,7 +119,9 @@ public interface ValidationAware { | |||
* | |||
* @return <code>(hasActionErrors() || hasFieldErrors())</code> | |||
*/ | |||
boolean hasErrors(); | |||
default boolean hasErrors() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added default implementation which matches the JavaDoc, makes implementing this class simpler
@@ -42,7 +42,7 @@ public ErrorMessageBuilder errorSettingExpressionWithValue(String expr, Object v | |||
return this; | |||
} | |||
|
|||
private void appenExpression(String expr) { | |||
private void appendExpression(String expr) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed typo
*/ | ||
public class DebugUtils { | ||
|
||
public static void notifyDeveloperOfError(Logger log, Object action, String message) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extracted this method out of ParametersInterceptor
for reuse
@@ -116,15 +116,17 @@ public void testInsecureParameters() throws Exception { | |||
pi.setParameters(action, vs, HttpParameters.create(params).build()); | |||
|
|||
// then | |||
assertEquals(3, action.getActionMessages().size()); | |||
assertEquals(3, action.getActionErrors().size()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using Action errors instead of Action messages to communicate developer errors (only impacts DevMode)
String msg2 = actionErrors.get(1); | ||
String msg3 = actionErrors.get(2); | ||
|
||
assertEquals("Unexpected Exception caught setting 'expression' on 'class org.apache.struts2.interceptor.parameter.ValidateAction: Error setting expression 'expression' with value '#f=#_memberAccess.getClass().getDeclaredField('allowStaticMethodAccess'),#f.setAccessible(true),#f.set(#_memberAccess,true),#[email protected]@getRequest(),#[email protected]@getResponse().getWriter(),#resp.println(#req.getRealPath('/')),#resp.close()'", msg1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These messages now include both the context message as well as the exception message. Whilst they are very similar in this test example, it's not guaranteed to be the case
@@ -26,7 +26,7 @@ | |||
* ValidationAware classes can accept Action (class level) or field level error messages. Action level messages are kept | |||
* in a Collection. Field level error messages are kept in a Map from String field name to a List of field error msgs. | |||
* | |||
* @author plightbo | |||
* @author plightbo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can remove the @author
tag next time (recommended by ASF)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done :)
/** | ||
* @since 6.5.0 | ||
*/ | ||
public class DebugUtils { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can this be final
or maybe make an interface which can be mixed in?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made it final, not sure it makes sense as a mix-in interface
Quality Gate failedFailed conditions |
WW-5429