-
Bug
-
Resolution: Tracked Elsewhere
-
Low
-
None
-
8.9.4
-
1
-
Severity 3 - Minor
-
Issue Summary
This is reproducible on Data Center: (yes)
Confluence returns java.lang.NullPointerException while calling pageManager.getPages in user macro.
Steps to Reproduce
- Create a Confluence 8.9.4 version
- Set system property '-Dmacro.required.velocity.context.keys=spaceManager,pageManager'
- Create a user macro
- Add the below code to the user macro to list pages in specific space (In this sample the space key is DS);
## Macro title: Test Macro ## Macro has a body: Y or N ## ## Developed by: Test ## Date created: 25/07/2024 ## Installed by: My Macro ## @noparams #set($space = $spaceManager.getSpace("DS")) #foreach($page in $pageManager.getPages($spaceManager.getSpace($space.key), true)) $page #end
- After adding this macro to a page, it causes java.lang.NullPointerException in the logs;
2024-07-25 10:50:26,779 ERROR [http-nio-8090-exec-4 url: /confluence/display/MS/New+Page+User+Macro, /confluence/pages/viewpage.action; user: admin] [confluence.impl.velocity.VelocityEngineRenderingService] getRenderedContent Failed to render template content -- page: 393247 | referer: https://linux-76562.prod.atl-cd.net/confluence/display/MS/My+Space | traceId: 21023079959710ba | userName: admin | action: viewpage | url: /confluence/display/MS/New+Page+User+Macro java.lang.NullPointerException at com.atlassian.velocity.htmlsafe.introspection.ReturnValueAnnotator.getAnnotationsForMethod(ReturnValueAnnotator.java:34) at com.atlassian.velocity.htmlsafe.introspection.AnnotationBoxingUberspect.getMethodAnnotations(AnnotationBoxingUberspect.java:341) at com.atlassian.velocity.htmlsafe.introspection.HtmlSafeAnnotationBoxingUberspect.getMethodAnnotations(HtmlSafeAnnotationBoxingUberspect.java:28) at com.atlassian.confluence.velocity.introspection.ConfluenceAnnotationBoxingUberspect.getMethodAnnotations(ConfluenceAnnotationBoxingUberspect.java:24) at com.atlassian.velocity.htmlsafe.introspection.AnnotationBoxingUberspect.getMethod(AnnotationBoxingUberspect.java:131) at org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:192) at org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTReference.java:262) at org.apache.velocity.runtime.parser.node.ASTReference.value(ASTReference.java:507) at org.apache.velocity.runtime.parser.node.ASTExpression.value(ASTExpression.java:71) at org.apache.velocity.runtime.parser.node.ASTSetDirective.render(ASTSetDirective.java:142) at org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:72) at org.apache.velocity.runtime.directive.Foreach.performIteration(Foreach.java:393) at org.apache.velocity.runtime.directive.Foreach.render(Foreach.java:316) at org.apache.velocity.runtime.parser.node.ASTDirective.render(ASTDirective.java:175) at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:336) at org.apache.velocity.runtime.RuntimeInstance.render(RuntimeInstance.java:1276) at org.apache.velocity.runtime.RuntimeInstance.evaluate(RuntimeInstance.java:1215) at org.apache.velocity.runtime.RuntimeInstance.evaluate(RuntimeInstance.java:1164) at org.apache.velocity.app.VelocityEngine.evaluate(VelocityEngine.java:219) at com.atlassian.confluence.impl.velocity.VelocityEngineRenderingService.getRenderedContentWithoutSwallowingErrors(VelocityEngineRenderingService.java:63) at com.atlassian.confluence.impl.velocity.VelocityEngineRenderingService.getRenderedContent(VelocityEngineRenderingService.java:52)
The issue is not reproducible by using Confluence 8.5.12.
Expected Results
After adding the macro to a page, pages should be listed that are located in a specific space.
Actual Results
The user macro causes java.lang.NullPointerException.
Workaround
There is no available workaround for this issue.
- split to
-
CONFSERVER-97878 $pageManager not available in default Velocity context
-
- Closed
-
-
CONFSERVER-97879 Using the foreach directive with a context item that is blocked by the Introspector in a Velocity template will throw an unhandled exception
-
- Closed
-
(1 mentioned in)
Form Name |
---|
This report has been split into the following 2 independent issues:
CONFSERVER-97878$pageManager not available in default Velocity contextCONFSERVER-97879Using the foreach directive with a null value in a Velocity template will throw an unhandled exception