Skip to content

Commit ed6f165

Browse files
Move check exception is Serializable into ResultHolder implementations
1 parent 89f8ff6 commit ed6f165

File tree

4 files changed

+8
-7
lines changed

4 files changed

+8
-7
lines changed

taskmaster-service-helper/src/main/java/com/github/bordertech/taskmaster/service/impl/ResultHolderDefault.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.github.bordertech.taskmaster.service.impl;
22

33
import com.github.bordertech.taskmaster.service.ResultHolder;
4+
import com.github.bordertech.taskmaster.service.util.ExceptionUtil;
45
import java.io.Serializable;
56

67
/**
@@ -63,7 +64,8 @@ public ResultHolderDefault(final M metaData, final Exception exception) {
6364
}
6465
this.metaData = metaData;
6566
this.result = null;
66-
this.exception = exception;
67+
// Check exception is serializable (sometimes they arent)
68+
this.exception = ExceptionUtil.getSerializableException(exception);
6769
}
6870

6971
/**

taskmaster-service-helper/src/main/java/com/github/bordertech/taskmaster/service/impl/ResultHolderMutable.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.github.bordertech.taskmaster.service.impl;
22

33
import com.github.bordertech.taskmaster.service.ResultHolder;
4+
import com.github.bordertech.taskmaster.service.util.ExceptionUtil;
45
import java.io.Serializable;
56

67
/**
@@ -68,7 +69,8 @@ public Exception getException() {
6869
* @param exception the exception when calling the service
6970
*/
7071
public void setException(final Exception exception) {
71-
this.exception = exception;
72+
// Check exception is serializable (sometimes they arent)
73+
this.exception = ExceptionUtil.getSerializableException(exception);
7274
this.result = null;
7375
}
7476

taskmaster-service-helper/src/main/java/com/github/bordertech/taskmaster/service/impl/ServiceActionRunnable.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.github.bordertech.taskmaster.service.impl;
22

33
import com.github.bordertech.taskmaster.service.ServiceAction;
4-
import com.github.bordertech.taskmaster.service.util.ExceptionUtil;
54
import java.io.Serializable;
65

76
/**
@@ -33,8 +32,7 @@ public void run() {
3332
T resp = getAction().service(getCriteria());
3433
result.setResult(resp);
3534
} catch (Exception e) {
36-
// Check exception is serializable to be held in the cache (sometimes they arent)
37-
result.setException(ExceptionUtil.getSerializableException(e));
35+
result.setException(e);
3836
}
3937
}
4038

taskmaster-service-helper/src/main/java/com/github/bordertech/taskmaster/service/impl/ServiceHelperProviderDefault.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import com.github.bordertech.taskmaster.service.ServiceHelperProvider;
1212
import com.github.bordertech.taskmaster.service.exception.RejectedServiceException;
1313
import com.github.bordertech.taskmaster.service.exception.ServiceException;
14-
import com.github.bordertech.taskmaster.service.util.ExceptionUtil;
1514
import java.io.Serializable;
1615
import java.util.concurrent.TimeUnit;
1716
import javax.cache.Cache;
@@ -143,7 +142,7 @@ public <S extends Serializable, T extends Serializable> ResultHolder<S, T> invok
143142
T resp = action.service(criteria);
144143
return new ResultHolderDefault<>(criteria, resp);
145144
} catch (Exception e) {
146-
return new ResultHolderDefault(criteria, ExceptionUtil.getSerializableException(e));
145+
return new ResultHolderDefault(criteria, e);
147146
}
148147
}
149148

0 commit comments

Comments
 (0)