lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From er...@apache.org
Subject [lucene-solr] branch branch_8x updated: SOLR-13568: Precommit fail Java var until 9x. Fail var...
Date Sun, 11 Aug 2019 15:52:41 GMT
This is an automated email from the ASF dual-hosted git repository.

erick pushed a commit to branch branch_8x
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git


The following commit(s) were added to refs/heads/branch_8x by this push:
     new 5df5df9  SOLR-13568: Precommit fail Java var until 9x. Fail var...
5df5df9 is described below

commit 5df5df9ec37c9fbaca9c0629482a95fb90c8d33b
Author: Erick Erickson <Erick.Erickson@gmail.com>
AuthorDate: Sun Aug 11 11:49:54 2019 -0400

    SOLR-13568: Precommit fail Java var until 9x. Fail var...
    
    (cherry picked from commit f6f1b4244c40e5665b20a2a8ef9852c6dd827cb2)
---
 lucene/tools/src/groovy/check-source-patterns.groovy         | 12 ++++++++++++
 solr/CHANGES.txt                                             |  2 ++
 .../test/org/apache/solr/client/solrj/SolrExampleTests.java  |  5 ++---
 3 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/lucene/tools/src/groovy/check-source-patterns.groovy b/lucene/tools/src/groovy/check-source-patterns.groovy
index 7794963..62565e6 100644
--- a/lucene/tools/src/groovy/check-source-patterns.groovy
+++ b/lucene/tools/src/groovy/check-source-patterns.groovy
@@ -49,6 +49,13 @@ def invalidPatterns = [
   (~$/import java\.lang\.\w+;/$) : 'java.lang import is unnecessary'
 ]
 
+// Python and others merrily use var declarations, this is a problem _only_ in Java at least
for 8x where we're forbidding var declarations
+def invalidJavaOnlyPatterns = [
+  (~$/\n\s*var\s+.*=.*<>.*/$) : 'Diamond operators should not be used with var',
+  (~$/\n\s*var\s+/$) : 'var is not allowed in until we stop development on the 8x code line'
+]
+
+
 def baseDir = properties['basedir'];
 def baseDirLen = baseDir.length() + 1;
 
@@ -200,6 +207,11 @@ ant.fileScanner{
         reportViolation(f, "Solr test cases should extend SolrTestCase rather than LuceneTestCase");
       }
     }
+    invalidJavaOnlyPatterns.each { pattern,name ->
+      if (pattern.matcher(text).find()) {
+        reportViolation(f, name);
+      }
+    }
   }
   if (f.name.endsWith('.xml') || f.name.endsWith('.xml.template')) {
     checkLicenseHeaderPrecedes(f, '<tag>', xmlTagPattern, xmlCommentPattern, text,
ratDocument);
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 491fdc0..972255c 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -114,6 +114,8 @@ Other Changes
 
 * SOLR-13573: Add SolrRangeQuery getters for upper, lower bound (Brian Rhees via Jason Gerlowski)
 
+* SOLR-13658: Precommit fail Java "var" until 9x. Fail "var...<>" constructs entirely
(Erick Erickson)
+
 ==================  8.2.0 ==================
 
 Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release.
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.java b/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.java
index 5391b89..ad70787 100644
--- a/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.java
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/SolrExampleTests.java
@@ -70,7 +70,6 @@ import org.apache.solr.common.params.AnalysisParams;
 import org.apache.solr.common.params.CommonParams;
 import org.apache.solr.common.params.FacetParams;
 import org.apache.solr.common.params.ModifiableSolrParams;
-import org.apache.solr.common.util.ContentStream;
 import org.apache.solr.common.util.ContentStreamBase;
 import org.apache.solr.common.util.NamedList;
 import org.apache.solr.common.util.Pair;
@@ -697,8 +696,8 @@ abstract public class SolrExampleTests extends SolrExampleTestsBase
     boolean assertClosed = random().nextBoolean();
     if (assertClosed) {
       byte[] allBytes = Files.readAllBytes(file.toPath());
-      
-      ContentStream contentStreamMock = new ContentStreamBase.ByteArrayStream(allBytes, "solrj/books.csv",
"application/csv") {
+
+      ContentStreamBase.ByteArrayStream contentStreamMock = new ContentStreamBase.ByteArrayStream(allBytes,
"solrj/books.csv", "application/csv") {
         @Override
         public InputStream getStream() throws IOException {
           opened [0]++;


Mime
View raw message