Workflow keeps retrying until max when the Exception is in FailWorkflowExceptionTypes

I am running a workflow in java sdk. I have registered exception type in FailWorkflowExceptionTypes of the worker. When there is exception, it doesn’t fail the workflow and retries it until the max attempts.
Simplified code that simulate the behavior is below,

public class HelloTest {
  static final String TASK_QUEUE = "mytaskqueue";
  static final String WORKFLOW_ID = "HelloExceptionWorkflow";

  public interface MyWorkflow {
    String workflowMethod(String greeting, String name);

  public interface MyActivity {
    String activityMethod(String greeting, String name);
  public static class MyWorkflowChildImpl implements MyWorkflow {
    private final MyActivity activities =

    public String workflowMethod(String greeting, String name) {
      return activities.activityMethod(greeting, name);

  static class MyActivityImpl implements MyActivity {

    public String activityMethod(String greeting, String name) {
      throw new IllegalStateException("this is intentional");

  public static void main(String[] args) {

    // Define the workflow service.
    WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
    WorkflowClient client = WorkflowClient.newInstance(service);
    WorkerFactory factory = WorkerFactory.newInstance(client);
    Worker worker = factory.newWorker(TASK_QUEUE);
    WorkflowImplementationOptions options =
    worker.registerWorkflowImplementationTypes(options, MyWorkflowChildImpl.class);
    worker.registerActivitiesImplementations(new MyActivityImpl());

    WorkflowOptions workflowOptions =
    MyWorkflow myWorkflow = client.newWorkflowStub(MyWorkflow.class, workflowOptions);
    myWorkflow.workflowMethod("hello", "test");

Is this a bug, or am I missing something here?

Activity exception is always wrapped in an ActivityFailure. So you either need to throw a different exception from the workflow or add ActivityFailure to the list of failed workflow types.

Thanks @maxim . Where does the failWorkflowExceptionType apply then?

It applies to exceptions thrown from a workflow. In your case an ActivityFailure is thrown.