Hi Team,

There is a hang issue happening with SharedOutputBuffer when trying to
insert data chunck of 1024 bytes or above. However this works fine if data
chunck being inserted is less that 1024 bytes.

Simple way to reproduce the problem is
- Create SharedOutputBuffer with 4096 bytes of capacity
- Now try to write 1024 bytes of data chunck to above created buffer

Second step will cause hang and by looking at code it looks like below
condition is causing problem

if (src.remaining() < 1024 && buffer().remaining() > src.remaining()) {

Problem with this above condition is that even though buffer has capacity
to store complete contents of src, this condition will not satisfy if src
has 1024 bytes or more data (may well be in limit of actual size provided
during creation of buffer) to be written to buffer

second step still will cause in a hang as first if condition is not
satisfied due to src.remaining() < 1024 even though there is enough
capacity to store data and it proceeds to second condition which will cause
the program to wait on a condition for flush (even though this is the first
write we are performing)

if (buffer().position() > 0 || dataStreamChannel == null) {
                         waitFlush();
}

Regards,
Sreenivas

Reply via email to