lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From no...@apache.org
Subject [1/2] lucene-solr git commit: SOLR-8750 : Use lambdas in code where SAM type interfaces are used
Date Fri, 04 Mar 2016 13:27:41 GMT
Repository: lucene-solr
Updated Branches:
  refs/heads/branch_6_0 140707709 -> 6a4f912b5


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/6a4f912b/solr/solrj/src/test/org/apache/solr/common/params/SolrParamTest.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/test/org/apache/solr/common/params/SolrParamTest.java b/solr/solrj/src/test/org/apache/solr/common/params/SolrParamTest.java
index ed6465f..48237c5 100644
--- a/solr/solrj/src/test/org/apache/solr/common/params/SolrParamTest.java
+++ b/solr/solrj/src/test/org/apache/solr/common/params/SolrParamTest.java
@@ -201,12 +201,9 @@ public class SolrParamTest extends LuceneTestCase {
     }
     
     // Malformed params: These should throw a 400
-    assertEquals( 400, getReturnCode( new Runnable() { @Override
-    public void run() { params.getInt(   "f.bad.int" ); } } ) );
-    assertEquals( 400, getReturnCode( new Runnable() { @Override
-    public void run() { params.getBool(  "f.bad.bool" ); } } ) );
-    assertEquals( 400, getReturnCode( new Runnable() { @Override
-    public void run() { params.getFloat( "f.bad.float" ); } } ) );
+    assertEquals(400, getReturnCode(() -> params.getInt("f.bad.int")));
+    assertEquals(400, getReturnCode(() -> params.getBool("f.bad.bool")));
+    assertEquals(400, getReturnCode(() -> params.getFloat("f.bad.float")));
     
     // Ask for params that arent there
     assertNull( params.get( "asagdsaga" ) );
@@ -243,24 +240,15 @@ public class SolrParamTest extends LuceneTestCase {
     assertEquals( pfloat , required.getFieldFloat( "fakefield", "float" ) );
     
     // Required params which are missing: These should throw a 400
-    assertEquals( 400, getReturnCode( new Runnable() { @Override
-    public void run() { required.get( "aaaa" ); } } ) );
-    assertEquals( 400, getReturnCode( new Runnable() { @Override
-    public void run() { required.getInt(   "f.bad.int" ); } } ) );
-    assertEquals( 400, getReturnCode( new Runnable() { @Override
-    public void run() { required.getBool(  "f.bad.bool" ); } } ) );
-    assertEquals( 400, getReturnCode( new Runnable() { @Override
-    public void run() { required.getFloat( "f.bad.float" ); } } ) );
-    assertEquals( 400, getReturnCode( new Runnable() { @Override
-    public void run() { required.getInt(   "aaa" ); } } ) );
-    assertEquals( 400, getReturnCode( new Runnable() { @Override
-    public void run() { required.getBool(  "aaa" ); } } ) );
-    assertEquals( 400, getReturnCode( new Runnable() { @Override
-    public void run() { required.getFloat( "aaa" ); } } ) );
-    assertEquals( 400, getReturnCode( new Runnable() { @Override
-    public void run() { params.getFieldBool(  "bad", "bool" ); } } ) );
-    assertEquals( 400, getReturnCode( new Runnable() { @Override
-    public void run() { params.getFieldInt(   "bad", "int"  ); } } ) );
+    assertEquals(400, getReturnCode(() -> required.get("aaaa")));
+    assertEquals(400, getReturnCode(() -> required.getInt("f.bad.int")));
+    assertEquals(400, getReturnCode(() -> required.getBool("f.bad.bool")));
+    assertEquals(400, getReturnCode(() -> required.getFloat("f.bad.float")));
+    assertEquals(400, getReturnCode(() -> required.getInt("aaa")));
+    assertEquals(400, getReturnCode(() -> required.getBool("aaa")));
+    assertEquals(400, getReturnCode(() -> required.getFloat("aaa")));
+    assertEquals(400, getReturnCode(() -> params.getFieldBool("bad", "bool")));
+    assertEquals(400, getReturnCode(() -> params.getFieldInt("bad", "int")));
 
     // Fields with default use their parent value:
     assertEquals(

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/6a4f912b/solr/solrj/src/test/org/apache/solr/common/util/TestJavaBinCodec.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/test/org/apache/solr/common/util/TestJavaBinCodec.java b/solr/solrj/src/test/org/apache/solr/common/util/TestJavaBinCodec.java
index b59eee9..03ec1b5 100644
--- a/solr/solrj/src/test/org/apache/solr/common/util/TestJavaBinCodec.java
+++ b/solr/solrj/src/test/org/apache/solr/common/util/TestJavaBinCodec.java
@@ -443,17 +443,14 @@ public class TestJavaBinCodec extends SolrTestCaseJ4 {
     final int ITERS = 1000000;
     int THREADS = 10;
 
-    runInThreads(THREADS, new Runnable() {
-      @Override
-      public void run() {
-        JavaBinCodec.StringBytes stringBytes1 = new JavaBinCodec.StringBytes(new byte[0],
0, 0);
-        for (int i = 0; i < ITERS; i++) {
-          JavaBinCodec.StringBytes b = l.get(i % l.size());
-          stringBytes1.reset(b.bytes, 0, b.bytes.length);
-          if (STRING_CACHE.get(stringBytes1) == null) throw new RuntimeException("error");
-        }
-
+    runInThreads(THREADS, () -> {
+      JavaBinCodec.StringBytes stringBytes1 = new JavaBinCodec.StringBytes(new byte[0], 0,
0);
+      for (int i = 0; i < ITERS; i++) {
+        JavaBinCodec.StringBytes b = l.get(i % l.size());
+        stringBytes1.reset(b.bytes, 0, b.bytes.length);
+        if (STRING_CACHE.get(stringBytes1) == null) throw new RuntimeException("error");
       }
+
     });
 
 
@@ -462,17 +459,14 @@ public class TestJavaBinCodec extends SolrTestCaseJ4 {
     System.out.println("time taken by LRUCACHE " + timer.getTime());
     timer = new RTimer();
 
-    runInThreads(THREADS, new Runnable() {
-      @Override
-      public void run() {
-        String a = null;
-        CharArr arr = new CharArr();
-        for (int i = 0; i < ITERS; i++) {
-          JavaBinCodec.StringBytes sb = l.get(i % l.size());
-          arr.reset();
-          ByteUtils.UTF8toUTF16(sb.bytes, 0, sb.bytes.length, arr);
-          a = arr.toString();
-        }
+    runInThreads(THREADS, () -> {
+      String a = null;
+      CharArr arr = new CharArr();
+      for (int i = 0; i < ITERS; i++) {
+        JavaBinCodec.StringBytes sb = l.get(i % l.size());
+        arr.reset();
+        ByteUtils.UTF8toUTF16(sb.bytes, 0, sb.bytes.length, arr);
+        a = arr.toString();
       }
     });
 
@@ -575,14 +569,11 @@ public class TestJavaBinCodec extends SolrTestCaseJ4 {
     if (nThreads <= 0) {
       ret += doDecode(buffers, iter, stringCache);
     } else {
-      runInThreads(nThreads, new Runnable() {
-        @Override
-        public void run() {
-          try {
-            doDecode(buffers, iter, stringCache);
-          } catch (IOException e) {
-            e.printStackTrace();
-          }
+      runInThreads(nThreads, () -> {
+        try {
+          doDecode(buffers, iter, stringCache);
+        } catch (IOException e) {
+          e.printStackTrace();
         }
       });
     }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/6a4f912b/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java
----------------------------------------------------------------------
diff --git a/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java b/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java
index c80998a..c3ce47d 100644
--- a/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java
+++ b/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java
@@ -1612,12 +1612,7 @@ public abstract class SolrTestCaseJ4 extends LuceneTestCase {
     final int mul = asc ? 1 : -1;
 
     if (field.equals("_docid_")) {
-     return new Comparator<Doc>() {
-      @Override
-      public int compare(Doc o1, Doc o2) {
-        return (o1.order - o2.order) * mul;
-      }
-     };
+     return (o1, o2) -> (o1.order - o2.order) * mul;
     }
 
     if (field.equals("score")) {
@@ -1669,16 +1664,13 @@ public abstract class SolrTestCaseJ4 extends LuceneTestCase {
   }
 
   public static Comparator<Doc> createComparator(final List<Comparator<Doc>>
comparators) {
-    return new Comparator<Doc>() {
-      @Override
-      public int compare(Doc o1, Doc o2) {
-        int c = 0;
-        for (Comparator<Doc> comparator : comparators) {
-          c = comparator.compare(o1, o2);
-          if (c!=0) return c;
-        }
-        return o1.order - o2.order;
+    return (o1, o2) -> {
+      int c = 0;
+      for (Comparator<Doc> comparator : comparators) {
+        c = comparator.compare(o1, o2);
+        if (c!=0) return c;
       }
+      return o1.order - o2.order;
     };
   }
 


Mime
View raw message