-
Type:
Suggestion
-
Resolution: Unresolved
-
None
-
Component/s: Macros - 3rd Party, Server - Plugin Development
-
None
-
1
-
1
This feature request seeks to improve the reliability of the ServletActionContext.getRequest() method in Confluence, particularly for custom macro development. Currently, the method is documented to potentially return null in contexts where an HTTP request is unavailable, such as during space exports (which run as background tasks). However, instead of returning null as expected, the method throws a NullPointerException when ServletActionContext.getContext() is null. This behavior prevents developers from safely implementing null checks as recommended in the developer documentation How do I get hold of the HttpServletRequest, which states:
Please always assume that ServletActionContext.getRequest() will return null. Treat ServletActionContext as a bonus. If it's populated, you can do neat things with it, but don't rely on it.
The proposed feature would ensure that ServletActionContext.getRequest() consistently returns null when the request context is unavailable, rather than throwing an exception. This change would allow developers to follow the documented best practice of adding null checks, improving the reliability of custom macros and plugins in Confluence, especially during operations like space exports. This enhancement would align the method’s behavior with the documentation, making it more predictable and developer-friendly.