1

There are a few similar questions, but for C# mostly.

@Override
public void setExtraItemsDone(XMPPResourceConnection session) throws NotAuthorizedException 
{
    try
    {
        cp1 = Calendar.getInstance().getTimeInMillis();

        try 
        {
             ...

        } catch (TigaseDBException e) {

                         ...

        } catch (UnsupportedOperationException e) {

                         ...
        }


    } catch (Exception e) {

        cp2 = Calendar.getInstance().getTimeInMillis();
        throw new NotAuthorizedException(e.getMessage() + "; method took " + (cp2 - cp1) + " ms", e); 
    }

I am basically looking to catch a MySQLTimeoutException and turn it into a NotAuthorizedException (while keeping an eye for any other stuff besides TigaseDBException and UnsupportedOperationException) in the last catch block. Somehow, java eludes my master plan.

Logs show a straight

com.mysql.jdbc.exceptions.MySQLTimeoutException: Statement cancelled due to timeout or client request
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1754)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2019)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1937)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1922)
at tigase.db.jdbc.JDBCRepository.addDataList(JDBCRepository.java:183)
at tigase.db.jdbc.JDBCRepository.setDataList(JDBCRepository.java:1175)
at tigase.db.UserRepositoryMDImpl.setDataList(UserRepositoryMDImpl.java:651)
at tigase.xmpp.RepositoryAccess.setDataList(RepositoryAccess.java:1152)
at tigase.xmpp.RepositoryAccess.setOfflineDataList(RepositoryAccess.java:1204)
**at tigase.xmpp.impl.XGateRoster.setExtraItemsDone(XGateRoster.java:370)**
at tigase.xmpp.impl.DynamicRoster.setExtraItemsDone(DynamicRoster.java:377)
at tigase.xmpp.impl.JabberIqRoster.dynamicSetRequest(JabberIqRoster.java:178)
at tigase.xmpp.impl.JabberIqRoster.process(JabberIqRoster.java:329)
at tigase.server.xmppsession.SessionManager$ProcessorWorkerThread.process(SessionManager.java:2135)
at tigase.util.WorkerThread.run(WorkerThread.java:132)

As far as i can tell, the bolded line in the stack trace should have changed the exception to a NotAuthorizedException breed. What am I missing ?

Thanks

4

1 回答 1

0

我同意。问题不在于发布的代码。检查你的假设。XGateRoster.setExtraItemsDone 是否还有其他重载?尝试使用 Jad 反编译您正在运行的类文件。如果您启用显示行号的选项,您可以确定您正在查看的(反编译的)源代码正是正在执行的代码。您是否确切知道您正在查看的日志消息来自哪里?也许它来自更高的堆栈,在它被抛出之后但在这个 catch 块和异常转换代码甚至被命中之前。

于 2012-05-28T14:09:59.737 回答