[MAGNOLIA-7695] JcrExportCommand$DefaultFilter#setNodePredicate can produce misleading exception Created: 10/Dec/19 Updated: 15/Apr/21 |
|
| Status: | Open |
| Project: | Magnolia |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Trivial |
| Reporter: | Richard Gange | Assignee: | Unassigned |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | light-development | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||
| Template: |
|
||||
| Acceptance criteria: |
Empty
|
||||
| Task DoD: |
[ ]*
Doc/release notes changes? Comment present?
[ ]*
Downstream builds green?
[ ]*
Solution information and context easily available?
[ ]*
Tests
[ ]*
FixVersion filled and not yet released
[ ] 
Architecture Decision Record (ADR)
|
||||
| Bug DoR: |
[ ]*
Steps to reproduce, expected, and actual results filled
[ ]*
Affected version filled
|
||||
| Description |
|
If you happen to trigger the exception here: @Override
public NodeFilteringPredicate getNodePredicate() {
return (NodeFilteringPredicate) super.getNodePredicate();
}
@Override
public void setNodePredicate(AbstractPredicate<Node> propertyPredicate) {
if (propertyPredicate instanceof NodeFilteringPredicate) {
super.setNodePredicate(propertyPredicate);
} else {
throw new IllegalArgumentException(String.format("Expected instances of {%s} but got {%s}", PropertyFilteringPredicate.class, propertyPredicate.getClass()));
}
}
You can end up with a misleading error message about expecting a PropertyFilteringPredicate. When really it should be expecting a NodeFilteringPredicate. It looks like the result of a careless copy paste from the above DefaultFilter#setPropertyPredicate method which led to this issue. 2019-12-05 15:02:13,426 ERROR fo.magnolia.ui.contentapp.browser.BrowserPresenter: An error occurred while executing action [MyAction]
info.magnolia.ui.api.action.ActionExecutionException: Action execution failed for action: MyAction
at info.magnolia.ui.api.action.AbstractActionExecutor.execute(AbstractActionExecutor.java:64) ~[magnolia-ui-api-5.6.10.jar:?]
Caused by: java.lang.IllegalArgumentException: Expected instances of {class info.magnolia.jcr.predicate.PropertyFilteringPredicate} but got {class ch.uzh.module.versioning.MyPredicate}
at info.magnolia.importexport.command.JcrExportCommand$DefaultFilter.setNodePredicate(JcrExportCommand.java:233) ~[magnolia-core-5.6.10.jar:?]
|