一切正常的场景工作正常,但在使用无效凭据测试的简单错误场景中,java 示例客户端应用程序中的代码返回退出代码 0。
这段代码有什么问题?
/* * 创建于 2007 年 3 月 2 日 * SWIFT scrl */
public class BICDownloader {
public static void main(String[] args) { ... try { ... // 执行方法。statusCode = client.executeMethod(method);if (statusCode != HttpStatus.SC_OK) { // Handling HTTP error 404 and 500 not covered in this example // All http error cause in this example exit with status 1. System.err.println("Method failed: " + method.getStatusLine()+ "\n" + method.getResponseBodyAsString()); System.out.println(method.getRequestCharSet()+ "\n" + method.getRequestHeader("").toString()); exitcode = 1; } else { ... } } catch (HttpException e) { exitcode = 2; System.err.println("Fatal HTTP Error: " + e.getMessage()); e.printStackTrace(); } catch (IOException e) { exitcode = 3; System.err.println("Fatal I/O error: " + e.getMessage()); e.printStackTrace(); } finally { // Release the connection. method.releaseConnection(); System.exit(exitcode); } System.out.println("Dowload done");
} }