Description
I have a component that has its own middleware:
(defrecord SenteHandler [respond-to middleware]
component/Lifecycle
(start [component]
(assoc component :handler
(if middleware
((apply comp (reverse middleware)) respond-to)
respond-to)))
(stop [component]
(dissoc component :handler)))
I am also using the system.component.handler/Handler
component. My SenteHandler
is a transient dependency of the system.components.handler/Handler
:
{...
:sente [:sente-handler]
:private-endpoints [:sente]
:handler [:public-endpoints
:private-endpoints
:middleware]}
When :middleware
in SenteHandler
is nil
, Handler
is throwing a NullPointerException
on L37. If I change :middleware
key in SenteHandler
to anything else, such as :mw
, Handler
does not throw an exception. Handler
seems to be searching for middleware in transient dependencies by checking for the :middleware
key.
While this is fairly easy to work around, would it make things more robust to check the type of the component instead or checking for keywords that are not namespaced? Something like (instance? Middleware component)
? I've thrown together a simple PR and it seems to work.