Uploaded image for project: 'XWiki Rendering'
  1. XWiki Rendering
  2. XRENDERING-748

A macro with a null descriptor completely breaks the macro picker (NPE)

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Minor
    • None
    • 16.4.0
    • Macro
    • None
    • Unknown

    Description

      There is a NPE when the macroId is null in DefaultMacroCategoryManager.getMacroCategories().

      When there is a macro that returns a null descriptor, the macro listing completely breaks in the WYSIWYG editor.

      A null macro id should never happen, it would only in case of a programming mistake. However, I think logging an error would be more appropriate.

      The NPE is at: https://github.com/xwiki/xwiki-rendering/blob/8fcf6ac112103b0b1d0f79d4b5624d2cfe05ce39/xwiki-rendering-transformations/xwiki-rendering-transformation-macro/src/main/java/org/xwiki/rendering/internal/macro/DefaultMacroCategoryManager.java#L116

      The trace:

      Caused by: java.lang.NullPointerException: Cannot invoke "org.xwiki.rendering.macro.MacroId.getId()" because "macroId" is null
       at org.xwiki.rendering.internal.macro.DefaultMacroCategoryManager.getMacroCategories(DefaultMacroCategoryManager.java:116)
       at org.xwiki.rendering.script.RenderingScriptService.getMacroCategories(RenderingScriptService.java:301)
       at jdk.internal.reflect.GeneratedMethodAccessor1696.invoke(Unknown Source)
       at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
       at java.base/java.lang.reflect.Method.invoke(Method.java:568)
       at org.apache.velocity.util.introspection.UberspectImpl$VelMethodImpl.doInvoke(UberspectImpl.java:571)
       at org.apache.velocity.util.introspection.UberspectImpl$VelMethodImpl.invoke(UberspectImpl.java:554)
       at org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:221)
       ... 257 more
      

      The getMacroIdsByCategory method should probably be checked as well.

      The call to getMacroCategories comes from CKEditor.MacroService.

      At https://github.com/xwiki/xwiki-platform/blob/0ddc451a08d512f0b092bfe9923f0e42b6e62967/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/src/main/java/org/xwiki/rendering/script/RenderingScriptService.java#L254: this.macroManager.getMacro(id).getDescriptor() returns null.

      Attachments

        Activity

          People

            Unassigned Unassigned
            rjakse Raphaël Jakse
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated: