Skip to content

SpringActivityWorker.addActivitiesImplementation does not use the DataConverter set in setDataConverter method; uses default instead #13

@kiiadi

Description

@kiiadi

(moved from aws/aws-sdk-java#925 issue opened by @jonkerlinger )
When calling setActivitiesImplementation or addActivitiesImplementation on the SpringActivityWorker, the single-arg POJOActivityImplementationFactory.addActivitiesImplementation, which ultimately will only use the default DataConverter or the Activities annotation-specified DataConverter. Even though the POJO implementation of SpringActivityWorker allows users to specify the DataConverter, it is not used when adding ActivitiesImplementations.

To work around it, I've had to extend SpringActivityWorker with something like this:

    @Override
    public List<ActivityType> addActivitiesImplementation(Object activitiesImplementation) {
        try {
            Field field = SpringActivityWorker.class.getDeclaredField("factory");
            field.setAccessible(true);
            POJOActivityImplementationFactory factory = (POJOActivityImplementationFactory) field.get(this);

            return factory.addActivitiesImplementation(activitiesImplementation, factory.getDataConverter());
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

The override works fine for now, but is hacky. It seems that since setDataConverter sets the factory DataConverter, then that value should also be passed into the addActivitiesImplementation call, or the POJO factory should use the dataConverter field if present, rather than just looking at the annotation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions