From 6a448b36c9b40d9c278d8fc32a1c48a8101ee133 Mon Sep 17 00:00:00 2001
From: gmantele <gmantele@ari.uni-heidelberg.de>
Date: Tue, 23 Sep 2014 17:38:43 +0200
Subject: [PATCH] [UWS] Fix function call loop when managing an error at the
 root service level.

---
 src/uws/service/UWSService.java | 2 +-
 src/uws/service/UWSServlet.java | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/uws/service/UWSService.java b/src/uws/service/UWSService.java
index 968a099..01acdeb 100644
--- a/src/uws/service/UWSService.java
+++ b/src/uws/service/UWSService.java
@@ -1140,7 +1140,7 @@ public class UWSService implements UWS {
 			// Apply the redirection:
 			redirect(error.getMessage(), request, user, uwsAction, response);
 		}else
-			sendError(error, request, reqID, user, uwsAction, response);
+			sendError((Exception)error, request, reqID, user, uwsAction, response);
 	}
 
 	/**
diff --git a/src/uws/service/UWSServlet.java b/src/uws/service/UWSServlet.java
index 2936d8d..33d8b4a 100644
--- a/src/uws/service/UWSServlet.java
+++ b/src/uws/service/UWSServlet.java
@@ -501,7 +501,7 @@ public abstract class UWSServlet extends HttpServlet implements UWS, UWSFactory
 				InputStream input = null;
 				try{
 					input = getFileManager().getErrorInput(error, job);
-					UWSToolBox.write(input, "text/plain", getFileManager().getErrorSize(error, job), resp);
+					UWSToolBox.write(input, errorWriter.getErrorDetailsMIMEType(), getFileManager().getErrorSize(error, job), resp);
 				}catch(IOException ioe){
 					getLogger().logUWS(LogLevel.ERROR, error, "GET_ERROR", "Can not read the details of the error summary of the job \"" + job.getJobId() + "\"!", ioe);
 					throw new UWSException(UWSException.INTERNAL_SERVER_ERROR, ioe, "Can not read the error details (job ID: " + job.getJobId() + ").");
@@ -649,7 +649,7 @@ public abstract class UWSServlet extends HttpServlet implements UWS, UWSFactory
 				throw new ServletException("Can not redirect the response! You should notify the administrator of the service (FATAL-" + reqID + "). However, while waiting a correction of this problem, you can manually go toward " + error.getMessage() + ".");
 			}
 		}else
-			sendError(error, request, reqID, user, uwsAction, response);
+			sendError((Exception)error, request, reqID, user, uwsAction, response);
 	}
 
 	/**
-- 
GitLab