Skip navigation
This discussion is archived
4159 Views 1 Reply Latest reply: May 4, 2007 2:40 PM by Matt Tucker RSS
Calculating status... 3 posts since
May 1, 2007
Currently Being Moderated

May 2, 2007 2:32 AM

Bug and correction in org.jivesoftware.openfire.filetransfer.proxy.DefaultP

There''s a bug in org.jivesoftware.openfire.filetransfer.proxy.DefaultProxyTransfer.java.

In method

 

    +public void doTransfer() throws *IOException *{

...

InputStream in = getInputStream();

OutputStream out = new ProxyOutputStream(getOutputStream());





+...

+


+ do {

// write to the output stream

            out.write(b, 0, count);+






 

+            amountWritten = count;







// read more bytes from the input stream

count = *in.read(b);

  •        } while (count >= 0);+

 

 

 

+        getInputStream().close();+

+*        getOutputStream().close();*+

+*    *+

this method throw exception IOException. we all know if a method throw an exception, the code after the throw statement will not be executed.

Here the functions which will throw the IOException are out.write() and in.read(). If they really do, something will be wrong.

That is, if they throws exception, the two close() functions after will not be executed, connections to clients will not be released maybe.

We will see the Spark client file transfering stops at a certain progress and will not tell us this transfer has corrupted.

One of the corrections will be:

 

+        try+

+        {

do {

// write to the output stream

out.write(b, 0, count);

amountWritten += count;



// read more bytes from the input stream

count = in.read(b);

         } while (count >= 0);+

+        }+

+        catch(IOException e)+

+        {

//e.printStackTrace();

throw e;

        }+

+        finally+

+        {

getInputStream().close();

getOutputStream().close();

        }+

 

 

 

More Like This

  • Retrieving data ...

Bookmarked By (0)