[
https://issues.apache.org/jira/browse/LOG4J2-599?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14663083#comment-14663083
]
Ralph Goers edited comment on LOG4J2-599 at 8/8/15 5:43 PM:
------------------------------------------------------------
I guess I have to disagree. While this does allow you to use the lambda syntax
it still requires the user to use the specific interface we require to provide
the method to be called. So we would forever be tied to requiring a Callable.
The Javadoc for Callable says "The Callable interface is similar to Runnable,
in that both are designed for classes whose instances are potentially executed
by another thread.". I realize it says "potentially", but are we ever planning
on passing the Callable to another thread before calling the method? If not,
Supplier seems to be the correct interface to use. Unless, of course, we use
our own Interface for this purpose.
I should add that with using a Callable I would expect that AsyncLogger would
call the method from a different thread. If that is the case then Callable is
the correct interface to use.
was (Author: [email protected]):
I guess I have to disagree. While this does allow you to use the lambda syntax
it still requires the user to use the specific interface we require to provide
the method to be called. So we would forever be tied to requiring a Callable.
The Javadoc for Callable says "The Callable interface is similar to Runnable,
in that both are designed for classes whose instances are potentially executed
by another thread.". I realize it says "potentially", but are we ever planning
on passing the Callable to another thread before calling the method? If not,
Supplier seems to be the correct interface to use. Unless, of course, we use
our own Interface for this purpose.
> Support lambda functions (or similar) for log message parameters
> ----------------------------------------------------------------
>
> Key: LOG4J2-599
> URL: https://issues.apache.org/jira/browse/LOG4J2-599
> Project: Log4j 2
> Issue Type: Brainstorming
> Components: Core
> Reporter: Matt Sicker
> Priority: Minor
> Labels: Java8
>
> It would be nice if we could support 0-param lambda functions (or the
> equivalent: interfaces with a single empty-parameter message call), or more
> simply, allow Runnables (or something similar) to be passed which will be
> dynamically executed if the log message is enabled.
> The use case here is that although string construction of the log message is
> a performance issue that is already solved quite well, the problem of adding
> in information to the log message that makes other calculations still needs
> to be wrapped in an if check.
> I'm not sure if it'd be best to just use Runnable, or create a new interface,
> or try to emulate how Java 1.8 lambdas work via an interface with a single
> method defined. The details here would still need to be fleshed out, but I
> think this sort of feature could be rather handy (especially in a Java 1.8+
> environment, or in Groovy/Scala/etc.).
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]