Uploaded image for project: 'Magnolia'
  1. Magnolia
  2. MAGNOLIA-7695

JcrExportCommand$DefaultFilter#setNodePredicate can produce misleading exception

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Trivial Trivial
    • None
    • None
    • None

      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:?]
      

        Acceptance criteria

              Unassigned Unassigned
              rgange Richard Gange
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:

                  Bug DoR
                  Task DoD