[MGNLUI-8032] Compatibility layer: Restore version throws null pointer Created: 02/May/23  Updated: 20/Jun/23  Resolved: 12/Jun/23

Status: Closed
Project: Magnolia UI
Component/s: app framework
Affects Version/s: 6.2.33
Fix Version/s: 6.2.36

Type: Bug Priority: Neutral
Reporter: Richard Gange Assignee: Jaromir Sarf
Resolution: Fixed Votes: 0
Labels: VN-Testing, compatibility-module
Σ Remaining Estimate: Not Specified Remaining Estimate: Not Specified
Σ Time Spent: 3h Time Spent: 3h
Σ Original Estimate: Not Specified Original Estimate: Not Specified

Attachments: PNG File null-pointer.png     PNG File restore-version.png     Text File stacktrace-full.txt    
Issue Links:
causality
relation
Sub-Tasks:
Key
Summary
Type
Status
Assignee
MGNLUI-8107 Implementation Sub-task Completed Jaromir Sarf  
MGNLUI-8108 Code review Sub-task Completed Quach Hao Thien  
MGNLUI-8109 Pre-Integration QA Sub-task Completed Quach Hao Thien  
MGNLUI-8110 QA Sub-task Closed Antonín Juran  
Template:
Acceptance criteria:
Empty
Task DoD:
[X]* Doc/release notes changes? Comment present?
[X]* Downstream builds green?
[X]* Solution information and context easily available?
[X]* Tests
[X]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[X]* Steps to reproduce, expected, and actual results filled
[X]* Affected version filled
Release notes required:
Yes
Date of First Response:
Epic Link: Old framework
Sprint: Nucleus 38
Story Points: 2
Team: Nucleus
Work Started:
Approved:
Yes

 Description   

The Restore version action throws a null pointer.

Reproduce

  1. Using the compatibility Pages app create a version of any page (i.e. publish a page).
  2. Try and restore the version created

Expected
The version selected is restored.

Actual
A null pointer is thrown stacktrace-full.txt

ERROR info.magnolia.ui.contentapp.browser.action.RestoreVersionAction 02.05.2023 13:22:36 -- Restoring of version failed. java.lang.NullPointerException
javax.jcr.RepositoryException: java.lang.NullPointerException
	at info.magnolia.ui.contentapp.browser.action.RestoreVersionAction.createVersionBeforeRestore(RestoreVersionAction.java:197) ~[magnolia-ui-framework-compatibility-6.2.33.jar:?]
	at info.magnolia.ui.contentapp.browser.action.RestoreVersionAction.restoreVersion(RestoreVersionAction.java:222) ~[magnolia-ui-framework-compatibility-6.2.33.jar:?]
	at info.magnolia.ui.contentapp.browser.action.RestoreVersionAction.access$800(RestoreVersionAction.java:75) ~[magnolia-ui-framework-compatibility-6.2.33.jar:?]
	at info.magnolia.ui.contentapp.browser.action.RestoreVersionAction$1.onSuccess(RestoreVersionAction.java:143) [magnolia-ui-framework-compatibility-6.2.33.jar:?]
	at info.magnolia.ui.dialog.formdialog.FormDialogPresenterImpl$1.onSuccess(FormDialogPresenterImpl.java:146) [magnolia-ui-framework-compatibility-6.2.33.jar:?]
...
...
Caused by: java.lang.NullPointerException
	at info.magnolia.context.RequestAttributeStrategy.setAttribute(RequestAttributeStrategy.java:165) ~[magnolia-core-6.2.33.jar:?]
	at info.magnolia.context.AbstractContext.setAttribute(AbstractContext.java:114) ~[magnolia-core-6.2.33.jar:?]
	at info.magnolia.commands.impl.VersionCommand.execute(VersionCommand.java:101) ~[magnolia-core-6.2.33.jar:?]
	at info.magnolia.ui.contentapp.browser.action.RestoreVersionAction.createVersionBeforeRestore(RestoreVersionAction.java:195) ~[magnolia-ui-framework-compatibility-6.2.33.jar:?]
	... 140 more

Workaround
Use the UI6 (aka new) Pages app to restore the version.

Notes
Looking closer the null pointer occurs on Line 195 of RestoreVersionAction where the versionCommand calls execute(). Line 101 of VersionCommand#execute() where setAttribute() is called ultimately throws the null because Line 165 of RequestAttributeStrategy#setAttribute() returns null from getRequest().



 Comments   
Comment by Jaromir Sarf [ 26/May/23 ]

Discovery:
The bug is caused by this PR https://git.magnolia-cms.com/projects/PLATFORM/repos/ui/commits/45b7b794430b51d142093603d2974b138e1c13c8#magnolia-ui-framework-compatibility/src/main/java/info/magnolia/ui/contentapp/browser/action/RestoreVersionAction.java?f=196. The solution could be to restore changes in RestoreVersionAction.java file.

Comment by Quach Hao Thien [ 26/May/23 ]

Double check with this ticket on implementing: https://jira.magnolia-cms.com/browse/MAGNOLIA-8524

Generated at Mon Feb 12 09:51:30 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.