Skip to content

no default constructor for io.dapr.client.domain.CloudEvent #385

Description

@beiwei30

Expected Behavior

A default constructor of CloudEvent is helpful for unmarshalling the payload to the exact type automatically in a Spring MVC application, for example:

@RestController
public class MqBindingController {

    @Autowired
    @Qualifier("jsonDaprClient")
    private DaprClient daprClient;

    @GetMapping("/dapr/subscribe")
    public Flux<Subscription> subscribe() {
        Subscription[] subscriptions = new Subscription[]{
                new Subscription("pubsub", "BEIWEI_TEST_TOPIC_A", "A"),
                new Subscription("pubsub", "BEIWEI_TEST_TOPIC_B", "B"),
        };
        return Flux.fromArray(subscriptions);
    }

    @PostMapping("/A")
    public ResponseEntity<HttpStatus> topicA(@RequestBody byte[] payload) {
        ...
    }

    @PostMapping("/B")
    public ResponseEntity<HttpStatus> topicB(@RequestBody CloudEvent payload) { // this doesn't work
        ... 
    }
   ...
}

Spring complains no default constructor is present for CloudEvent.

Actual Behavior

    @PostMapping("/B")
    public ResponseEntity<HttpStatus> topicB(@RequestBody CloudEvent payload) {

    }

I believe this applies to all classes under io.dapr.client.domain.

Steps to Reproduce the Problem

Release Note

RELEASE NOTE: REFACTORED CloudEvent serialization, also adding default constructor.

Activity

  1. mukundansundar commented on Nov 12, 2020

    @mukundansundar
    Contributor

    Hi @beiwei30 thanks for raising this issue. Will you be able to work on this?

  2. arghya88 commented on Dec 16, 2020

    @arghya88
    Contributor

    @mukundansundar I see all the fields are final and hence just adding a default constructor is not going to work. What do you suggest we should do?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions