Example usage for java.net SocketTimeoutException getMessage

List of usage examples for java.net SocketTimeoutException getMessage

Introduction

In this page you can find the example usage for java.net SocketTimeoutException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:com.highcharts.export.converter.SVGConverter.java

public String requestServer(String params)
        throws SVGConverterException, TimeoutException, NoSuchElementException, PoolException {
    Server server = null;/*from   ww w  .  j av a 2 s .com*/

    try {
        server = (Server) serverPool.borrowObject();
        String response = server.request(params);

        return response;
    } catch (SocketTimeoutException ste) {
        throw new TimeoutException(ste.getMessage());
    } catch (TimeoutException te) {
        throw new TimeoutException(te.getMessage());
    } catch (PoolException nse) {
        logger.error("POOL EXHAUSTED!!");
        throw new PoolException(nse.getMessage());
    } catch (Exception e) {
        logger.debug(e.getMessage());
        throw new SVGConverterException("Error converting SVG" + e.getMessage());
    } finally {
        try {
            serverPool.returnObject(server, true);
        } catch (Exception e) {
            logger.error("Exception while returning server to pool: " + e.getMessage());
        }
    }
}

From source file:Highcharts.SVGConverter.java

public String requestServer(String params)
            throws SVGConverterException, TimeoutException, NoSuchElementException, PoolException {
        Server server = null;//from w  w w . ja  v  a  2 s  . c  o m

        try {
            server = (Server) serverPool.borrowObject();
            String response = server.request(params);

            return response;
        } catch (SocketTimeoutException ste) {
            throw new TimeoutException(ste.getMessage());
        } catch (TimeoutException te) {
            throw new TimeoutException(te.getMessage());
        } catch (PoolException nse) {
            logger.error("POOL EXHAUSTED!!");
            throw new PoolException(nse.getMessage());
        } catch (Exception e) {
            logger.debug(e.getMessage());
            throw new SVGConverterException("Error converting SVG" + e.getMessage());
        } finally {
            try {
                serverPool.returnObject(server, true);
            } catch (Exception e) {
                logger.error("Exception while returning server to pool: " + e.getMessage());
            }
        }
    }

From source file:edu.vanderbilt.android.vuparking.network.ParkingClient.java

public void getResponse() {
    //String getUrl = "http://10.0.2.2:8888/vuparkingservice";
    String getUrl = "http://vuparking.appspot.com/vuparkingservice";
    HttpGet request = new HttpGet(getUrl);
    try {/*from w  ww.  j  av a  2 s.com*/
        String result;
        HttpResponse response = client.execute(request);

        int status = response.getStatusLine().getStatusCode();
        if (status == HttpStatus.SC_OK) {
            result = convertToString(response);
            //Toast.makeText(mContext, result, Toast.LENGTH_SHORT).show();
            JSONArray servResp = new JSONArray(result);

            // Update information in DB
            updateDB(servResp);
        } else {
            result = "Error when getting data from server.";
            Toast.makeText(mContext, result, Toast.LENGTH_SHORT).show();
        }
    } catch (SocketTimeoutException e) {
        Toast.makeText(mContext, "Error:" + e.getMessage(), Toast.LENGTH_SHORT).show();
    } catch (JSONException e) {
        Toast.makeText(mContext, "Error:" + e.getMessage(), Toast.LENGTH_SHORT).show();
    } catch (IOException e) {
        Toast.makeText(mContext, "Error:" + e.getMessage(), Toast.LENGTH_SHORT).show();
    }
}

From source file:com.sophia.charts.export.converter.ChartConverter.java

public String requestServer(String params)
        throws ChartConverterException, TimeoutException, NoSuchElementException, PoolException {
    Server server = null;/*from w w w .j ava2  s . com*/

    try {
        server = (Server) serverPool.borrowObject();
        String response = server.request(params);

        return response;
    } catch (SocketTimeoutException ste) {
        throw new TimeoutException(ste.getMessage());
    } catch (TimeoutException te) {
        throw new TimeoutException(te.getMessage());
    } catch (PoolException nse) {
        logger.error("POOL EXHAUSTED!!");
        throw new PoolException(nse.getMessage());
    } catch (Exception e) {
        logger.debug(e.getMessage());
        throw new ChartConverterException("Error converting SVG" + e.getMessage());
    } finally {
        try {
            serverPool.returnObject(server, true);
        } catch (Exception e) {
            logger.error("Exception while returning server to pool: " + e.getMessage());
        }
    }
}

