For you, maybe t1 is more important than t2, but for someone else perhaps t2 is more important than t1. I don&#39;t know which solution is better, but right now, t1 is being logged and t2 is being thrown.<div>Here is the Jira issue: <meta http-equiv="content-type" content="text/html; charset=utf-8"><a href="https://jira.jboss.org/browse/JBRULES-2656">https://jira.jboss.org/browse/JBRULES-2656</a></div>

<div><br></div><div><a href="https://jira.jboss.org/browse/JBRULES-2656"></a>Best,<br clear="all"><br>XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br><br>Esteban Aliverti<br>- Developer @ <a href="http://www.plugtree.com" target="_blank">http://www.plugtree.com </a><br>

- Blog @ <a href="http://ilesteban.wordpress.com" target="_blank">http://ilesteban.wordpress.com</a><br>
<br><br><div class="gmail_quote">2010/11/14 Rui Tang <span dir="ltr">&lt;<a href="mailto:tangrui@zyeeda.com">tangrui@zyeeda.com</a>&gt;</span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

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><font color="#888888">-- <br>唐睿<br>
</font><br>_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br></blockquote></div><br></div>