[英]Strange behavior using Apache HttpClient
I am new to OSGi and it's the first time I am using Apache HttpClient under OSGi.我是 OSGi 的新手,这是我第一次在 OSGi 下使用 Apache HttpClient。
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
?因为抛出了
Error
而不是Exception
? Change the catch (Exception
to catch (Throwable
and see what happens.更改
catch (Exception
to catch (Throwable
,看看会发生什么。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.