Example usage for java.io EOFException getMessage

List of usage examples for java.io EOFException getMessage

Introduction

In this page you can find the example usage for java.io EOFException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:org.skyscreamer.nevado.jms.message.NevadoStreamMessage.java

/**
 * Reads a byte array field from the stream message into the specified
 * <CODE>byte[]</CODE> object (the read buffer). <p/>
 * <P>//from   w w w.  j  a  va 2 s  .c  o m
 * To read the field value, <CODE>readBytes</CODE> should be successively
 * called until it returns a value less than the length of the read buffer.
 * The value of the bytes in the buffer following the last byte read is
 * undefined. <p/>
 * <P>
 * If <CODE>readBytes</CODE> returns a value equal to the length of the
 * buffer, a subsequent <CODE>readBytes</CODE> call must be made. If there
 * are no more bytes to be read, this call returns -1. <p/>
 * <P>
 * If the byte array field value is null, <CODE>readBytes</CODE> returns
 * -1. <p/>
 * <P>
 * If the byte array field value is empty, <CODE>readBytes</CODE> returns
 * 0. <p/>
 * <P>
 * Once the first <CODE>readBytes</CODE> call on a <CODE>byte[]</CODE>
 * field value has been made, the full value of the field must be read
 * before it is valid to read the next field. An attempt to read the next
 * field before that has been done will throw a <CODE>MessageFormatException</CODE>.
 * <p/>
 * <P>
 * To read the byte field value into a new <CODE>byte[]</CODE> object, use
 * the <CODE>readObject</CODE> method.
 *
 * @param value
 *            the buffer into which the data is read
 * @return the total number of bytes read into the buffer, or -1 if there is
 *         no more data because the end of the byte field has been reached
 * @throws JMSException
 *             if the JMS provider fails to read the message due to some
 *             internal error.
 * @throws MessageEOFException
 *             if unexpected end of message stream has been reached.
 * @throws MessageFormatException
 *             if this type conversion is invalid.
 * @throws MessageNotReadableException
 *             if the message is in write-only mode.
 * @see #readObject()
 */

public int readBytes(byte[] value) throws JMSException {

    initializeReading();
    try {
        if (value == null) {
            throw new NullPointerException();
        }

        if (remainingBytes == -1) {
            this.dataIn.mark(value.length + 1);
            int type = this.dataIn.read();
            if (type == -1) {
                throw new MessageEOFException("reached end of data");
            }
            if (type != MarshallingSupport.BYTE_ARRAY_TYPE) {
                throw new MessageFormatException("Not a byte array");
            }
            remainingBytes = this.dataIn.readInt();
        } else if (remainingBytes == 0) {
            remainingBytes = -1;
            return -1;
        }

        if (value.length <= remainingBytes) {
            // small buffer
            remainingBytes -= value.length;
            this.dataIn.readFully(value);
            return value.length;
        } else {
            // big buffer
            int rc = this.dataIn.read(value, 0, remainingBytes);
            remainingBytes = 0;
            return rc;
        }

    } catch (EOFException e) {
        JMSException jmsEx = new MessageEOFException(e.getMessage());
        jmsEx.setLinkedException(e);
        throw jmsEx;
    } catch (IOException e) {
        JMSException jmsEx = new MessageFormatException(e.getMessage());
        jmsEx.setLinkedException(e);
        throw jmsEx;
    }
}

From source file:org.skyscreamer.nevado.jms.message.NevadoStreamMessage.java

/**
 * Reads a 16-bit integer from the stream message.
 *
 * @return a 16-bit integer from the stream message
 * @throws JMSException/*from ww w. j a v  a2s. co m*/
 *             if the JMS provider fails to read the message due to some
 *             internal error.
 * @throws MessageEOFException
 *             if unexpected end of message stream has been reached.
 * @throws MessageFormatException
 *             if this type conversion is invalid.
 * @throws MessageNotReadableException
 *             if the message is in write-only mode.
 */

