Add an overload of Timer#time that takes Runnable #989
Conversation
This allows you to invoke method handles or lambdas that don't return a value easily.
15dde82
into
dropwizard:3.2-development
Thanks for your contribution, Steven. |
I may be missing something (and I'm definitely late) but this seems like a potentially bad design change. Now #time accepts 2 possible SAM argument types which will complicate implicit coercion of lambdas or similar first class functions. |
FYI, this breaks groovy users of this api. Code like this appears to always call the
A workaround is to modify the call to look like this:
|
@mwhipple I don't think that had been considered. We could revert this change as it's likely no one is using it yet. Either way we'll be sure to avoid this problem in v4. |
@ryantenney cool, thanks for the quick response! |
Could I just ask that you open a new issue for this?
…On Mon, Mar 6, 2017 at 10:03 AM Matt Whipple ***@***.***> wrote:
@ryantenney <https://github.com/ryantenney> cool, thanks for the quick
response!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#989 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAHkbwQNQVTg5BCElN2dxn4_WNJ4IXD-ks5rjCBCgaJpZM4JSLXP>
.
|
I had an impression that the compiler is smart enough to figure out which SAM should applied depending on the argument. For instance, this snippet compiles for me: Timer timer = new MetricRegistry().timer("test");
timer.time(() -> System.out.println());
timer.time(() -> System.currentTimeMillis()); |
Ok, thanks for the additional info...it looks like this may just be a Groovy issue.
Sorry for the half-baked concern |
If it is really that bad, you could just give the method a different name so it is not an overload. |
This allows you to invoke method handles or lambdas that
don't return a value easily.