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


!ENTRY 4 2 2016-07-24 03:57:55.506
!MESSAGE An internal error occurred during: "On-the-fly Controller Synthesis from SML specification".
    at org.eclipse.emf.ecore.impl.EClassImpl.getFeatureID(
    at org.eclipse.emf.ecore.impl.DynamicEObjectImpl.eDerivedStructuralFeatureID(
    at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eGet(
    at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eGet(
    at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eGet(
    at org.eclipse.emf.henshin.interpreter.impl.ChangeImpl$AttributeChangeImpl.applyAndReverse(
    at org.eclipse.emf.henshin.interpreter.impl.ChangeImpl$CompoundChangeImpl.applyAndReverse(
    at org.eclipse.emf.henshin.interpreter.impl.RuleApplicationImpl.undo(
    at org.scenariotools.sml.runtime.henshin.logic.HenshinMessageEventsSideEffectsExecutorLogic.canExecuteSideEffects(

Back to the top