Skip to main content

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

Hi Daniel,
please go ahead an commit the change as you see fit.

Thanks,

Joel



On 24.07.2016 13:04, Daniel Strüber wrote:
Hi Joel,

Am 24.07.2016 um 04:15 schrieb Joel Greenyer:
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,
This looks a bit odd to me as well. My guess would be that setting "attribute" to null is used to permanently mark the change as an empty one, but then, this doesn't sound particularly clean, and also the handling of undo is broken, as you have pointed out.

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) {
Makes sense to me. Can you commit a change to Gerrit (see [1] for brief explanations)? Otherwise, I can do so as well.

[1] https://wiki.eclipse.org/Gerrit#To_create_a_new_change

Regards,
Daniel



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)
    ...
_______________________________________________
henshin-user mailing list
henshin-user@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/henshin-user



--
Prof. Dr. Joel Greenyer
Software Engineering for Ubiquitous Applications and Dynamic Interacting Systems
Leibniz Universität Hannover
Welfengarten 1, Room G322 (Main Building), 30167 Hannover, Germany
Phone: +49 511 762 3361
greenyer@xxxxxxxxxxxxxxxxxxx
http://jgreen.de

Back to the top