Handler convenience debug methods #22
Labels
No Label
1
13
2
21
3
34
5
55
8
bug
core
could have
duplicate
enhancement
help wanted
must have
proc
question
should have
wont have
L
M
S
XL
bug
bugfix
discussion
documentation
feature
maintenance
postponed
refactoring
wontfix
No Milestone
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: zdm/event-bus#22
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Add a method that simply lists all handlers in the order in which they would be executed when you have a specific input event, without actually invoking them, i.e. using
At best, a second method should be added as well that simply counts how many handlers would be called.
That would help with debugging as seeing what is going on inside event-bus is tedious even with a debugger.
Are you interested in a list of strings, or rather the actual event handler objects? Right now, the
EventHandler
class is internal and not exposed outside the module.By changing that, we could allow a more direct interaction with the handler configuration, including an ordered list of the handlers to be called for an event (essentially making
EventBus#getHandlersFor
public.List of strings, especially if the handlers implement
toString
correctly.Or do you currently store
java.lang.reflect.Method
s inside the handler? Because if that is the case, there surely is a nice way to get the name of the method that is registered as event handler to print out for debugging purposes.As this is intended to be a function to help with debugging, I only want to see which methods and/ or objects are registered for a specific event and when in the event dispatching lifecycle they are called.
Making this method public does not seem to be a bad idea to me. That would cover at least the second use case I mentioned directly (number of event handlers for a specific event).
Furthermore, I think the convenience method returning a list of strings can be declared as well as it encourages the default query for debugging purposes instead of having to tediously declare it yourself when debugging.
Adding new functions yourself whenever you need to debug something is in my opinion inefficient as those functions will always be deleted afterwards.
Currently, the
toString
method ofEventHandler
has the formEventHandler[method=%s, eventType=%s, useParameter=%b, polymorphic=%b, priority=%d]
, which contains all information that makes up the handler in human-readable form.As the standard output is not always accessible depending on the code base in question, I would rather prefer to return a string instead, made up of such handler descriptions in the correct order, separated by line breaks. At the top, a line in the form of "Handler execution order for event type X (n handler(s)):" could be included.