From source file:no.sesat.search.mode.command.GoogleSearchCommand.java

@Override
public ResultList<ResultItem> execute() {

    final ResultList<ResultItem> result = new BasicResultList<ResultItem>();
    final BufferedReader reader;
    try {//from   w w w . ja  v a2 s. com

        reader = getRestful().getHttpReader("UTF8");

        if (null != reader) {

            final StringBuilder builder = new StringBuilder();
            String line;
            while (null != (line = reader.readLine())) {
                builder.append(line);
            }

            final DynaBean bean = (DynaBean) JSONSerializer.toJava(JSONSerializer.toJSON(builder.toString()));
            final DynaBean data = (DynaBean) bean.get("responseData");

            final String totalResults = ((DynaBean) data.get("cursor")).get("estimatedResultCount").toString();
            result.setHitCount(Integer.parseInt(totalResults));

            final List<DynaBean> results = (List<DynaBean>) data.get("results");

            for (DynaBean r : results) {

                result.addResult(createItem(r));
            }

        }
    } catch (SocketTimeoutException ste) {
        LOG.error(getSearchConfiguration().getName() + " --> " + ste.getMessage());
        return new BasicResultList<ResultItem>();
    } catch (IOException ex) {
        throw new SearchCommandException(ex);
    }
    return result;
}

From source file:com.highcharts.export.converter.SVGConverter.java

public String requestServer(String params)
        throws SVGConverterException, TimeoutException, NoSuchElementException, PoolException {
    Server server = null;/*from  w ww  . ja va2  s  .  c om*/

    try {
        server = (Server) serverPool.borrowObject();
        String response = server.request(params);

        return response;
    } catch (SocketTimeoutException ste) {
        logger.error(ste);
        throw new TimeoutException(ste.getMessage());
    } catch (TimeoutException te) {
        logger.error(te);
        throw new TimeoutException(te.getMessage());
    } catch (PoolException nse) {
        logger.error("POOL EXHAUSTED!!");
        throw new PoolException(nse.getMessage());
    } catch (Exception e) {
        logger.error(e);
        throw new SVGConverterException("Error converting SVG" + e.getMessage());
    } finally {
        try {
            serverPool.returnObject(server, true);
        } catch (Exception e) {
            logger.error("Exception while returning server to pool: " + e.getMessage());
        }
    }
}

From source file:com.highcharts.export.converter.SVGConverter.java

public String requestServer(String params)
        throws SVGConverterException, TimeoutException, NoSuchElementException, PoolException {
    Server server = null;//w w w  . j  av a 2 s . c o m

    try {
        server = (Server) serverPool.borrowObject();
        String response = server.request(params);

        return response;
    } catch (SocketTimeoutException ste) {
        logger.error(ste);
        throw new TimeoutException(ste.getMessage());
    } catch (TimeoutException te) {
        logger.error(te);
        throw new TimeoutException(te.getMessage());
    } catch (PoolException nse) {
        logger.error("POOL EXHAUSTED!!");
        throw new PoolException(nse.getMessage());
    } catch (Exception e) {
        logger.error(e);
        throw new SVGConverterException("Error converting SVG: " + e.getMessage());
    } finally {
        try {
            serverPool.returnObject(server, true);
        } catch (Exception e) {
            logger.error("Exception while returning server to pool: " + e.getMessage());
        }
    }
}

From source file:co.edu.uniajc.vtf.utils.RestAsyncTask.java

