You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by us...@apache.org on 2022/10/02 14:42:42 UTC

[lucene] branch main updated: Upgrade forbiddenapis to 3.4 (#11834)

This is an automated email from the ASF dual-hosted git repository.

uschindler pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/lucene.git


The following commit(s) were added to refs/heads/main by this push:
     new aae293437f5 Upgrade forbiddenapis to 3.4 (#11834)
aae293437f5 is described below

commit aae293437f52b49bf692f6ea56e6b0fda9641386
Author: Uwe Schindler <us...@apache.org>
AuthorDate: Sun Oct 2 16:42:36 2022 +0200

    Upgrade forbiddenapis to 3.4 (#11834)
---
 build.gradle                                               |  2 +-
 gradle/validation/forbidden-apis.gradle                    | 14 ++++++++------
 lucene/CHANGES.txt                                         |  4 +++-
 .../org/apache/lucene/store/MemorySegmentIndexInput.java   |  3 ++-
 4 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/build.gradle b/build.gradle
index 03f4a372ffc..59027748a97 100644
--- a/build.gradle
+++ b/build.gradle
@@ -22,7 +22,7 @@ plugins {
   id "base"
   id "com.palantir.consistent-versions" version "2.11.0"
   id "org.owasp.dependencycheck" version "7.2.0"
-  id 'de.thetaphi.forbiddenapis' version '3.3' apply false
+  id 'de.thetaphi.forbiddenapis' version '3.4' apply false
   id "de.undercouch.download" version "5.2.0" apply false
   id "net.ltgt.errorprone" version "2.0.2" apply false
   id 'com.diffplug.spotless' version "6.5.2" apply false
diff --git a/gradle/validation/forbidden-apis.gradle b/gradle/validation/forbidden-apis.gradle
index 8fbe82a6efd..6de4c7d8aec 100644
--- a/gradle/validation/forbidden-apis.gradle
+++ b/gradle/validation/forbidden-apis.gradle
@@ -57,7 +57,7 @@ allprojects { prj ->
     }
 
     // Configure defaults for sourceSets.main
-    forbiddenApisMain {
+    tasks.matching { it.name in ["forbiddenApisMain", "forbiddenApisMain19"] }.all {
       bundledSignatures += [
           'jdk-unsafe',
           'jdk-deprecated',
@@ -73,6 +73,13 @@ allprojects { prj ->
       doFirst dynamicSignatures.curry(configurations.compileClasspath, "lucene")
     }
 
+    // Configure defaults for the MR-JAR feature sourceSets by setting java version and ignore missing classes
+    // TODO: Get hold of warning messages, see https://github.com/policeman-tools/forbidden-apis/issues/207
+    tasks.matching { it.name == "forbiddenApisMain19" }.all {
+      failOnMissingClasses = false
+      targetCompatibility = 19
+    }
+
     // Configure defaults for sourceSets.test
     tasks.matching { it.name in ["forbiddenApisTest", "forbiddenApisTestFixtures"] }.all {
       bundledSignatures += [
@@ -115,11 +122,6 @@ allprojects { prj ->
       inputs.dir(file(resources))
     }
 
-    // TODO: Remove this when forbiddenapis supports Java 19 class files
-    tasks.matching { it.name == "forbiddenApisMain19" }.all {
-      enabled = false
-    }
-
     // We rely on resolved configurations to compute the relevant set of rule
     // files for forbiddenApis. Since we don't want to resolve these configurations until
     // the task is executed, we can't really use them as task inputs properly. This is a
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index cd535e09edb..e9032231b9e 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -140,7 +140,9 @@ Other
 ---------------------
 * LUCENE-10423: Remove usages of System.currentTimeMillis() from tests. (Marios Trivyzas)
 
-* GITHUB#11811: upgrade google java format to 1.15.0 (Dawid Weiss)
+* GITHUB#11811: Upgrade google java format to 1.15.0 (Dawid Weiss)
+
+* GITHUB#11834: Upgrade forbiddenapis to version 3.4.  (Uwe Schindler)
 
 ======================== Lucene 9.4.0 =======================
 
diff --git a/lucene/core/src/java19/org/apache/lucene/store/MemorySegmentIndexInput.java b/lucene/core/src/java19/org/apache/lucene/store/MemorySegmentIndexInput.java
index 7754645c708..089a848d700 100644
--- a/lucene/core/src/java19/org/apache/lucene/store/MemorySegmentIndexInput.java
+++ b/lucene/core/src/java19/org/apache/lucene/store/MemorySegmentIndexInput.java
@@ -24,6 +24,7 @@ import java.lang.foreign.ValueLayout;
 import java.nio.ByteOrder;
 import java.util.Arrays;
 import java.util.Objects;
+import org.apache.lucene.util.ArrayUtil;
 
 /**
  * Base IndexInput implementation that uses an array of MemorySegments to represent a file.
@@ -408,7 +409,7 @@ abstract class MemorySegmentIndexInput extends IndexInput implements RandomAcces
 
     // we always allocate one more slice, the last one may be a 0 byte one after truncating with
     // asSlice():
-    final MemorySegment slices[] = Arrays.copyOfRange(segments, startIndex, endIndex + 1);
+    final MemorySegment slices[] = ArrayUtil.copyOfSubArray(segments, startIndex, endIndex + 1);
 
     // set the last segment's limit for the sliced view.
     slices[slices.length - 1] = slices[slices.length - 1].asSlice(0L, sliceEnd & chunkSizeMask);