public short readShort() throws JMSException {
    initializeReading();
    try {

        this.dataIn.mark(17);
        int type = this.dataIn.read();
        if (type == -1) {
            throw new MessageEOFException("reached end of data");
        }
        if (type == MarshallingSupport.SHORT_TYPE) {
            return this.dataIn.readShort();
        }
        if (type == MarshallingSupport.BYTE_TYPE) {
            return this.dataIn.readByte();
        }
        if (type == MarshallingSupport.STRING_TYPE) {
            return Short.valueOf(this.dataIn.readUTF()).shortValue();
        }
        if (type == MarshallingSupport.NULL) {
            this.dataIn.reset();
            throw new NullPointerException("Cannot convert NULL value to short.");
        } else {
            this.dataIn.reset();
            throw new MessageFormatException(" not a short type");
        }
    } catch (NumberFormatException mfe) {
        try {
            this.dataIn.reset();
        } catch (IOException ioe) {
            JMSException jmsEx = new MessageFormatException(ioe.getMessage());
            jmsEx.setLinkedException(ioe);
            throw jmsEx;
        }
        throw mfe;

    } catch (EOFException e) {
        String exMessage = "Reached premature EOF: " + e.getMessage();
        _log.error(exMessage, e);
        throw new JMSException(exMessage);
    } catch (IOException e) {
        String exMessage = "Could not read boolean: " + e.getMessage();
        _log.error(exMessage, e);
        throw new JMSException(exMessage);
    }
}

From source file:org.skyscreamer.nevado.jms.message.NevadoStreamMessage.java

/**
 * Reads a <code>double</code> from the stream message.
 *
 * @return a <code>double</code> value from the stream message
 * @throws JMSException/* w ww  .  jav  a  2 s  .  c o  m*/
 *             if the JMS provider fails to read the message due to some
 *             internal error.
 * @throws MessageEOFException
 *             if unexpected end of message stream has been reached.
 * @throws MessageFormatException
 *             if this type conversion is invalid.
 * @throws MessageNotReadableException
 *             if the message is in write-only mode.
 */

public double readDouble() throws JMSException {
    initializeReading();
    try {

        this.dataIn.mark(65);
        int type = this.dataIn.read();
        if (type == -1) {
            throw new MessageEOFException("reached end of data");
        }
        if (type == MarshallingSupport.DOUBLE_TYPE) {
            return this.dataIn.readDouble();
        }
        if (type == MarshallingSupport.FLOAT_TYPE) {
            return this.dataIn.readFloat();
        }
        if (type == MarshallingSupport.STRING_TYPE) {
            return Double.valueOf(this.dataIn.readUTF()).doubleValue();
        }
        if (type == MarshallingSupport.NULL) {
            this.dataIn.reset();
            throw new NullPointerException("Cannot convert NULL value to double.");
        } else {
            this.dataIn.reset();
            throw new MessageFormatException(" not a double type");
        }
    } catch (NumberFormatException mfe) {
        try {
            this.dataIn.reset();
        } catch (IOException ioe) {
            JMSException jmsEx = new MessageFormatException(ioe.getMessage());
            jmsEx.setLinkedException(ioe);
            throw jmsEx;
        }
        throw mfe;

    } catch (EOFException e) {
        String exMessage = "Reached premature EOF: " + e.getMessage();
        _log.error(exMessage, e);
        throw new JMSException(exMessage);
    } catch (IOException e) {
        String exMessage = "Could not read boolean: " + e.getMessage();
        _log.error(exMessage, e);
        throw new JMSException(exMessage);
    }
}

From source file:org.skyscreamer.nevado.jms.message.NevadoStreamMessage.java

/**
 * Reads a 32-bit integer from the stream message.
 *
 * @return a 32-bit integer value from the stream message, interpreted as an
 *         <code>int</code>//  w  w  w . j a  va 2 s  .  com
 * @throws JMSException
 *             if the JMS provider fails to read the message due to some
 *             internal error.
 * @throws MessageEOFException
 *             if unexpected end of message stream has been reached.
 * @throws MessageFormatException
 *             if this type conversion is invalid.
 * @throws MessageNotReadableException
 *             if the message is in write-only mode.
 */

public int readInt() throws JMSException {
    initializeReading();
    try {

        this.dataIn.mark(33);
        int type = this.dataIn.read();
        if (type == -1) {
            throw new MessageEOFException("reached end of data");
        }
        if (type == MarshallingSupport.INTEGER_TYPE) {
            return this.dataIn.readInt();
        }
        if (type == MarshallingSupport.SHORT_TYPE) {
            return this.dataIn.readShort();
        }
        if (type == MarshallingSupport.BYTE_TYPE) {
            return this.dataIn.readByte();
        }
        if (type == MarshallingSupport.STRING_TYPE) {
            return Integer.valueOf(this.dataIn.readUTF()).intValue();
        }
        if (type == MarshallingSupport.NULL) {
            this.dataIn.reset();
            throw new NullPointerException("Cannot convert NULL value to int.");
        } else {
            this.dataIn.reset();
            throw new MessageFormatException(" not an int type");
        }
    } catch (NumberFormatException mfe) {
        try {
            this.dataIn.reset();
        } catch (IOException ioe) {
            JMSException jmsEx = new MessageFormatException(ioe.getMessage());
            jmsEx.setLinkedException(ioe);
            throw jmsEx;
        }
        throw mfe;

    } catch (EOFException e) {
        String exMessage = "Reached premature EOF: " + e.getMessage();
        _log.error(exMessage, e);
        throw new JMSException(exMessage);
    } catch (IOException e) {
        String exMessage = "Could not read boolean: " + e.getMessage();
        _log.error(exMessage, e);
        throw new JMSException(exMessage);
    }
}

