简体   繁体   中英

Strange behavior using Apache HttpClient

I am new to OSGi and it's the first time I am using Apache HttpClient under OSGi.

When I execute this code...

try {
        System.out.println("> Creating Method Request");
        HttpGet httpGet = new HttpGet(baseUri + codec.encode(data));

        System.out.println("> Creating Client");
        CloseableHttpClient httpclient = HttpClients.createDefault();

        System.out.println("> Use Objects");

    } catch (Exception ex) {

        System.out.println("> Exception " + ex.getCause());

    } finally {

        System.out.println("> Finally");
    }

, I get this behavior: "> Creating Client" gets printed followed by "> Finally". No exception is caught but ">Using Objects" is never print.

Does anyone know what could be causing this? Thanks in advance.

Because an Error was thrown rather than an Exception ? Change the catch (Exception to catch (Throwable and see what happens.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM