Hi,

I've notice that fillbuf() method in
org.apache.crimson.parser.InputEntity 
when reading the 'Reader' can block on IO.
In fact, the way the code is implemented avoids input stream
parsing on the fly.

to be precise
=>  len = reader.read(buf, finish, len );
attempt to read 8Ko of data, and if the stream just send less
than 8k (it could happen on 2 ways communication protocol, such
as Jabber.org protocol), it blocks on this instruction.


To avoid this case I've rapidly hacked a dirty work:

=========
len = buf.length - len;
int appended = 0;

do{
int val = reader.read();
if( val == -1 ) close();
else{
    char c = (char)val;
    if( Character.isDefined( c ) ){
        buf[finish++] = c;
        appended++;
    }

}
}while( reader.ready() && finish<=buf.length && appended<=len );

len = appended;
===========

in this approach I use a combination of

do{
    int val = reader.read()
    ...
}while( reader.ready() ...);

to be sure the execution wont freeze in an IO operation.

I know this is clearly not an optimised work.

Hope this could help

-- 
Al

---------------------------------------------------------------------
In case of troubles, e-mail:     [EMAIL PROTECTED]
To unsubscribe, e-mail:          [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to