From 0740c8b7e0e57f72419ff6d5ad8523183e505caf Mon Sep 17 00:00:00 2001
From: gmantele <gmantele@ari.uni-heidelberg.de>
Date: Wed, 12 Nov 2014 17:59:31 +0100
Subject: [PATCH] [UWS] Change phase to ERROR when a JobThread can not be
 created while starting a job.

---
 src/uws/job/UWSJob.java | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/src/uws/job/UWSJob.java b/src/uws/job/UWSJob.java
index 735558d..b714f19 100644
--- a/src/uws/job/UWSJob.java
+++ b/src/uws/job/UWSJob.java
@@ -119,7 +119,7 @@ import uws.service.log.UWSLog.LogLevel;
  * </ul>
  * 
  * @author	Gr&eacute;gory Mantelet (CDS;ARI)
- * @version	4.1 (10/2014)
+ * @version	4.1 (11/2014)
  */
 public class UWSJob extends SerializableUWSObject {
 	private static final long serialVersionUID = 1L;
@@ -1151,9 +1151,14 @@ public class UWSJob extends SerializableUWSObject {
 		}// Otherwise start directly the execution:
 		else{
 			// Create its corresponding thread:
-			thread = getFactory().createJobThread(this);
-			if (thread == null)
-				throw new NullPointerException("Missing job work ! The thread created by the factory is NULL => The job can't be executed !");
+			try{
+				thread = getFactory().createJobThread(this);
+				if (thread == null)
+					throw new NullPointerException("Missing job work ! The thread created by the factory is NULL => The job can't be executed !");
+			}catch(UWSException ue){
+				setPhase(ExecutionPhase.ERROR);
+				throw ue;
+			}
 
 			// Change the job phase:
 			setPhase(ExecutionPhase.EXECUTING);
-- 
GitLab