Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[henshin-user] Problem with NullPointerException in ChangeImpl.applyAndReverse()

Hi all,
I have a problem with a NullPointerException in ChangeImpl.applyAndReverse().
We use Henshin within our tool where execute and undo a rule. The problem occurs during undo of a rule in which an attribute is set. See stack trace below.

The problem is that the field "attribute" is NULL when executing "oldValue = object.eGet(attribute);" (line 4 of snippet below)

01        public void applyAndReverse() {
02            // Need to initialize?
03            if (!initialized) {
04                oldValue = object.eGet(attribute);
05                if ((oldValue==null && newValue==null) ||
06                    (oldValue!=null && oldValue.equals(newValue))) {
07                    attribute = null;
08                }
09            }
10            // Nothing to do?
11            if (attribute==null) {
12                return;
13            }
14            ...

I think that the undo causes a second invocation of a change's applyAndReverse() where the first invocation resulted in setting "attribute = null;" (line 7)

I'm not sure what the reason is to set "attribute" to null, but it seems that when it is null it means that there is nothing to change and reverse (line 10).
So what works for me is changing line 4 to

04            if (!initialized && attribute != null) {


Best regards

Joel




!ENTRY org.eclipse.core.jobs 4 2 2016-07-24 03:57:55.506
!MESSAGE An internal error occurred during: "On-the-fly Controller Synthesis from SML specification".
!STACK 0
java.lang.NullPointerException
    at org.eclipse.emf.ecore.impl.EClassImpl.getFeatureID(EClassImpl.java:1500)
    at org.eclipse.emf.ecore.impl.DynamicEObjectImpl.eDerivedStructuralFeatureID(DynamicEObjectImpl.java:218)
    at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eGet(BasicEObjectImpl.java:1008)
    at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eGet(BasicEObjectImpl.java:1003)
    at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eGet(BasicEObjectImpl.java:998)
    at org.eclipse.emf.henshin.interpreter.impl.ChangeImpl$AttributeChangeImpl.applyAndReverse(ChangeImpl.java:134)
    at org.eclipse.emf.henshin.interpreter.impl.ChangeImpl$CompoundChangeImpl.applyAndReverse(ChangeImpl.java:466)
    at org.eclipse.emf.henshin.interpreter.impl.RuleApplicationImpl.undo(RuleApplicationImpl.java:126)
    at org.scenariotools.sml.runtime.henshin.logic.HenshinMessageEventsSideEffectsExecutorLogic.canExecuteSideEffects(HenshinMessageEventsSideEffectsExecutorLogic.java:133)
    ...


Back to the top