Project

General

Profile

Actions

bug #6546

open

Adding identifier does not always work

Added by Andreas Müller about 7 years ago. Updated about 5 years ago.

Status:
In Progress
Priority:
Highest
Category:
cdmlib
Start date:
Due date:
% Done:

0%

Estimated time:
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 treeIn ProgressAndreas Müller

Actions
Actions #1

Updated by Andreas Müller about 7 years ago

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

Updated by Andreas Müller about 7 years ago

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

Updated by Andreas Müller over 6 years ago

  • Target version changed from Release 4.7 to Release 4.11
Actions #4

Updated by Andreas Müller over 6 years ago

  • Target version changed from Release 4.11 to Release 4.12
Actions #5

Updated by Andreas Müller over 6 years ago

  • Target version changed from Release 4.12 to Release 4.13
Actions #6

Updated by Andreas Müller about 6 years ago

  • Target version changed from Release 4.13 to Release 4.14
Actions #7

Updated by Andreas Müller about 6 years ago

  • Target version changed from Release 4.14 to Release 5.0
Actions #8

Updated by Andreas Müller almost 6 years ago

  • Target version changed from Release 5.0 to Release 5.1
Actions #9

Updated by Andreas Müller almost 6 years ago

  • Target version changed from Release 5.1 to Release 5.2
Actions #10

Updated by Andreas Müller over 5 years ago

  • Target version changed from Release 5.2 to Release 5.3
Actions #11

Updated by Andreas Müller over 5 years ago

  • Target version changed from Release 5.3 to Release 5.4
Actions #12

Updated by Andreas Müller over 5 years ago

  • Target version changed from Release 5.4 to Release 5.5
Actions #13

Updated by Andreas Müller about 5 years ago

  • Target version changed from Release 5.5 to Release 5.6
Actions #14

Updated by Andreas Müller about 5 years ago

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

Also available in: Atom PDF