Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » IndirectSet triggers raiseAddChangeEvent even when no element was added
IndirectSet triggers raiseAddChangeEvent even when no element was added [message #666290] Tue, 19 April 2011 18:52 Go to next message
Jakub Kahovec is currently offline Jakub KahovecFriend
Messages: 13
Registered: July 2009
Junior Member
Hi,

I was debugging some code and noticed that when adding an element into the IndirectSet, an event raiseAddChangeEvent is being triggered even when the object is actually not added, causing IMHO unnecessary overhead.

Here is the snippet :
    public boolean add(Object element) {
        boolean added = true;
        // PERF: If not instantiated just record the add to avoid the instantiation.
        if (shouldAvoidInstantiation()) {
            if (hasRemovedElements() && getRemovedElements().contains(element)) {
                getRemovedElements().remove(element);
            } else if (getAddedElements().contains(element)) {
                // Must avoid recursion for relationship maintenance.                
                return false;
            } else {
                getAddedElements().add(element);
            }
        } else {
            added = getDelegate().add(element);
        }
        raiseAddChangeEvent(element);
        return added;
    }


Note the line

    added = getDelegate().add(element);


Variable added is set to false if the element is already present in the delegated set but at the end of the method the event raiseAddChangeEvent is triggered regardless the added variable

I think the event should only be triggered when the element was actually added.

Jakub
Re: IndirectSet triggers raiseAddChangeEvent even when no element was added [message #666662 is a reply to message #666290] Thu, 21 April 2011 13:37 Go to previous message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

Sounds correct, please log a bug for this.


James : Wiki : Book : Blog : Twitter
Previous Topic:postgres and CursoredStream
Next Topic:Transfer entities between entitymanagers
Goto Forum:
  


Current Time: Fri Apr 19 18:49:58 GMT 2024

Powered by FUDForum. Page generated in 0.03048 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top