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

TemplatingFunctions#handleRepositoryException suppresses possible NPE

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: Low Low
    • None
    • None
    • templating
    • None

      In the class info.magnolia.templating.functions.TemplatingFunctions if line 873 encounters a NullPointerException during `handleRepositoryException` then a side-effect is that the parameter `e` is ignored, loosing exception context to the other.

      We should consider refactoring the logic or adding a second catch to handle the null pointer gracefully.

          private void handleRepositoryException(RepositoryException e, String workspace) {
              final AggregationState aggregationState = webContextProvider.get().getAggregationState();
              String template;
              if (aggregationState != null) try {
                  template = NodeTypes.Renderable.getTemplate(aggregationState.getCurrentContentNode());
              } catch (RepositoryException re) {
                  log.error("Repository Exception: {}", re);
              }
              log.debug("Exception in '{}' workspace when rendering template '{}' for URI '{}': {}", workspace, template, aggregationState.getOriginalBrowserURI(), e);
      
          }
      

        Acceptance criteria

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

                Created:
                Updated:
                Resolved:

                  Bug DoR
                  Task DoD