[rules-users] java.lang.ClassCastException: org.drools.reteoo.BetaMemory cannot be cast to org.drools.reteoo.AlphaNode$AlphaMemory

AlesD Ales.Dolecek at nextiraone.eu
Wed Aug 7 15:16:10 EDT 2013


Looking at org.drools.common.ConcurrentNodeMemories: What happens if the
rulebase is changed during invocation of resize?

If I understand it well then every node in the rulebase has "slot" in this
class? Can number of nodes in rulebase change while the copying for-cycle is
running? Can in such case BetaMemory end up in place where AlphaMemory was
before? (causing the ClassCastException later).

    private void resize( NodeMemory node ) {
        try {
            this.lock.lock();
            if( node.getId() >= this.memories.length() ) {
                // adding some buffer for new nodes, so that we reduce array
copies
                int size = Math.max( this.rulebase.getNodeCount(),
node.getId() + 32 );
                AtomicReferenceArray<Memory> newMem = new
AtomicReferenceArray<Memory>( size );
                for ( int i = 0; i < this.memories.length(); i++ ) {
                    newMem.set( i,
                                this.memories.get( i ) );
                }
                this.memories = newMem;
            }
        } finally {
            this.lock.unlock();
        }
    }

And BTW: this.lock.lock() should be outside of the try block.



--
View this message in context: http://drools.46999.n3.nabble.com/java-lang-ClassCastException-org-drools-reteoo-BetaMemory-cannot-be-cast-to-org-drools-reteoo-AlphaNy-tp4023610p4025416.html
Sent from the Drools: User forum mailing list archive at Nabble.com.


More information about the rules-users mailing list