From source file:org.skyscreamer.nevado.jms.message.NevadoStreamMessage.java

/**
 * Reads a 64-bit integer from the stream message.
 *
 * @return a 64-bit integer value from the stream message, interpreted as a
 *         <code>long</code>
 * @throws JMSException//from   w ww  . jav  a 2 s.  c om
 *             if the JMS provider fails to read the message due to some
 *             internal error.
 * @throws MessageEOFException
 *             if unexpected end of message stream has been reached.
 * @throws MessageFormatException
 *             if this type conversion is invalid.
 * @throws MessageNotReadableException
 *             if the message is in write-only mode.
 */

public long readLong() throws JMSException {
    initializeReading();
    try {

        this.dataIn.mark(65);
        int type = this.dataIn.read();
        if (type == -1) {
            throw new MessageEOFException("reached end of data");
        }
        if (type == MarshallingSupport.LONG_TYPE) {
            return this.dataIn.readLong();
        }
        if (type == MarshallingSupport.INTEGER_TYPE) {
            return this.dataIn.readInt();
        }
        if (type == MarshallingSupport.SHORT_TYPE) {
            return this.dataIn.readShort();
        }
        if (type == MarshallingSupport.BYTE_TYPE) {
            return this.dataIn.readByte();
        }
        if (type == MarshallingSupport.STRING_TYPE) {
            return Long.valueOf(this.dataIn.readUTF()).longValue();
        }
        if (type == MarshallingSupport.NULL) {
            this.dataIn.reset();
            throw new NullPointerException("Cannot convert NULL value to long.");
        } else {
            this.dataIn.reset();
            throw new MessageFormatException(" not a long type");
        }
    } catch (NumberFormatException mfe) {
        try {
            this.dataIn.reset();
        } catch (IOException ioe) {
            JMSException jmsEx = new MessageFormatException(ioe.getMessage());
            jmsEx.setLinkedException(ioe);
            throw jmsEx;
        }
        throw mfe;

    } catch (EOFException e) {
        String exMessage = "Reached premature EOF: " + e.getMessage();
        _log.error(exMessage, e);
        throw new JMSException(exMessage);
    } catch (IOException e) {
        String exMessage = "Could not read boolean: " + e.getMessage();
        _log.error(exMessage, e);
        throw new JMSException(exMessage);
    }
}

From source file:org.skyscreamer.nevado.jms.message.NevadoStreamMessage.java

/**
 * Reads a <CODE>String</CODE> from the stream message.
 *
 * @return a Unicode string from the stream message
 * @throws JMSException// ww  w .j  a va 2s  .  c  om
 *             if the JMS provider fails to read the message due to some
 *             internal error.
 * @throws MessageEOFException
 *             if unexpected end of message stream has been reached.
 * @throws MessageFormatException
 *             if this type conversion is invalid.
 * @throws MessageNotReadableException
 *             if the message is in write-only mode.
 */

