Login | Register
My pages Projects Community openCollabNet

Discussions > issues > [Issue 49] New - SplitTask hangs processing File

Discussion topic

Hide all messages in topic

All messages in topic

[Issue 49] New - SplitTask hangs processing File

Author hopesea
Full name Sean Hope
Date 2010-11-03 17:23:56 PDT
Message http://antelope.tigr​is.org/issues/show_b​ug.cgi?id=49
                 Issue #|49
                 Summary|SplitTask hangs processing File
       Status whiteboard|
              Issue type|DEFECT
            Subcomponent|Ant Tasks
             Assigned to|danson
             Reported by|hopesea

------- Additional comments from hopesea at tigris dot org Wed Nov 3 17:23:55 -0700 2010 -------
Using the SplitTask to split a file causes the task to hang.

<split file="myfile.bin" bytes="4096" prefix="A"/>

If the file is larger than 4096 in this example, the task never completes.

        int offset = 0;
        while ( true ) {
            bytes_read = from.read( buffer, 0, java.lang.Math.min( buffer_size,
size - offset ) );
System.out.println(">> read: "+bytes_read);
            if ( bytes_read == -1 )
            to.write( buffer, 0, bytes_read );
            total += bytes_read;
            offset += bytes_read;
        return total;

The while loop won't exit because once offset reads 4096 bytes, the logic
continues by trying to read 0 bytes in the buffer which means from.read will
never return -1.
Messages per page: