summaryrefslogtreecommitdiff
path: root/eaaf_core/src
diff options
context:
space:
mode:
authorThomas Lenz <thomas.lenz@egiz.gv.at>2020-11-20 11:45:20 +0100
committerThomas Lenz <thomas.lenz@egiz.gv.at>2020-11-20 11:45:20 +0100
commit2c8d2e81c99615bd1f57fd19f18f1ce3e6d7efed (patch)
tree147066860bfd45261c83b5496d4e08e7e199d9be /eaaf_core/src
parentba2b8e1a97964c0920ddeab8fc3ea4b735e80152 (diff)
downloadEAAF-Components-2c8d2e81c99615bd1f57fd19f18f1ce3e6d7efed.tar.gz
EAAF-Components-2c8d2e81c99615bd1f57fd19f18f1ce3e6d7efed.tar.bz2
EAAF-Components-2c8d2e81c99615bd1f57fd19f18f1ce3e6d7efed.zip
fix bug in central error-handling that lead to a ClassCastException in some cases (Jira EID-647)
Diffstat (limited to 'eaaf_core/src')
-rw-r--r--eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/services/ProtocolAuthenticationService.java56
1 files changed, 34 insertions, 22 deletions
diff --git a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/services/ProtocolAuthenticationService.java b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/services/ProtocolAuthenticationService.java
index 98149957..8c258a14 100644
--- a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/services/ProtocolAuthenticationService.java
+++ b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/services/ProtocolAuthenticationService.java
@@ -29,6 +29,17 @@ import javax.naming.ConfigurationException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import org.apache.commons.lang3.ArrayUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.text.StringEscapeUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.ApplicationContext;
+import org.springframework.lang.NonNull;
+import org.springframework.lang.Nullable;
+import org.springframework.stereotype.Service;
+
import at.gv.egiz.components.eventlog.api.EventConstants;
import at.gv.egiz.eaaf.core.api.IRequest;
import at.gv.egiz.eaaf.core.api.IRequestStorage;
@@ -59,6 +70,7 @@ import at.gv.egiz.eaaf.core.exceptions.GuiBuildException;
import at.gv.egiz.eaaf.core.exceptions.InvalidProtocolRequestException;
import at.gv.egiz.eaaf.core.exceptions.ProcessExecutionException;
import at.gv.egiz.eaaf.core.exceptions.ProtocolNotActiveException;
+import at.gv.egiz.eaaf.core.exceptions.TaskExecutionException;
import at.gv.egiz.eaaf.core.impl.data.Pair;
import at.gv.egiz.eaaf.core.impl.gui.AbstractGuiFormBuilderConfiguration;
import at.gv.egiz.eaaf.core.impl.http.HttpUtils;
@@ -67,17 +79,6 @@ import at.gv.egiz.eaaf.core.impl.idp.controller.protocols.RequestImpl;
import at.gv.egiz.eaaf.core.impl.utils.KeyValueUtils;
import at.gv.egiz.eaaf.core.impl.utils.ServletUtils;
-import org.apache.commons.lang3.ArrayUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.text.StringEscapeUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.ApplicationContext;
-import org.springframework.lang.NonNull;
-import org.springframework.lang.Nullable;
-import org.springframework.stereotype.Service;
-
@Service
public class ProtocolAuthenticationService implements IProtocolAuthenticationService {
private static final Logger log = LoggerFactory.getLogger(ProtocolAuthenticationService.class);
@@ -379,21 +380,32 @@ public class ProtocolAuthenticationService implements IProtocolAuthenticationSer
*
* @param loggedException Exception to log
*/
- protected void logExceptionToTechnicalLog(final Throwable loggedException) {
- if (!(loggedException instanceof EaafException
- || loggedException instanceof ProcessExecutionException)) {
+ protected void logExceptionToTechnicalLog(final Throwable loggedException) {
+ // In case of a TaskExecutionException, which is only a container for process-errors,
+ // extract internal exception
+ Throwable toLog;
+ if (loggedException instanceof TaskExecutionException) {
+ toLog = ((TaskExecutionException)loggedException);
+
+ } else {
+ toLog = loggedException;
+
+ }
+
+ // Log exception
+ if (!(toLog instanceof EaafException)) {
log.error(TECH_LOG_MSG, IStatusMessenger.CODES_INTERNAL_ERROR_GENERIC,
- loggedException.getMessage(), loggedException);
+ toLog.getMessage(), toLog);
- } else {
- if (loggedException instanceof EaafException
- && logOnInfoLevel.contains(((EaafException) loggedException).getErrorId())) {
- log.info(TECH_LOG_MSG, ((EaafException) loggedException).getErrorId(),
- loggedException.getMessage(), loggedException);
+ } else {
+ if (toLog instanceof EaafException
+ && logOnInfoLevel.contains(((EaafException) toLog).getErrorId())) {
+ log.info(TECH_LOG_MSG, ((EaafException) toLog).getErrorId(),
+ toLog.getMessage(), toLog);
} else {
- log.warn(TECH_LOG_MSG, ((EaafException) loggedException).getErrorId(),
- loggedException.getMessage(), loggedException);
+ log.warn(TECH_LOG_MSG, ((EaafException) toLog).getErrorId(),
+ toLog.getMessage(), toLog);
}
}