public String readString() throws JMSException {
    initializeReading();
    try {

        this.dataIn.mark(65);
        int type = this.dataIn.read();
        if (type == -1) {
            throw new MessageEOFException("reached end of data");
        }
        if (type == MarshallingSupport.NULL) {
            return null;
        }
        if (type == MarshallingSupport.BIG_STRING_TYPE) {
            return MarshallingSupport.readUTF8(dataIn);
        }
        if (type == MarshallingSupport.STRING_TYPE) {
            return this.dataIn.readUTF();
        }
        if (type == MarshallingSupport.LONG_TYPE) {
            return new Long(this.dataIn.readLong()).toString();
        }
        if (type == MarshallingSupport.INTEGER_TYPE) {
            return new Integer(this.dataIn.readInt()).toString();
        }
        if (type == MarshallingSupport.SHORT_TYPE) {
            return new Short(this.dataIn.readShort()).toString();
        }
        if (type == MarshallingSupport.BYTE_TYPE) {
            return new Byte(this.dataIn.readByte()).toString();
        }
        if (type == MarshallingSupport.FLOAT_TYPE) {
            return new Float(this.dataIn.readFloat()).toString();
        }
        if (type == MarshallingSupport.DOUBLE_TYPE) {
            return new Double(this.dataIn.readDouble()).toString();
        }
        if (type == MarshallingSupport.BOOLEAN_TYPE) {
            return (this.dataIn.readBoolean() ? Boolean.TRUE : Boolean.FALSE).toString();
        }
        if (type == MarshallingSupport.CHAR_TYPE) {
            return new Character(this.dataIn.readChar()).toString();
        } else {
            this.dataIn.reset();
            throw new MessageFormatException(" not a String type");
        }
    } catch (NumberFormatException mfe) {
        try {
            this.dataIn.reset();
        } catch (IOException ioe) {
            JMSException jmsEx = new MessageFormatException(ioe.getMessage());
            jmsEx.setLinkedException(ioe);
            throw jmsEx;
        }
        throw mfe;

    } catch (EOFException e) {
        String exMessage = "Reached premature EOF: " + e.getMessage();
        _log.error(exMessage, e);
        throw new JMSException(exMessage);
    } catch (IOException e) {
        String exMessage = "Could not read boolean: " + e.getMessage();
        _log.error(exMessage, e);
        throw new JMSException(exMessage);
    }
}

From source file:org.skyscreamer.nevado.jms.message.NevadoStreamMessage.java

/**
 * Reads an object from the stream message. <p/>
 * <P>/* w ww  .  j  a v a2s  . c o  m*/
 * This method can be used to return, in objectified format, an object in
 * the Java programming language ("Java object") that has been written to
 * the stream with the equivalent <CODE>writeObject</CODE> method call, or
 * its equivalent primitive <CODE>write<I>type</I></CODE> method. <p/>
 * <P>
 * Note that byte values are returned as <CODE>byte[]</CODE>, not <CODE>Byte[]</CODE>.
 * <p/>
 * <P>
 * An attempt to call <CODE>readObject</CODE> to read a byte field value
 * into a new <CODE>byte[]</CODE> object before the full value of the byte
 * field has been read will throw a <CODE>MessageFormatException</CODE>.
 *
 * @return a Java object from the stream message, in objectified format (for
 *         example, if the object was written as an <CODE>int</CODE>, an
 *         <CODE>Integer</CODE> is returned)
 * @throws JMSException
 *             if the JMS provider fails to read the message due to some
 *             internal error.
 * @throws MessageEOFException
 *             if unexpected end of message stream has been reached.
 * @throws MessageFormatException
 *             if this type conversion is invalid.
 * @throws MessageNotReadableException
 *             if the message is in write-only mode.
 * @see #readBytes(byte[] value)
 */

public Object readObject() throws JMSException {
    initializeReading();
    try {
        this.dataIn.mark(65);
        int type = this.dataIn.read();
        if (type == -1) {
            throw new MessageEOFException("reached end of data");
        }
        if (type == MarshallingSupport.NULL) {
            return null;
        }
        if (type == MarshallingSupport.BIG_STRING_TYPE) {
            return MarshallingSupport.readUTF8(dataIn);
        }
        if (type == MarshallingSupport.STRING_TYPE) {
            return this.dataIn.readUTF();
        }
        if (type == MarshallingSupport.LONG_TYPE) {
            return new Long(this.dataIn.readLong());
        }
        if (type == MarshallingSupport.INTEGER_TYPE) {
            return new Integer(this.dataIn.readInt());
        }
        if (type == MarshallingSupport.SHORT_TYPE) {
            return new Short(this.dataIn.readShort());
        }
        if (type == MarshallingSupport.BYTE_TYPE) {
            return new Byte(this.dataIn.readByte());
        }
        if (type == MarshallingSupport.FLOAT_TYPE) {
            return new Float(this.dataIn.readFloat());
        }
        if (type == MarshallingSupport.DOUBLE_TYPE) {
            return new Double(this.dataIn.readDouble());
        }
        if (type == MarshallingSupport.BOOLEAN_TYPE) {
            return this.dataIn.readBoolean() ? Boolean.TRUE : Boolean.FALSE;
        }
        if (type == MarshallingSupport.CHAR_TYPE) {
            return new Character(this.dataIn.readChar());
        }
        if (type == MarshallingSupport.BYTE_ARRAY_TYPE) {
            int len = this.dataIn.readInt();
            byte[] value = new byte[len];
            this.dataIn.readFully(value);
            return value;
        } else {
            this.dataIn.reset();
            throw new MessageFormatException("unknown type");
        }
    } catch (NumberFormatException mfe) {
        try {
            this.dataIn.reset();
        } catch (IOException ioe) {
            JMSException jmsEx = new MessageFormatException(ioe.getMessage());
            jmsEx.setLinkedException(ioe);
            throw jmsEx;
        }
        throw mfe;

    } catch (EOFException e) {
        JMSException jmsEx = new MessageEOFException(e.getMessage());
        jmsEx.setLinkedException(e);
        throw jmsEx;
    } catch (IOException e) {
        JMSException jmsEx = new MessageFormatException(e.getMessage());
        jmsEx.setLinkedException(e);
        throw jmsEx;
    }
}

