1:An instanceof check is being performed on the caught exception. Create a separate catch clause for this exception type
catch (AxisFault e)
{
if (e instanceof RemoteException)
{
connState = false;
}
}
修改成:
catch (AxisFault e)
{
if (e.getCause() instanceof RemoteException)
{
connState = false;
}
}
但是注意:e.getCause() instanceof RemoteException 虽然可以通过PMD检查,但是功能失效,原因是e.getCause() instanceof RemoteException 为false。修改成:e.getCause() instanceof ConnectException。则可通过。
本文讨论了在捕获AxisFault异常时如何正确地检查其原因是否为RemoteException的问题,并给出了具体的代码修改建议。
295

被折叠的 条评论
为什么被折叠?



