[MGNLGROOVY-145] NPE in in ConsoleContext when strategy is not set (when executing console OUT of web context (on a separate thread for example) Created: 18/Mar/16  Updated: 29/Mar/16  Resolved: 29/Mar/16

Status: Closed
Project: Magnolia Groovy Module
Component/s: None
Affects Version/s: 2.4.3
Fix Version/s: None

Type: Bug Priority: Critical
Reporter: Jan Haderka Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
causality
caused by MGNLGROOVY-142 Refactor module to use Node API inste... Closed
duplicate
is duplicated by MGNLGROOVY-144 GroovyBugError: BUG! exception in pha... Closed
Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled
Date of First Response:

 Description   
Caused by: java.lang.NullPointerException
	at info.magnolia.context.RequestAttributeStrategy.getAttribute(RequestAttributeStrategy.java:83)
	at info.magnolia.context.AbstractContext.getAttribute(AbstractContext.java:107)
	at info.magnolia.context.ContextDecorator.getAttribute(ContextDecorator.java:74)
	at info.magnolia.module.groovy.console.MgnlGroovyConsoleContext.getRepositoryStrategy(MgnlGroovyConsoleContext.java:111)

(Ugly) workaround is to set strategy explicitly to null to prevent this error before invoking console on the context:

            final String STRATEGY_ATTRIBUTE = MgnlGroovyConsole.class.getName() + ".strategy";
            groovyCtx.setAttribute(STRATEGY_ATTRIBUTE, null, Context.SESSION_SCOPE);
...
            MgnlContext.setInstance(groovyCtx);
            MgnlGroovyConsole console = new MgnlGroovyConsole(new Binding());


Generated at Mon Feb 12 05:56:02 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.