From source file:com.treasure_data.client.bulkimport.BulkImportClientAdaptorImpl.java

private GetErrorRecordsResult doGetErrorRecords(GetErrorRecordsRequest request) throws ClientException {
    request.setCredentials(client.getTreasureDataCredentials());
    validator.validateCredentials(client, request);

    Unpacker unpacker = null;//  w  w  w. j a v  a 2 s.  com
    int code = 0;
    String message = null;
    try {
        conn = createConnection();

        // send request
        String path = String.format(HttpURL.V3_ERROR_RECORDS, HttpConnectionImpl.e(request.getSessionName()));
        Map<String, String> header = new HashMap<String, String>();
        setUserAgentHeader(header);
        Map<String, String> params = null;
        conn.doGetRequest(request, path, header, params);

        // receive response code and body
        code = conn.getResponseCode();
        message = conn.getResponseMessage();
        if (code != HttpURLConnection.HTTP_OK) {
            String errMessage = conn.getErrorMessage();
            LOG.severe(HttpClientException.toMessage("Get error_records failed", message, code));
            LOG.severe(errMessage);
            throw new HttpClientException("Get error_records failed", message + ", detail = " + errMessage,
                    code);
        }

        // receive response body
        try {
            unpacker = conn.getResponseBodyBinary();
        } catch (EOFException e) {
            // ignore
        }
    } catch (IOException e) {
        LOG.throwing(getClass().getName(), "getErrorRecords", e);
        LOG.severe(HttpClientException.toMessage(e.getMessage(), message, code));
        throw new HttpClientException("Get error_records failed", message, code, e);
    } finally {
        if (conn != null) {
            conn.disconnect();
        }
    }

    return new GetErrorRecordsResult(request.getSession(), unpacker);
}

From source file:org.jared.synodroid.ds.server.SimpleSynoServer.java

/**
 * Upload a file which is located on the mobile
 *///from  ww w. j  a  va2  s  .  c  o  m
public JSONObject sendMultiPart(String uriP, MultipartBuilder multiPartP) throws Exception {
    HttpURLConnection conn = null;
    JSONObject respJSO = null;
    int retry = 0;
    int MAX_RETRY = 2;
    Exception last_exception = null;
    try {
        while (retry <= MAX_RETRY) {
            try {
                // Create the connection
                conn = createConnection(uriP, "", "POST", true);
                conn.setRequestProperty("Connection", "keep-alive");
                conn.setRequestProperty("Content-Type",
                        "multipart/form-data; boundary=" + multiPartP.getBoundary());

                // Write the multipart
                multiPartP.writeData(conn.getOutputStream());

                // Now read the reponse and build a string with it
                BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream()));
                StringBuffer sb = new StringBuffer();
                String line;
                while ((line = br.readLine()) != null) {
                    sb.append(line);
                }
                br.close();

                if (conn.getResponseCode() == -1) {
                    retry++;
                    if (DEBUG)
                        Log.w(Synodroid.DS_TAG, "Response code is -1 (retry: " + retry + ")");
                } else {
                    if (DEBUG)
                        Log.d(Synodroid.DS_TAG, "Response is: " + sb.toString());
                    respJSO = new JSONObject(sb.toString());
                    return respJSO;
                }
            } catch (EOFException e) {
                if (DEBUG)
                    Log.w(Synodroid.DS_TAG, "Caught EOFException while contacting the server, retying...");
                retry++;
                last_exception = e;
            } catch (SocketException e) {
                if (DEBUG)
                    Log.e(Synodroid.DS_TAG, "Caught SocketException while contacting the server, stopping...");
                throw e;
            } catch (SSLHandshakeException e) {
                if (DEBUG)
                    Log.e(Synodroid.DS_TAG,
                            "Caught SSLHandshakeException while contacting the server, stopping...");
                throw e;
            } catch (FileNotFoundException e) {
                String msg = e.getMessage();
                if (DEBUG)
                    Log.e(Synodroid.DS_TAG,
                            "Could not find file " + msg + "\nProbably wrong DSM version, stopping...");
                throw e;
            } catch (Exception e) {
                if (DEBUG)
                    Log.e(Synodroid.DS_TAG, "Caught exception while contacting the server, retying...", e);
                retry++;
                last_exception = e;
            } finally {
                conn.disconnect();
            }
        }
    } finally {
        conn = null;
    }
    if (last_exception != null)
        throw last_exception;
    throw new GenericException();
}

