diff options
author | Thomas Lenz <thomas.lenz@egiz.gv.at> | 2020-10-13 16:31:03 +0200 |
---|---|---|
committer | Thomas Lenz <thomas.lenz@egiz.gv.at> | 2020-10-13 16:31:03 +0200 |
commit | 54fdf1c8201312ffedec71595aa6602bb11e7640 (patch) | |
tree | 66fbf26805f04b3d4495365a6dc66abbea2fe285 /eaaf_core | |
parent | 379cd870ec5a3e6d66825d75a37e091e4e181074 (diff) | |
download | EAAF-Components-54fdf1c8201312ffedec71595aa6602bb11e7640.tar.gz EAAF-Components-54fdf1c8201312ffedec71595aa6602bb11e7640.tar.bz2 EAAF-Components-54fdf1c8201312ffedec71595aa6602bb11e7640.zip |
Serialize exceptions in error-handler manually to fix problems with Serialization in some caching frameworks
Diffstat (limited to 'eaaf_core')
2 files changed, 29 insertions, 14 deletions
diff --git a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/controller/AbstractController.java b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/controller/AbstractController.java index e9687833..58c8c0a9 100644 --- a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/controller/AbstractController.java +++ b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/controller/AbstractController.java @@ -47,6 +47,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; +import org.springframework.util.SerializationUtils; import org.springframework.web.bind.annotation.ExceptionHandler; /** @@ -170,11 +171,21 @@ public abstract class AbstractController { final String errorKey = Random.nextLongRandom(); if (errorToHandle.getFirst() != null) { revisionsLogger.logEvent(errorToHandle.getFirst(), EventConstants.TRANSACTION_ERROR); - transactionStorage.put(errorKey, new ExceptionContainer(errorToHandle.getFirst(), errorToHandle - .getSecond()), -1); + + log.trace("Serializing {} ... ", ExceptionContainer.class.getName()); + final byte[] serializedError = SerializationUtils.serialize( + new ExceptionContainer(errorToHandle.getFirst(), errorToHandle.getSecond())); + + log.trace("Put 'ExceptionContainer' into cache ... "); + transactionStorage.put(errorKey, serializedError, -1); } else { - transactionStorage.put(errorKey, new ExceptionContainer(null, errorToHandle.getSecond()), -1); + log.trace("Serializing {} ... ", ExceptionContainer.class.getName()); + final byte[] serializedError = SerializationUtils.serialize( + new ExceptionContainer(null, errorToHandle.getSecond())); + + log.trace("Put 'ExceptionContainer' into cache ... "); + transactionStorage.put(errorKey, serializedError, -1); } diff --git a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/controller/ProtocolFinalizationController.java b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/controller/ProtocolFinalizationController.java index 17da63f5..dc8caabd 100644 --- a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/controller/ProtocolFinalizationController.java +++ b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/controller/ProtocolFinalizationController.java @@ -24,14 +24,6 @@ import java.io.IOException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.apache.commons.text.StringEscapeUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; - import at.gv.egiz.components.eventlog.api.EventConstants; import at.gv.egiz.eaaf.core.api.IRequest; import at.gv.egiz.eaaf.core.api.IRequestStorage; @@ -40,6 +32,15 @@ import at.gv.egiz.eaaf.core.api.data.EaafConstants; import at.gv.egiz.eaaf.core.api.data.ExceptionContainer; import at.gv.egiz.eaaf.core.exceptions.EaafException; +import org.apache.commons.text.StringEscapeUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.util.SerializationUtils; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; + /** * Protocol finialization end-point. * @@ -73,12 +74,15 @@ public class ProtocolFinalizationController extends AbstractController { IRequest pendingReq = null; try { // load stored exception from database - final ExceptionContainer container = - transactionStorage.get(errorid, ExceptionContainer.class); - if (container != null) { + final byte[] containerSerialized = + transactionStorage.get(errorid, byte[].class); + if (containerSerialized != null) { // remove exception if it was found transactionStorage.remove(errorid); + final ExceptionContainer container = + (ExceptionContainer) SerializationUtils.deserialize(containerSerialized); + final Throwable throwable = container.getExceptionThrown(); pendingReq = container.getPendingRequest(); |