hi, all

I’m reading the MemoryChannel code these days. I’ve noticed doRollback releases 
putByteCounter permits of bytesRemaining. This is wrong for the below cases:
In the doCommit function:
1)
    if(!bytesRemaining.tryAcquire(putByteCounter, keepAlive,
     TimeUnit.SECONDS)) {
     throw new ChannelException("Cannot commit transaction. Heap space " +
      "limit of " + byteCapacity + "reached. Please increase heap space" +
      " allocated to the channel as the sinks may not be keeping up " +
      "with the sources");
    }
2)
    if(!queueRemaining.tryAcquire(-remainingChange, keepAlive, 
TimeUnit.SECONDS)) {
     bytesRemaining.release(putByteCounter);
     throw new ChannelFullException("Space for commit to queue couldn't be 
acquired." +
       " Sinks are likely not keeping up with sources, or the buffer size is 
too tight");
    }
When they throw ChannelException, bytesRemaining should not release any permits.


Is it right or am I missing something?


Thanks

Reply via email to