Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* <p>Modifications copyright (C) 2017 Uber Technologies, Inc.
*
* <p>Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file
* except in compliance with the License. A copy of the License is located at
*
* <p>http://aws.amazon.com/apache2.0
*
* <p>or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
package com.uber.cadence.client;

import com.uber.cadence.CadenceError;

public final class ApplicationFailureException extends CadenceError {

public ApplicationFailureException(String message) {
super(message);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.google.gson.reflect.TypeToken;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import com.uber.cadence.client.ApplicationFailureException;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
Expand Down Expand Up @@ -137,7 +138,7 @@ public T read(JsonReader jsonReader) throws IOException {
try {
classType = Class.forName(className);
} catch (ClassNotFoundException e) {
throw new IOException("Cannot deserialize " + className + " exception", e);
classType = ApplicationFailureException.class;
}
if (!Throwable.class.isAssignableFrom(classType)) {
throw new IOException("Expected type that extends Throwable: " + className);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import com.uber.cadence.WorkflowExecutionStartedEventAttributes;
import com.uber.cadence.WorkflowType;
import com.uber.cadence.activity.Activity;
import com.uber.cadence.client.ApplicationFailureException;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
Expand Down Expand Up @@ -270,4 +271,23 @@ public void testException() {

assertEquals("root exception", causeFromConverted.getSuppressed()[0].getMessage());
}

@Test
public void testExceptionNotFound() {
String convertedString =
"{\n"
+ " \"detailMessage\": \"application exception\",\n"
+ " \"stackTrace\": \"com.uber.cadence.converter.JsonDataConverterTest.testExceptionNotFound(JsonDataConverterTest.java:282)\\nsun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\\nsun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\\nsun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\\njava.lang.reflect.Method.invoke(Method.java:498)\\norg.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)\\norg.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)\\norg.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)\\norg.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)\\norg.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)\\norg.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)\\norg.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)\\norg.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)\\norg.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)\\norg.junit.runners.ParentRunner$4.run(ParentRunner.java:331)\\norg.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)\\norg.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)\\norg.junit.runners.ParentRunner.access$100(ParentRunner.java:66)\\norg.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)\\norg.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)\\norg.junit.runners.ParentRunner.run(ParentRunner.java:413)\\norg.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:93)\\norg.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:40)\\norg.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:520)\\norg.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:748)\\norg.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:443)\\norg.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:211)\\n\",\n"
+ " \"suppressedExceptions\": [],\n"
+ " \"class\": \"com.uber.cadence.converter.ExceptionNotFound\"\n"
+ "}";
RuntimeException fromConverted =
converter.fromData(
convertedString.getBytes(StandardCharsets.UTF_8),
RuntimeException.class,
RuntimeException.class);
assertEquals(ApplicationFailureException.class, fromConverted.getClass());
assertEquals("application exception", fromConverted.getMessage());
assertNotSame(fromConverted.getStackTrace().length, 0);
}
}
Loading