You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2018/01/24 15:16:40 UTC
[isis] 04/20: ISIS-1831: adds a guard in exception handler of a
RuntimeException (REST API) to avoid throwing an NPE there.
This is an automated email from the ASF dual-hosted git repository.
danhaywood pushed a commit to branch ISIS-1569-replay-commands
in repository https://gitbox.apache.org/repos/asf/isis.git
commit 573c7b4eb01267d9d336106b426903ff2c804829
Author: Dan Haywood <da...@haywood-associates.co.uk>
AuthorDate: Thu Jan 18 09:30:01 2018 +0000
ISIS-1831: adds a guard in exception handler of a RuntimeException (REST API) to avoid throwing an NPE there.
---
.../server/mappers/ExceptionMapperForRuntimeException.java | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/core/viewer-restfulobjects-server/src/main/java/org/apache/isis/viewer/restfulobjects/server/mappers/ExceptionMapperForRuntimeException.java b/core/viewer-restfulobjects-server/src/main/java/org/apache/isis/viewer/restfulobjects/server/mappers/ExceptionMapperForRuntimeException.java
index 2596c65..c83798b 100644
--- a/core/viewer-restfulobjects-server/src/main/java/org/apache/isis/viewer/restfulobjects/server/mappers/ExceptionMapperForRuntimeException.java
+++ b/core/viewer-restfulobjects-server/src/main/java/org/apache/isis/viewer/restfulobjects/server/mappers/ExceptionMapperForRuntimeException.java
@@ -26,6 +26,7 @@ import javax.ws.rs.ext.Provider;
import com.google.common.base.Throwables;
import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.isis.core.runtime.system.session.IsisSession;
import org.apache.isis.core.runtime.system.session.IsisSessionFactory;
import org.apache.isis.core.runtime.system.transaction.IsisTransaction;
@@ -35,15 +36,17 @@ public class ExceptionMapperForRuntimeException extends ExceptionMapperAbstract<
@Override
public Response toResponse(final RuntimeException ex) {
- // since already rendered...
- final IsisTransaction currentTransaction = getIsisSessionFactory().getCurrentSession()
- .getPersistenceSession().getTransactionManager().getCurrentTransaction();
-
final Throwable rootCause = Throwables.getRootCause(ex);
final List<Throwable> causalChain = Throwables.getCausalChain(ex);
for (Throwable throwable : causalChain) {
if(throwable == rootCause) {
- currentTransaction.clearAbortCause();
+ // since already rendered...
+ final IsisSession currentSession = getIsisSessionFactory().getCurrentSession();
+ if(currentSession != null) {
+ final IsisTransaction currentTransaction = currentSession
+ .getPersistenceSession().getTransactionManager().getCurrentTransaction();
+ currentTransaction.clearAbortCause();
+ }
}
}
--
To stop receiving notification emails like this one, please contact
danhaywood@apache.org.