Example usage for java.net SocketException fillInStackTrace

List of usage examples for java.net SocketException fillInStackTrace

Introduction

In this page you can find the example usage for java.net SocketException fillInStackTrace.

Prototype

public synchronized Throwable fillInStackTrace() 

Source Link

Document

Fills in the execution stack trace.

Usage

From source file:com.hoccer.tools.HttpHelper.java

private static HttpResponse executeHTTPMethod(HttpRequestBase pMethod, int pConnectionTimeout,
        Boolean pRedirect) throws IOException, HttpClientException, HttpServerException {

    HttpParams httpParams = new BasicHttpParams();
    HttpConnectionParams.setConnectionTimeout(httpParams, pConnectionTimeout);
    HttpConnectionParams.setSoTimeout(httpParams, pConnectionTimeout);
    if (!pRedirect) {
        HttpClientParams.setRedirecting(httpParams, false);
    }/*from  w ww  .j  a  va  2s.c o m*/
    DefaultHttpClient httpclient = new HttpClientWithKeystore(httpParams);

    // Log redirects
    httpclient.setRedirectHandler(new DefaultRedirectHandler() {
        @Override
        public URI getLocationURI(HttpResponse response, HttpContext context) throws ProtocolException {
            URI uri = super.getLocationURI(response, context);
            return uri;
        }
    });

    HttpResponse response;
    try {
        response = httpclient.execute(pMethod);
    } catch (SocketException e) {
        e = new SocketException(e.getMessage() + ": " + pMethod.getURI());
        e.fillInStackTrace();
        throw e;
    }
    HttpException.throwIfError(pMethod.getURI().toString(), response);
    return response;
}