嗨,为什么我的 try 块正在跳过,而控件最终会阻塞而不给出任何异常?

问题描述

我的代码如下

try{
    System.out.println("index"+index);
    System.out.println("Inside getPayloadFromKibana elsatic host" + elasticHost);
    RestHighLevelClient restClient = new RestHighLevelClient(RestClient
                    .builder(new HttpHost(elasticHost,7008,"http"))//here port number is differnt.
                    .setRequestConfigCallback(
                            requestConfigBuilder -> requestConfigBuilder.setConnectTimeout(60000).setSocketTimeout(60000))
                    .setMaxRetryTimeoutMillis(60000));
    System.out.println("restClient ::"+restClient);
    SearchRequest searchRequest = new SearchRequest();
    -----
    }catch(Exception e){
    }
    finally{}

当我在调试模式下执行我的项目时,我看到我的控件在 RestHighLevelClient 创建对象上运行时最终会阻塞,并且它没有给出任何异常或没有进入 catch 块,为什么它的行为是这样的有人可以在这里帮忙吗?

解决方法

您可能没有正确使用调试模式。 尝试扩展 Catch 块并使用 .

进行测试