You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@solr.apache.org by "iamsanjay (via GitHub)" <gi...@apache.org> on 2024/06/04 16:15:03 UTC

[PR] SOLR-17321: Bump minimum required Java version to 21 [solr]

iamsanjay opened a new pull request, #2497:
URL: https://github.com/apache/solr/pull/2497

   https://issues.apache.org/jira/browse/SOLR-17321
   
   <!--
   _(If you are a project committer then you may remove some/all of the following template.)_
   
   Before creating a pull request, please file an issue in the ASF Jira system for Solr:
   
   * https://issues.apache.org/jira/projects/SOLR
   
   For something minor (i.e. that wouldn't be worth putting in release notes), you can skip JIRA. 
   To create a Jira issue, you will need to create an account there first.
   
   The title of the PR should reference the Jira issue number in the form:
   
   * SOLR-####: <short description of problem or changes>
   
   SOLR must be fully capitalized. A short description helps people scanning pull requests for items they can work on.
   
   Properly referencing the issue in the title ensures that Jira is correctly updated with code review comments and commits. -->
   
   We are upgrading the minimum Java version for Solr main branch to 21. However, at the same, It has been suggested to be not so aggressive with SolrJ (and thus solr-api, a dependency) Java version – setting it to 17.
   
   
   # Checklist
   
   Please review the following and check all that apply:
   
   - [x] I have reviewed the guidelines for [How to Contribute](https://github.com/apache/solr/blob/main/CONTRIBUTING.md) and my code conforms to the standards described there to the best of my ability.
   - [x] I have created a Jira issue and added the issue ID to my pull request title.
   - [x] I have given Solr maintainers [access](https://help.github.com/en/articles/allowing-changes-to-a-pull-request-branch-created-from-a-fork) to contribute to my PR branch. (optional but recommended)
   - [x] I have developed this patch against the `main` branch.
   - [x] I have run `./gradlew check`.
   - [] I have added tests for my changes.
   - [ ] I have added documentation for the [Reference Guide](https://github.com/apache/solr/tree/main/solr/solr-ref-guide)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] SOLR-17321: Bump minimum required Java version to 21 [solr]

Posted by "dsmiley (via GitHub)" <gi...@apache.org>.
dsmiley commented on code in PR #2497:
URL: https://github.com/apache/solr/pull/2497#discussion_r1626476316


##########
solr/core/src/test/org/apache/solr/cli/PostToolTest.java:
##########
@@ -210,6 +211,7 @@ public void testAppendParam() {
   }
 
   @Test
+  @SuppressForbidden(reason = "java.net.URL ctors deprecated since Java 20")

Review Comment:
   can this be put at the class level once instead of most tests?



##########
solr/core/src/java/org/apache/solr/cli/PostTool.java:
##########
@@ -256,10 +257,12 @@ public void runImpl(CommandLine cli) throws Exception {
     solrUpdateUrl = null;
     if (cli.hasOption("url")) {
       String url = cli.getOptionValue("url");
-      solrUpdateUrl = new URL(url);
+      URI uri = new URI(url);

Review Comment:
   nitpick: inline



##########
solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java:
##########
@@ -844,7 +844,8 @@ public void doTestIndexFetchWithLeaderUrl() throws Exception {
             + "/"
             + DEFAULT_TEST_CORENAME
             + ReplicationHandler.PATH;
-    URL url = new URL(leaderUrl);
+    URI uri = new URI(leaderUrl);
+    URL url = uri.toURL();

Review Comment:
   inline to one-liner



##########
gradle/validation/dependency-analyze.gradle:
##########
@@ -23,14 +23,14 @@ allprojects { prj ->
     prj.apply plugin: 'ca.cutterslade.analyze'
 
     analyzeClassesDependencies {
-      warnUsedUndeclared = false // means fail build if UsedUndeclared found
-      warnUnusedDeclared = false // means fail build if UnusedDeclared found
+      warnUsedUndeclared = true // means fail build if UsedUndeclared found

Review Comment:
   you updated booleans but not the explanatory comment.  Why change this any way?



##########
solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java:
##########
@@ -86,7 +86,7 @@
  *
  * @since 1.4
  */
-@LuceneTestCase.Nightly
+// @LuceneTestCase.Nightly

Review Comment:
   Why?



##########
solr/core/src/test/org/apache/solr/response/transform/TestSubQueryTransformerDistrib.java:
##########
@@ -134,6 +135,7 @@ public static void setupCluster() throws Exception {
   }
 
   @SuppressWarnings("serial")
+  @SuppressForbidden(reason = "java.net.URL ctors deprecated since Java 20")

Review Comment:
   You fix some and suppress others.  Is there a pattern/approach to it?  (just curious; maybe not)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] SOLR-17321: Bump minimum required Java version to 21 [solr]

Posted by "dsmiley (via GitHub)" <gi...@apache.org>.
dsmiley commented on PR #2497:
URL: https://github.com/apache/solr/pull/2497#issuecomment-2150480373

   References to JavaVersion (a Gradle class) like `>= JavaVersion.VERSION_16` should be reviewed to see if we can make changes to remove conditions that will no longer vary.
   
   Searching for "Java 17" or "JDK 17" or similar searches or other versions can reveal stuff where maybe a change is needed.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] SOLR-17321: Bump minimum required Java version to 21 [solr]

Posted by "iamsanjay (via GitHub)" <gi...@apache.org>.
iamsanjay commented on PR #2497:
URL: https://github.com/apache/solr/pull/2497#issuecomment-2149754684

   > RE URL: If you have IntelliJ Ultimate edition (not sure if Community), you could do "Structural Replace" to find & replace systematically everywhere.
   Like always, Thanks for the air support. "Structural Replace" is a Game Changer!
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] SOLR-17321: Bump minimum required Java version to 21 [solr]

Posted by "iamsanjay (via GitHub)" <gi...@apache.org>.
iamsanjay commented on PR #2497:
URL: https://github.com/apache/solr/pull/2497#issuecomment-2147937183

   For now two things pending
   1. Set different Java level for SolrJ and Solr. Currently both are 21.
   2. And, another one is to change the test-via-crave.yml file to run the build with Java 21.
   
   Feel free to push changes to this branch.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] SOLR-17321: Bump minimum required Java version to 21 [solr]

Posted by "dsmiley (via GitHub)" <gi...@apache.org>.
dsmiley commented on code in PR #2497:
URL: https://github.com/apache/solr/pull/2497#discussion_r1627690614


##########
solr/solrj/src/java/org/apache/solr/client/solrj/util/ClientUtils.java:
##########
@@ -102,8 +104,9 @@ public static String buildRequestUrl(
     return basePath + path;
   }
 
+  @SuppressForbidden(reason = "java.net.URL ctors deprecated since Java 20")

Review Comment:
   No longer need this suppress.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] SOLR-17321: Bump minimum required Java version to 21 [solr]

Posted by "iamsanjay (via GitHub)" <gi...@apache.org>.
iamsanjay closed pull request #2497: SOLR-17321: Bump minimum required Java version to 21
URL: https://github.com/apache/solr/pull/2497


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] SOLR-17321: Bump minimum required Java version to 21 [solr]

Posted by "dsmiley (via GitHub)" <gi...@apache.org>.
dsmiley commented on PR #2497:
URL: https://github.com/apache/solr/pull/2497#issuecomment-2149871311

   I suggest flipping the order.  Prep the code for Java 21 compatibility
   first so that we don't go adding SupressForbidden to many classes to only
   then fix the issue later.  i.e. visit these classes once not twice.  You
   know exactly how to fix it and have even starting doing so; it's not a
   tricky matter.  Again, IntelliJ will do much of the work.
   
   On Wed, Jun 5, 2024 at 8:55 AM Sanjay Dutt ***@***.***> wrote:
   
   > Would it be too much to ask to separate all this URL conversion stuff to a
   > separate PR, ultimately being its own commit focused on exactly that?
   > Needn't be another JIRA; needn't touch CHANGES.txt in that commit. If I had
   > to do this, I'd start with the trick of taking a GitHub PR URL and adding
   > the ".patch" (or maybe it's ".diff" for a different format) and then
   > copy-paste into IntellIJ "Apply patch from Clipboard" and selectively
   > exclude stuff unrelated at that point (or after).
   >
   > So SuppressForbidden is okay for now, and later on (Just after this one!)
   > deal with removing it in a different PR?
   >
   > —
   > Reply to this email directly, view it on GitHub
   > <https://github.com/apache/solr/pull/2497#issuecomment-2149791390>, or
   > unsubscribe
   > <https://github.com/notifications/unsubscribe-auth/AAC4DTZJTS2ICJN2TM6AJZLZF4C77AVCNFSM6AAAAABIY26TRCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNBZG44TCMZZGA>
   > .
   > You are receiving this because your review was requested.Message ID:
   > ***@***.***>
   >
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] SOLR-17321: Bump minimum required Java version to 21 [solr]

Posted by "iamsanjay (via GitHub)" <gi...@apache.org>.
iamsanjay commented on PR #2497:
URL: https://github.com/apache/solr/pull/2497#issuecomment-2157143107

   Setting different Java version for main and SolrJ resulting in error.  Currently, `:solr:api:ecjLintTest ` task is failing and below is the error.
   
   ```
   > Task :solr:api:ecjLintTest
   ----------
   1. ERROR in /Users/sanjaydutt/Documents/Solr/solr-main/solr/solr/api/src/test/org/apache/solr/util/TestSolrVersion.java (at line 19)
           import org.apache.solr.SolrTestCase;
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   The import org.apache.solr.SolrTestCase cannot be resolved
   ----------
   2. ERROR in /Users/sanjaydutt/Documents/Solr/solr-main/solr/solr/api/src/test/org/apache/solr/util/TestSolrVersion.java (at line 23)
           public class TestSolrVersion extends SolrTestCase {
                                                ^^^^^^^^^^^^
   SolrTestCase cannot be resolved to a type
   
   ```
   
   The api test cases not able to access the class, `SolrTestClass`, from the main branch.  Further, I logged the java version that has been used to configure SolrJ via adding println statements.  
   
   `ecj-lint.gradle`
   
   ```
   allprojects {
     plugins.withType(JavaPlugin) {
       // Create a [sourceSetName]EcjLint task for each source set
       // with a non-empty java.srcDirs. These tasks are then
       // attached to project's "ecjLint" task.
   
       println "The project name is " + project + " and the sourceCompatibility is " + project.sourceCompatibility
   
       def lintTasks = sourceSets.collect { sourceSet ->
         def srcDirs = sourceSet.java.srcDirs.findAll { dir -> dir.exists() }
   
         tasks.create(sourceSet.getTaskName("ecjLint", null), JavaExec, {task ->
   ....
   ...
   ```
   
   **Output**
   
   ```
   > Configure project :solr:server
   The project name is project ':solr:server' and the sourceCompatibility is 21
   
   > Configure project :solr:core
   The project name is project ':solr:core' and the sourceCompatibility is 21
   
   > Configure project :solr:api
   The project name is project ':solr:api' and the sourceCompatibility is 17
   
   > Configure project :solr:solrj
   The project name is project ':solr:solrj' and the sourceCompatibility is 17
   ```
   
   The version has changed for SolrJ and for api as well. However, as @dsmiley pointed out before that test classes for both of these project should point to 21. Still looking for a way How we can achieve that.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] SOLR-17321: Bump minimum required Java version to 21 [solr]

Posted by "iamsanjay (via GitHub)" <gi...@apache.org>.
iamsanjay commented on PR #2497:
URL: https://github.com/apache/solr/pull/2497#issuecomment-2150340085

   Test case failing, on main branch as well!
   ```
   ./gradlew :solr:core:test --tests "org.apache.solr.search.function.TestDenseVectorFunctionQuery.floatFieldVectors_shouldReturnFloatSimilarity" -Ptests.jvms=96 "-Ptests.jvmargs=-XX:TieredStopAtLevel=1 -XX:+UseParallelGC -XX:ActiveProcessorCount=1 -XX:ReservedCodeCacheSize=120m" -Ptests.seed=8F0CED8E85B304BD -Ptests.timeoutSuite=600000! -Ptests.file.encoding=US-ASCII
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] SOLR-17321: Bump minimum required Java version to 21 [solr]

Posted by "epugh (via GitHub)" <gi...@apache.org>.
epugh commented on code in PR #2497:
URL: https://github.com/apache/solr/pull/2497#discussion_r1626768150


##########
solr/core/src/java/org/apache/solr/cli/PostTool.java:
##########
@@ -601,6 +604,7 @@ protected static String normalizeUrlEnding(String link) {
    * @param out output stream to write to
    * @return number of pages crawled on this level and below
    */
+  @SuppressForbidden(reason = "java.net.URL ctors deprecated since Java 20")

Review Comment:
   Do we need this suppress?



##########
solr/core/src/java/org/apache/solr/cli/PostTool.java:
##########
@@ -815,7 +820,7 @@ public void postFile(File file, OutputStream output, String type) throws Malform
           urlStr =
               appendParam(urlStr, "literal.id=" + URLEncoder.encode(file.getAbsolutePath(), UTF_8));
         }
-        url = new URL(urlStr);
+        url = URI.create(urlStr).toURL();

Review Comment:
   Curious if using a URI would be better than constantly converting back to string?   Maybe another pr...



##########
solr/core/src/java/org/apache/solr/cli/PostTool.java:
##########
@@ -624,13 +628,14 @@ protected int webCrawl(int level, OutputStream out) {
         if (result.httpStatus == 200) {
           url = (result.redirectUrl != null) ? result.redirectUrl : url;
           URL postUrl =
-              new URL(
-                  appendParam(
-                      solrUpdateUrl.toString(),
-                      "literal.id="
-                          + URLEncoder.encode(url.toString(), UTF_8)
-                          + "&literal.url="
-                          + URLEncoder.encode(url.toString(), UTF_8)));
+              new URI(

Review Comment:
   If you run tidy do some white space changes go away?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] SOLR-17321: Bump minimum required Java version to 21 [solr]

Posted by "iamsanjay (via GitHub)" <gi...@apache.org>.
iamsanjay commented on PR #2497:
URL: https://github.com/apache/solr/pull/2497#issuecomment-2149791390

   > Would it be too much to ask to separate all this URL conversion stuff to a separate PR, ultimately being its own commit focused on exactly that? Needn't be another JIRA; needn't touch CHANGES.txt in that commit. If I had to do this, I'd start with the trick of taking a GitHub PR URL and adding the ".patch" (or maybe it's ".diff" for a different format) and then copy-paste into IntellIJ "Apply patch from Clipboard" and selectively exclude stuff unrelated at that point (or after).
   
   So SuppressForbidden is okay for now, and later on (Just after this one!) deal with removing it in a different PR?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] SOLR-17321: Bump minimum required Java version to 21 [solr]

Posted by "dsmiley (via GitHub)" <gi...@apache.org>.
dsmiley commented on PR #2497:
URL: https://github.com/apache/solr/pull/2497#issuecomment-2148251203

    > @SuppressForbidden(reason = "<custom message>") //Still need to decide what the message should be for all. Thinking of adding "Deprecated in Java <version>"
   
   Ideally those are addressed for real, otherwise they will continue to linger.  Could be a separate JIRA/PR.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] SOLR-17321: Bump minimum required Java version to 21 [solr]

Posted by "janhoy (via GitHub)" <gi...@apache.org>.
janhoy commented on code in PR #2497:
URL: https://github.com/apache/solr/pull/2497#discussion_r1626628157


##########
build.gradle:
##########
@@ -31,8 +31,8 @@ plugins {
 }
 
 // Declare default Java versions for the entire project and for SolrJ separately
-rootProject.ext.minJavaVersionDefault = JavaVersion.VERSION_11
-rootProject.ext.minJavaVersionSolrJ = JavaVersion.VERSION_11
+rootProject.ext.minJavaVersionDefault = JavaVersion.VERSION_21
+rootProject.ext.minJavaVersionSolrJ = JavaVersion.VERSION_21

Review Comment:
   Use Java 17 for SolrJ



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] SOLR-17321: Bump minimum required Java version to 21 [solr]

Posted by "epugh (via GitHub)" <gi...@apache.org>.
epugh commented on PR #2497:
URL: https://github.com/apache/solr/pull/2497#issuecomment-2149773970

   > > RE URL: If you have IntelliJ Ultimate edition (not sure if Community), you could do "Structural Replace" to find & replace systematically everywhere.
   > 
   > Like always, Thanks for the air support. "Structural Replace" is a Game Changer!
   
   I need to learn that!   Looks amazing!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org