File tree Expand file tree Collapse file tree 3 files changed +50
-2
lines changed
main/java/com/uber/cadence
test/java/com/uber/cadence/converter Expand file tree Collapse file tree 3 files changed +50
-2
lines changed Original file line number Diff line number Diff line change
1
+ /**
2
+ * Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ *
4
+ * <p>Modifications copyright (C) 2017 Uber Technologies, Inc.
5
+ *
6
+ * <p>Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file
7
+ * except in compliance with the License. A copy of the License is located at
8
+ *
9
+ * <p>http://aws.amazon.com/apache2.0
10
+ *
11
+ * <p>or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
13
+ * specific language governing permissions and limitations under the License.
14
+ */
15
+ package com .uber .cadence .client ;
16
+
17
+ import com .uber .cadence .CadenceError ;
18
+ import java .util .Objects ;
19
+
20
+ public final class ApplicationFailureException extends CadenceError {
21
+
22
+ public ApplicationFailureException (String message ) {
23
+ super (message );
24
+ }
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
+ }
43
+ }
Original file line number Diff line number Diff line change 22
22
import com .google .gson .reflect .TypeToken ;
23
23
import com .google .gson .stream .JsonReader ;
24
24
import com .google .gson .stream .JsonWriter ;
25
+ import com .uber .cadence .client .ApplicationFailureException ;
25
26
import java .io .IOException ;
26
27
import java .io .PrintWriter ;
27
28
import java .io .StringWriter ;
@@ -137,7 +138,7 @@ public T read(JsonReader jsonReader) throws IOException {
137
138
try {
138
139
classType = Class .forName (className );
139
140
} catch (ClassNotFoundException e ) {
140
- return null ;
141
+ return ( T ) new ApplicationFailureException ( "Class not found: " + className ) ;
141
142
}
142
143
if (!Throwable .class .isAssignableFrom (classType )) {
143
144
throw new IOException ("Expected type that extends Throwable: " + className );
Original file line number Diff line number Diff line change 27
27
import com .uber .cadence .WorkflowExecutionStartedEventAttributes ;
28
28
import com .uber .cadence .WorkflowType ;
29
29
import com .uber .cadence .activity .Activity ;
30
+ import com .uber .cadence .client .ApplicationFailureException ;
30
31
import java .io .File ;
31
32
import java .io .FileInputStream ;
32
33
import java .io .IOException ;
@@ -285,6 +286,9 @@ public void testExceptionNotFound() {
285
286
convertedString .getBytes (StandardCharsets .UTF_8 ),
286
287
RuntimeException .class ,
287
288
RuntimeException .class );
288
- assertNull (fromConverted );
289
+ assertEquals (ApplicationFailureException .class , fromConverted .getClass ());
290
+ assertEquals (
291
+ "Class not found: com.uber.cadence.converter.ExceptionNotFound" ,
292
+ fromConverted .getMessage ());
289
293
}
290
294
}
You can’t perform that action at this time.
0 commit comments