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 2222import com .google .gson .reflect .TypeToken ;
2323import com .google .gson .stream .JsonReader ;
2424import com .google .gson .stream .JsonWriter ;
25+ import com .uber .cadence .client .ApplicationFailureException ;
2526import java .io .IOException ;
2627import java .io .PrintWriter ;
2728import java .io .StringWriter ;
@@ -137,7 +138,7 @@ public T read(JsonReader jsonReader) throws IOException {
137138 try {
138139 classType = Class .forName (className );
139140 } catch (ClassNotFoundException e ) {
140- return null ;
141+ return ( T ) new ApplicationFailureException ( "Class not found: " + className ) ;
141142 }
142143 if (!Throwable .class .isAssignableFrom (classType )) {
143144 throw new IOException ("Expected type that extends Throwable: " + className );
Original file line number Diff line number Diff line change 2727import com .uber .cadence .WorkflowExecutionStartedEventAttributes ;
2828import com .uber .cadence .WorkflowType ;
2929import com .uber .cadence .activity .Activity ;
30+ import com .uber .cadence .client .ApplicationFailureException ;
3031import java .io .File ;
3132import java .io .FileInputStream ;
3233import java .io .IOException ;
@@ -285,6 +286,9 @@ public void testExceptionNotFound() {
285286 convertedString .getBytes (StandardCharsets .UTF_8 ),
286287 RuntimeException .class ,
287288 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 ());
289293 }
290294}
You can’t perform that action at this time.
0 commit comments