|
|
|
|
|
|
Re: Adapters [message #1745388 is a reply to message #1745278] |
Mon, 10 October 2016 05:43 |
Ludwig Moser Messages: 476 Registered: July 2009 |
Senior Member |
|
|
sorry for the late reply (weekend)
i tried to override eSetDeliver and eBasicSetAdapterArray on my root element, triggering an System.exit which never happens.
i am sure the adapter is dropped from my current eobject as i output all adapters which are on my current EObject to console - others show up, this one does at first bit after dropped it does no more (obviously).
only one thread is adding and removing Adapters. Especially this Adapter should only get removed if my EObject gets saved by the user - save method is not called so nothing should remove the Adapter.
NOTE: i also removed the line of code where the Adapter gets removed (in save()) which remains in the same problem.
the symptoms only brought me to the point to check if the adapter is still in place - actually this was my last guess - i searched my code a lot for errors.
i check if the adapter is still in place with this code:
public static void printEAdapters(EObject o) {
if (o != null) {
List<Adapter> adapters = o.eAdapters();
System.out.println("EAdapters for " + o);
for (Adapter adapter : adapters) {
System.out.println(String.format("\t %s", adapter));
}
}
}
and the check if it is still there:
public static boolean hasExampleSearchAdapters(EObject o) {
if (o != null) {
List<Adapter> adapters = o.eAdapters();
for (Adapter adapter : adapters) {
if (adapter instanceof ExampleSearchAdapter) {
return true;
}
}
}
return false;
}
can an adapter be on an EObject without being listed in eAdapters()?
[Updated on: Mon, 10 October 2016 06:03] Report message to a moderator
|
|
|
|
|
|
Re: Adapters [message #1745489 is a reply to message #1745456] |
Tue, 11 October 2016 13:40 |
Ed Merks Messages: 33216 Registered: July 2009 |
Senior Member |
|
|
Felix,
The implementation for MinimalEObjectImpl's eAdapter's list is tricky. A new list is created for each call to eAdapters and that list is backed by an array kept in the eStorage. The array that it uses is never modified. In fact the array instance may be shared among many EObjects, so for example, when adding an EContentAdapter, all objects in the tree might well share the same array of adapters containing that EContentAdapter. So the list will certainly never see a partially initialized array...
Ludwig,
I really did suggest setting a breakpoint. It's best to find out where exactly are all the calls that modify the adapters on that object. If it's being removed or otherwise going missing, which could happen if multiple threads are adding adapters at the same time for the same object, all cases must set a new array and must go through this method. So either the adapter isn't really going missing or some call to this method sets an array that doesn't have this adapter in it. You've instrumented the call with logic, but I have no idea what that logic really tests and no idea if the logic itself is correct. Set a breakpoint to find out all places that modify the array. If there are multiple threads doing it, you should end up seeing the process stop in multiple threads.
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.04417 seconds