[
https://jira.jboss.org/jira/browse/JBPM-2133?page=com.atlassian.jira.plug...
]
Volker Börchers updated JBPM-2133:
----------------------------------
Description:
regards CommndServiceBean.execute(Command command):
public Object execute(Command command)
{
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
try
{
log.debug("executing " + command);
return command.execute(jbpmContext);
}
catch (RuntimeException e)
{
sessionContext.setRollbackOnly();
throw e;
}
catch (Exception e)
{
sessionContext.setRollbackOnly();
throw new JbpmException("failed to execute " + command, e);
}
finally
{
jbpmContext.close();
}
}
If an exception occurres in Command.excute() it's important that this exception is
propagated to the client to allow for proper exception handling to differentiate e.g.
between a concurrency issue ("job is locked by...") and a database error.
These exceptions are not propagated to the client if the jbpmContext.close() in the
finally block throws an exceptions. This might very well happen since it performs
non-trivial operations, e.g. access the database. (Actually it it seems to me as if the
failure of jbpmContext.close() always happen, maybe since after the setRollbackOnly() no
new connections are possible.)
The following change will fix the problem:
public Object execute(Command command)
{
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
boolean exceptionThrown = false;
try
{
log.debug("executing " + command);
return command.execute(jbpmContext);
}
catch (RuntimeException e)
{
sessionContext.setRollbackOnly();
exceptionThrown = true;
throw e;
}
catch (Exception e)
{
sessionContext.setRollbackOnly();
exceptionThrown = true;
throw new JbpmException("failed to execute " + command, e);
}
finally
{
try
{
jbpmContext.close();
}
catch (RuntimeException e2) {
if (exceptionThrown)
{
// JIRA XX: do not hide thrown exception
log.error("exception on context close", e2);
}
else
{
throw e2;
}
}
}
}
was:
regards CommndServiceBean.execute(Command command):
public Object execute(Command command)
{
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
try
{
log.debug("executing " + command);
return command.execute(jbpmContext);
}
catch (RuntimeException e)
{
sessionContext.setRollbackOnly();
throw e;
}
catch (Exception e)
{
sessionContext.setRollbackOnly();
throw new JbpmException("failed to execute " + command, e);
}
finally
{
jbpmContext.close();
}
}
If an exception occurres in Command.excute() it's important that this exception is
propagated to the client to allow for proper exception handling to differentiate e.g.
between a concurrency issue ("job is locked by...") and a database error.
These exceptions are not propagated to the client if the jbpmContext.close() in the
finally block throws an exceptions. This might very well happen since it performs
non-trivial operations, e.g. access the database. (Actually it it seems to me as if the
failure of jbpmContext.close() always happen, maybe since after the setRollbackOnly() no
new connections are possible.)
The following change will fix the problem:
public Object execute(Command command)
{
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
boolean exceptionThrown = false;
try
{
log.debug("executing " + command);
return command.execute(jbpmContext);
}
catch (RuntimeException e)
{
sessionContext.setRollbackOnly();
exceptionThrown = true;
throw e;
}
catch (Exception e)
{
sessionContext.setRollbackOnly();
exceptionThrown = true;
throw new JbpmException("failed to execute " + command, e);
}
finally
{
try
{
jbpmContext.close();
}
catch (Exception e2) {
if (exceptionThrown)
{
// JIRA XX: do not hide thrown exception
log.error("exception on context close", e2);
}
else
{
throw e2;
}
}
}
}
Error handling in CommandServiceBean.execute
--------------------------------------------
Key: JBPM-2133
URL:
https://jira.jboss.org/jira/browse/JBPM-2133
Project: JBoss jBPM
Issue Type: Patch
Security Level: Public(Everyone can see)
Affects Versions: jBPM 3.2.6.SP1
Environment: irrelevant
Reporter: Volker Börchers
Priority: Minor
regards CommndServiceBean.execute(Command command):
public Object execute(Command command)
{
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
try
{
log.debug("executing " + command);
return command.execute(jbpmContext);
}
catch (RuntimeException e)
{
sessionContext.setRollbackOnly();
throw e;
}
catch (Exception e)
{
sessionContext.setRollbackOnly();
throw new JbpmException("failed to execute " + command, e);
}
finally
{
jbpmContext.close();
}
}
If an exception occurres in Command.excute() it's important that this exception is
propagated to the client to allow for proper exception handling to differentiate e.g.
between a concurrency issue ("job is locked by...") and a database error.
These exceptions are not propagated to the client if the jbpmContext.close() in the
finally block throws an exceptions. This might very well happen since it performs
non-trivial operations, e.g. access the database. (Actually it it seems to me as if the
failure of jbpmContext.close() always happen, maybe since after the setRollbackOnly() no
new connections are possible.)
The following change will fix the problem:
public Object execute(Command command)
{
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
boolean exceptionThrown = false;
try
{
log.debug("executing " + command);
return command.execute(jbpmContext);
}
catch (RuntimeException e)
{
sessionContext.setRollbackOnly();
exceptionThrown = true;
throw e;
}
catch (Exception e)
{
sessionContext.setRollbackOnly();
exceptionThrown = true;
throw new JbpmException("failed to execute " + command, e);
}
finally
{
try
{
jbpmContext.close();
}
catch (RuntimeException e2) {
if (exceptionThrown)
{
// JIRA XX: do not hide thrown exception
log.error("exception on context close", e2);
}
else
{
throw e2;
}
}
}
}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira