-
Notifications
You must be signed in to change notification settings - Fork 641
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Search before asking
- I had searched in the issues and found no similar issues.
Environment
Linux
EventMesh version
master
What happened
HTTP source connector stop after receiving an request without attribute subject and never response again.
How to reproduce
Reproduce
- start http connector server
- send an invalid request without
subject, such as
curl --location --request POST 'http://localhost:3755/test' \
--header 'ce-id: 11' \
--header 'ce-specversion: 1.0' \
--header 'ce-type: com.example.someevent' \
--header 'ce-source: /mycontext' \
# --header 'ce-subject: test' \
--header 'Content-Type: text/plain' \
--data-raw 'aaa'- http connector server stop forever
Analysis
In HttpSourceConnector#poll, the conversion from cloudevent to connectRecord is performed.

If a cloudevent contains null subject, connectRecord.addExtension("topic", event.getSubject()) will throw unexpected NPE, which will stop the connector server.

Fix
Check subject before saving cloudevents. We don't need to check other attributes like id, source, type,etc. Because they are required arrtibutes of cloudevents and cloudevents-sdk will do the check in toEvent().
VertxMessageFactory.createReader(ctx.request())
.map(r -> {
CloudEvent event = r.toEvent();
if (event.getSubject() == null) {
throw new IllegalStateException("attribute 'subject' cannot be null");
}
return event;
})
setting others...Debug logs
No response
Are you willing to submit PR?
- Yes I am willing to submit a PR!
Code of Conduct
- I agree to follow this project's Code of Conduct *
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working