Project

General

Profile

bug #6546

Adding identifier does not always work

Added by Andreas Müller about 2 years ago. Updated 4 months ago.

Status:
In Progress
Priority:
Highest
Category:
cdmlib
Start date:
03/30/2017
Due date:
% Done:

0%

Severity:
normal
Found in Version:

Description

Probably this is related to the size() problem in PersistentLists (see #5211): If a PersistentList is detached (not bound to a session) it adds new objects NOT to the underlying list but to an operationQueue. The operation queue is handled during reattache.

(from PersistentList line 312ff)
@Override
@SuppressWarnings("unchecked")
public void add(int index, Object value) {
        if ( index < 0 ) {
        throw new ArrayIndexOutOfBoundsException( "negative index" );
    }
    if ( !isInitialized() || isConnectedToSession() ) {
        // NOTE : we don't care about the inverse part here because
        // even if the collection is inverse, this side is driving the
        // writing of the indexes.  And because this is a positioned-add
        // we need to load the underlying elements to know how that
        // affects overall re-ordering
        write();
        list.add( index, value );
    }
    else {
        queueOperation( new Add( index, value ) );
    }
}

The objects in the operationQueue are NOT considered when calling PersistentList.size().
Therefore calls to size like in IdentifiableEntity.addIdentifier() create unexpected results.


@Override
public void addIdentifier(Identifier identifier){
    addIdentifier(getIdentifiers().size(), identifier);
}

The problem only exists if add() is called with an index, like add(int, obj). The default add(obj) handles the list as expected:


@Override
public boolean add(Object object) {
    if ( !isOperationQueueEnabled() ) {
        write();
        return list.add( object );
    }
    else {
        queueOperation( new SimpleAdd( object ) );
        return true;
    }
}

Related issues

Related to Edit - bug #5211: Error when creating new taxon /problem with sortindex in taxon tree In Progress 09/08/2015

Associated revisions

Revision 26c35e3a (diff)
Added by Andreas Müller about 2 years ago

ref #6546 avoid add() with index if not necessary

History

#1 Updated by Andreas Müller about 2 years ago

  • Related to bug #5211: Error when creating new taxon /problem with sortindex in taxon tree added

#2 Updated by Andreas Müller about 2 years ago

  • Description updated (diff)
  • Status changed from New to In Progress

#3 Updated by Andreas Müller over 1 year ago

  • Target version changed from Release 4.7 to Release 4.11

#4 Updated by Andreas Müller over 1 year ago

  • Target version changed from Release 4.11 to Release 4.12

#5 Updated by Andreas Müller over 1 year ago

  • Target version changed from Release 4.12 to Release 4.13

#6 Updated by Andreas Müller over 1 year ago

  • Target version changed from Release 4.13 to Release 4.14

#7 Updated by Andreas Müller over 1 year ago

  • Target version changed from Release 4.14 to Release 5.0

#8 Updated by Andreas Müller about 1 year ago

  • Target version changed from Release 5.0 to Release 5.1

#9 Updated by Andreas Müller 12 months ago

  • Target version changed from Release 5.1 to Release 5.2

#10 Updated by Andreas Müller 10 months ago

  • Target version changed from Release 5.2 to Release 5.3

#11 Updated by Andreas Müller 9 months ago

  • Target version changed from Release 5.3 to Release 5.4

#12 Updated by Andreas Müller 8 months ago

  • Target version changed from Release 5.4 to Release 5.5

#13 Updated by Andreas Müller 4 months ago

  • Target version changed from Release 5.5 to Release 5.6

#14 Updated by Andreas Müller 4 months ago

  • Target version changed from Release 5.6 to Reviewed Next Major Release

Also available in: Atom PDF

Add picture from clipboard (Maximum size: 40 MB)