@Override
protected String doInBackground(String... params) {
    String lsResult = "";
    try {/*from w w  w . j a va  2 s  .c om*/
        if (params[0].equals("0")) {
            HttpGet loRequest = new HttpGet(params[1].toString());
            HttpResponse loResponse = coClient.execute(loRequest);
            lsResult = EntityUtils.toString(loResponse.getEntity());
        } else if (params[0].equals("1")) {
            HttpPost loRequest = new HttpPost(params[1].toString());
            StringEntity lsData = new StringEntity(params[2].toString());
            loRequest.setEntity(lsData);
            loRequest.setHeader("Accept", "application/json");
            loRequest.setHeader("Content-type", "application/json");

            HttpResponse loResponse = coClient.execute(loRequest);
            lsResult = EntityUtils.toString(loResponse.getEntity());
        }

    } catch (SocketTimeoutException ex) {
        this.cbohasError = true;
        lsResult = "Timeout exception";
    } catch (Exception ex) {
        this.cbohasError = true;
        lsResult = ex.getMessage();
    }

    return lsResult;
}

From source file:com.cyberway.issue.crawler.fetcher.HeritrixSSLProtocolSocketFactory.java

public synchronized Socket createSocket(String host, int port, InetAddress localAddress, int localPort,
        HttpConnectionParams params) throws IOException, UnknownHostException {
    // Below code is from the DefaultSSLProtocolSocketFactory#createSocket
    // method only it has workarounds to deal with pre-1.4 JVMs.  I've
    // cut these out.
    if (params == null) {
        throw new IllegalArgumentException("Parameters may not be null");
    }/*from   ww  w  .  j av  a2 s  . c  om*/
    Socket socket = null;
    int timeout = params.getConnectionTimeout();
    if (timeout == 0) {
        socket = createSocket(host, port, localAddress, localPort);
    } else {
        SSLSocketFactory factory = (SSLSocketFactory) params.getParameter(FetchHTTP.SSL_FACTORY_KEY);
        SSLSocketFactory f = (factory != null) ? factory : this.sslDefaultFactory;
        socket = f.createSocket();
        ServerCache cache = (ServerCache) params.getParameter(FetchHTTP.SERVER_CACHE_KEY);
        InetAddress hostAddress = (cache != null) ? HeritrixProtocolSocketFactory.getHostAddress(cache, host)
                : null;
        InetSocketAddress address = (hostAddress != null) ? new InetSocketAddress(hostAddress, port)
                : new InetSocketAddress(host, port);
        socket.bind(new InetSocketAddress(localAddress, localPort));
        try {
            socket.connect(address, timeout);
        } catch (SocketTimeoutException e) {
            // Add timeout info. to the exception.
            throw new SocketTimeoutException(
                    e.getMessage() + ": timeout set at " + Integer.toString(timeout) + "ms.");
        }
        assert socket.isConnected() : "Socket not connected " + host;
    }
    return socket;
}

From source file:org.archive.modules.fetcher.HeritrixSSLProtocolSocketFactory.java

public synchronized Socket createSocket(String host, int port, InetAddress localAddress, int localPort,
        HttpConnectionParams params) throws IOException, UnknownHostException {
    // Below code is from the DefaultSSLProtocolSocketFactory#createSocket
    // method only it has workarounds to deal with pre-1.4 JVMs.  I've
    // cut these out.
    if (params == null) {
        throw new IllegalArgumentException("Parameters may not be null");
    }//from   ww w  .  java 2 s .  c  om
    Socket socket = null;
    int timeout = params.getConnectionTimeout();
    if (timeout == 0) {
        socket = createSocket(host, port, localAddress, localPort);
    } else {
        SSLSocketFactory factory = (SSLSocketFactory) params.getParameter(FetchHTTP.SSL_FACTORY_KEY);
        SSLSocketFactory f = (factory != null) ? factory : this.sslDefaultFactory;
        socket = f.createSocket();

        Thread current = Thread.currentThread();
        InetAddress hostAddress;
        if (current instanceof HostResolver) {
            HostResolver resolver = (HostResolver) current;
            hostAddress = resolver.resolve(host);
        } else {
            hostAddress = null;
        }
        InetSocketAddress address = (hostAddress != null) ? new InetSocketAddress(hostAddress, port)
                : new InetSocketAddress(host, port);
        socket.bind(new InetSocketAddress(localAddress, localPort));
        try {
            socket.connect(address, timeout);
        } catch (SocketTimeoutException e) {
            // Add timeout info. to the exception.
            throw new SocketTimeoutException(
                    e.getMessage() + ": timeout set at " + Integer.toString(timeout) + "ms.");
        }
        assert socket.isConnected() : "Socket not connected " + host;
    }
    return socket;
}