From source file:org.jared.synodroid.ds.server.SimpleSynoServer.java

/**
 * Send a request to the server./*from   w w  w  .j  av  a  2  s  . c o  m*/
 * 
 * @param uriP
 *            The part of the URI ie: /webman/doit.cgi
 * @param requestP
 *            The query in the form 'param1=foo&param2=yes'
 * @param methodP
 *            The method to send this request
 * @return A JSONObject containing the response of the server
 * @throws DSMException
 */
public JSONArray sendJSONRequestArray(String uriP, String requestP, String methodP, boolean log)
        throws Exception {
    HttpURLConnection con = null;
    OutputStreamWriter wr = null;
    BufferedReader br = null;
    StringBuffer sb = null;
    Exception last_exception = null;
    try {

        // For some reason in Gingerbread I often get a response code of -1.
        // Here I retry for a maximum of MAX_RETRY to send the request and it usually succeed at the second try...
        int retry = 0;
        int MAX_RETRY = 2;
        while (retry <= MAX_RETRY) {
            try {
                // Create the connection
                con = createConnection(uriP, requestP, methodP, log);
                // Add the parameters
                wr = new OutputStreamWriter(con.getOutputStream());
                wr.write(requestP);
                // Send the request
                wr.flush();
                wr.close();

                // Try to retrieve the session cookie
                String newCookie = con.getHeaderField("set-cookie");
                if (newCookie != null) {
                    synchronized (this) {
                        setCookie(newCookie);
                    }
                    if (DEBUG)
                        Log.v(Synodroid.DS_TAG, "Retreived cookies: " + cookies);
                }

                // Now read the reponse and build a string with it
                br = new BufferedReader(new InputStreamReader(con.getInputStream()));
                sb = new StringBuffer();
                String line;
                while ((line = br.readLine()) != null) {
                    sb.append(line);
                }
                br.close();
                // Verify is response if not -1, otherwise take reason from the header
                if (con.getResponseCode() == -1) {
                    retry++;
                    if (DEBUG)
                        Log.w(Synodroid.DS_TAG, "Response code is -1 (retry: " + retry + ")");
                } else {
                    if (DEBUG)
                        Log.d(Synodroid.DS_TAG, "Response is: " + sb.toString());
                    JSONArray respJSO = null;
                    try {
                        respJSO = new JSONArray(sb.toString());
                    } catch (JSONException je) {
                        respJSO = new JSONArray();
                    }
                    return respJSO;
                }
            } catch (EOFException e) {
                if (DEBUG)
                    Log.w(Synodroid.DS_TAG, "Caught EOFException while contacting the server, retying...");
                retry++;
                last_exception = e;
            } catch (SocketException e) {
                if (DEBUG)
                    Log.e(Synodroid.DS_TAG, "Caught SocketException while contacting the server, stopping...");
                throw e;
            } catch (SSLHandshakeException e) {
                if (DEBUG)
                    Log.e(Synodroid.DS_TAG,
                            "Caught SSLHandshakeException while contacting the server, stopping...");
                throw e;
            } catch (FileNotFoundException e) {
                String msg = e.getMessage();
                if (DEBUG)
                    Log.e(Synodroid.DS_TAG,
                            "Could not find file " + msg + "\nProbably wrong DSM version, stopping...");
                throw e;
            } catch (Exception e) {
                if (DEBUG)
                    Log.e(Synodroid.DS_TAG, "Caught exception while contacting the server, retying...", e);
                retry++;
                last_exception = e;
            } finally {
                con.disconnect();
            }

        }
        if (last_exception != null)
            throw last_exception;
        throw new GenericException();
    } finally {
        wr = null;
        br = null;
        sb = null;
        con = null;
    }
}