Skip to content

Commit 01dbd13

Browse files
committed
instead of creating exception complaining about not found, try to deserialize it to the application failure exception
1 parent 700479d commit 01dbd13

File tree

3 files changed

+3
-23
lines changed

3 files changed

+3
-23
lines changed

src/main/java/com/uber/cadence/client/ApplicationFailureException.java

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,29 +15,10 @@
1515
package com.uber.cadence.client;
1616

1717
import com.uber.cadence.CadenceError;
18-
import java.util.Objects;
1918

2019
public final class ApplicationFailureException extends CadenceError {
2120

2221
public ApplicationFailureException(String message) {
2322
super(message);
2423
}
25-
26-
@Override
27-
public boolean equals(Object obj) {
28-
if (this == obj) {
29-
return true;
30-
}
31-
if (obj == null || getClass() != obj.getClass()) {
32-
return false;
33-
}
34-
ApplicationFailureException that = (ApplicationFailureException) obj;
35-
return Objects.equals(getMessage(), that.getMessage())
36-
&& Objects.equals(getCause(), that.getCause());
37-
}
38-
39-
@Override
40-
public int hashCode() {
41-
return Objects.hash(getMessage(), getCause());
42-
}
4324
}

src/main/java/com/uber/cadence/converter/CustomThrowableTypeAdapter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ public T read(JsonReader jsonReader) throws IOException {
138138
try {
139139
classType = Class.forName(className);
140140
} catch (ClassNotFoundException e) {
141-
return (T) new ApplicationFailureException("Class not found: " + className);
141+
classType = ApplicationFailureException.class;
142142
}
143143
if (!Throwable.class.isAssignableFrom(classType)) {
144144
throw new IOException("Expected type that extends Throwable: " + className);

src/test/java/com/uber/cadence/converter/JsonDataConverterTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,7 @@ public void testExceptionNotFound() {
287287
RuntimeException.class,
288288
RuntimeException.class);
289289
assertEquals(ApplicationFailureException.class, fromConverted.getClass());
290-
assertEquals(
291-
"Class not found: com.uber.cadence.converter.ExceptionNotFound",
292-
fromConverted.getMessage());
290+
assertEquals("application exception", fromConverted.getMessage());
291+
assertNotSame(fromConverted.getStackTrace().length, 0);
293292
}
294293
}

0 commit comments

Comments
 (0)