Hi Mark,

I am wondering why you be so verbose in Java 8's code. The main reason for 
ThreadLocal.withInitial() is to use it like that:

        private static final ThreadLocal<Integer> CALL_DEPTH = 
ThreadLocal.withInitial(() -> 0);

Using a Supplier without a lambda is not the intention behind this method /API 
:-)
In Java 7, you can use the code like this fix comitted. If you want it verbose 
in Java 8, I would also use the Java 7 code...

Uwe

-----
Uwe Schindler
H.-H.-Meier-Allee 63, D-28213 Bremen
http://www.thetaphi.de
eMail: [email protected]

> -----Original Message-----
> From: [email protected] [mailto:[email protected]]
> Sent: Wednesday, May 27, 2015 5:28 PM
> To: [email protected]
> Subject: svn commit: r1682057 -
> /lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/loggin
> g/MDCLoggingContext.java
> 
> Author: markrmiller
> Date: Wed May 27 15:27:43 2015
> New Revision: 1682057
> 
> URL: http://svn.apache.org/r1682057
> Log:
> SOLR-7590: Java8 code -> Java7 for branch_5x.
> 
> Modified:
> 
> lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/logging
> /MDCLoggingContext.java
> 
> Modified:
> lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/logging
> /MDCLoggingContext.java
> URL:
> http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/core/sr
> c/java/org/apache/solr/logging/MDCLoggingContext.java?rev=1682057&r1=
> 1682056&r2=1682057&view=diff
> ==========================================================
> ====================
> ---
> lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/logging
> /MDCLoggingContext.java (original)
> +++
> lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/log
> +++ ging/MDCLoggingContext.java Wed May 27 15:27:43 2015
> @@ -23,7 +23,6 @@ import static org.apache.solr.common.clo  import static
> org.apache.solr.common.cloud.ZkStateReader.REPLICA_PROP;
>  import static
> org.apache.solr.common.cloud.ZkStateReader.SHARD_ID_PROP;
> 
> -import java.util.function.Supplier;
> 
>  import org.apache.solr.cloud.CloudDescriptor;
>  import org.apache.solr.cloud.ZkController;
> @@ -39,12 +38,13 @@ import org.slf4j.MDC;
>   */
>  public class MDCLoggingContext {
>    // When a thread sets context and finds that the context is already set, we
> should noop and ignore the finally clear
> -  private static ThreadLocal<Integer> CALL_DEPTH =
> ThreadLocal.withInitial(new Supplier<Integer>() {
> +  private static ThreadLocal<Integer> CALL_DEPTH = new
> + ThreadLocal<Integer>() {
>      @Override
> -    public Integer get() {
> +    protected Integer initialValue() {
>        return 0;
>      }
> -  });
> +  };
> +
> 
>    private static void setCollection(String collection) {
>      if (collection != null) {



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to