Skip to content
This repository has been archived by the owner on Apr 22, 2022. It is now read-only.

Handle exceptions during event mapping. #113

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

cbsmith
Copy link

@cbsmith cbsmith commented Dec 4, 2015

Avoid letting exceptions during event mapping cause multiple events to
be lost. Also provide better logging.

Avoid letting exceptions during event mapping cause multiple events to
be lost. Also provide better logging.
@cbsmith
Copy link
Author

cbsmith commented Dec 4, 2015

As requested, a pull against master.

doProcess(avroBuffer);
listener.incomingRequest(event, avroBuffer, avroRecord);
doProcess(avroBuffer);
} catch (final RuntimeException e) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The listener call and the doProcess should go outside of the try-catch block, if we're guarding against mapping errors here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you look at the stack trace from #110, you will see it actually propagated up from fromRecord. I guess it wasn't strictly an error in the mapping logic, but rather the generic schema being employed. Either way, I think it is safer to include it.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But to clarify, listener.incomingRequest & doProcess are both inside the try/catch block.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I would consider the fromRecord to be part of the mapping (going from event to Avro) and doProcess(...) is part of handling the (then valid) avro record for enqueueing. Any error at that point would really be a bug and not a mapping error.

The listener is really just there for testing purposes (there's certain classes in the HTTP implementation that we cannot mock, so we use this path instead). Running Divolte normally shouldn't use it. If there is an exception in the listener, it's clearly a programming error.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh geez. I misread your feedback... I read "inside" where you said "outside". Okay. I'll update the pull.

Neither are parting of the user configurable logic and should really
execute without error.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants