Hi list,<br><br>During my application development, I encountered some problems about the exception handling within SingleSessionCommandService class.<br><br>In this constructor<br><br>    public SingleSessionCommandService(KnowledgeBase kbase,<br>

                                       KnowledgeSessionConfiguration conf,<br>                                       Environment env) {<br clear="all"><br>the exceptions are handled like this<br><br>try {<br>    ....<br>
}  catch ( Exception t1 ) {<br>
    try {<br>        this.txm.rollback(); // line 1<br>    } catch ( Throwable t2 ) {<br>        throw new RuntimeException( &quot;Could not commit session or rollback&quot;, t2 ); // line 2<br>    }<br>    throw new RuntimeException( &quot;Could not commit session&quot;, t1 ); // line 3<br>

}<br><br>In the first try block, if some exception occurred, exception t1 will be caught, then this.txm (TransactionManager) will be rolled back. But during this piece of code, if exception occurred again, throwable t2 will be caught, then t2 will be wrapped into another runtime exception and re-throw. In this case the wrapped t1 (in line 3) will never be throw out. But in my situation, the wrapped t1 exception will be more meaningful than the wrapped t2 exception.<br>

<br>So I think this code should be changed like this:<br><br>try {<br>    ...<br>} catch (Exception t1) {<br>    try {<br>        this.txm.rollback();<br>    } catch (Throwable t2) {<br>        logger.error(t2.getMessage(), t2); // or some other logs, but do NOT rethrow<br>

    }<br>     throw new RuntimeException( &quot;Could not commit session&quot;, t1 <br>}<br><br>Is this right?<br>-- <br>唐睿<br>