How JIMM does check connection error

Jimm development discussions.

Moderator: Jimm developers

How JIMM does check connection error

Postby samolisov » Wed Jan 13, 2010 9:39 am

Hello folks,

Could you tell me how jimm dows check connection error. I find this code in jimm.comm.connections.PeerConnection:
Code: Select all
// Try
        try
        {

            // Check abort condition
            while (!this.inputCloseFlag)
            {

                // Read flap header
                bReadSum = 0;
                if (Options.getInt(Options.OPTION_CONN_PROP) == 1)
                {
                    while (is.available() == 0)
                        Thread.sleep(250);
                    if (is == null)
                        break;
                }
                do
                {
                    bRead = this.is.read(dcLength, bReadSum,
                            dcLength.length - bReadSum);
                    if (bRead == -1)
                        break;
                    bReadSum += bRead;
                } while (bReadSum < dcLength.length);
                if (bRead == -1)
                    break;

                // Allocate memory for flap data
                rcvdPacket = new byte[Util.getWord(dcLength, 0, false)];

                // Read flap data
                bReadSum = 0;
                do
                {
                    bRead = this.is.read(rcvdPacket, bReadSum,
                            rcvdPacket.length - bReadSum);
                    if (bRead == -1)
                        break;
                    bReadSum += bRead;
                } while (bReadSum < rcvdPacket.length);
                if (bRead == -1)
                    break;

//#sijapp cond.if modules_TRAFFIC is "true" #
                Traffic.addInTraffic(bReadSum + 53);
                MainThread.updateContactListCaption();
//#sijapp cond.end#

                // Lock object and add rcvd packet to vector
                synchronized (this.rcvdPackets)
                {
                    this.rcvdPackets.addElement(rcvdPacket);
                }

                // Notify main loop
                synchronized (Icq.getWaitObj())
                {
                    Icq.getWaitObj().notify();
                }
            }

        }
        // Catch communication exception
        catch (NullPointerException e)
        {
            if (!this.inputCloseFlag)
            {
                // Construct and handle exception
                JimmException f = new JimmException(125, 3, true, true);
                JimmException.handleException(f);
            } else
            { /* Do nothing */
            }
        }


But I don't understend what line in try-block can throw NPE? Or may be this code doesn't check connection error?

samolisov
 
Posts: 3
Joined: Wed Jan 13, 2010 9:35 am

Return to Development

Who is online

Users browsing this forum: No registered users and 1 guest