java - Java try-catch-finally 中的奇怪错误

标签 java try-catch program-flow jodconverter

我正在使用 JODConverter 将 .xls 和 .ppt 转换为 .pdf 格式。为此,我有类似的代码

try{
    //do something
    System.out.println("connecting to open office");
    OpenOfficeConnection connection = new SocketOpenOfficeConnection(8100);
    System.out.println("connection object created");
    connection.connect();
    System.out.println("connection to open office successful");
    //do something
    if(!successful)
      throw new FileNotFoundException();
}catch(Exception e){
   System.out.println("hello here");
   System.out.println("Caught Exception while converting to PDF ");
   LOGGER.error("Error in converting media" + e.getMessage());
   throw new MediaConversionFailedException();
}finally{
   decode_pdf.closePdfFile();
   System.out.println("coming in finally");
  //do something here
}

我的输出:

connecting to open office
connection object created
coming in finally

附言方法的返回类型为 void

这怎么可能?即使 connection.connect() 中有问题,它也会出现在 catch block 中。 困惑

最佳答案

可能抛出了一个错误。这仍然会导致 try block 未完成,忽略 catch 异常 block 并调用 finally block 。

关于java - Java try-catch-finally 中的奇怪错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6517057/

相关文章:

java - 调用 setDefaultHostnameVerifier 后出现 SSLHandshakeException,禁用 SSL 验证

Javascript 在 catch block 中丢失了回溯

java - 如何防止 JPA 查询包含 String 构造函数,当 null String 值仅可用时抛出 NullPointerException

Java Spring Thymeleaf 将枚举集合绑定(bind)到复选框时出错

java - 搜索扩展名为 .java 的文件

通过 try block 处理 Swift 2.2 错误

java - 遍历 try/catch block ?

c++ - 在调试期间,我的程序跳转到最近的 while 语句而不中断或继续 [C++]

objective-c - 如何找出谁是方法或函数的调用者?