Evert Bevernage created NIFI-7727:
-------------------------------------

             Summary: method to determine major java version causes bootstrap 
failure
                 Key: NIFI-7727
                 URL: https://issues.apache.org/jira/browse/NIFI-7727
             Project: Apache NiFi
          Issue Type: Bug
    Affects Versions: 1.11.4
         Environment: windows, java 11
            Reporter: Evert Bevernage


Using java 11 (openjdk 11 + 28) run-nifi.bat fails with the following message:
{code:java}
C:\Programs\nifi-1.11.4\bin>run-nifi.bat
Exception in thread "main" java.lang.StringIndexOutOfBoundsException:
nd -1, length 2
        at java.base/java.lang.String.checkBoundsBeginEnd(String.java
        at java.base/java.lang.String.substring(String.java:1874)
        at org.apache.nifi.bootstrap.RunNiFi.start(RunNiFi.java:1040)
        at org.apache.nifi.bootstrap.RunNiFi.main(RunNiFi.java:240)
{code}
 

 

I believe the issue is caused as follows: nifi bootstrap tries to identify the 
major java version using a substring statement:

 
{code:java}
if (Integer.parseInt(runtimeJavaVersion.substring(0, 
runtimeJavaVersion.indexOf('.'))) >= 11) ...
{code}
[github 
link|https://github.com/apache/nifi/blob/68d5d025dc3d2c3e137155c9cdb90c7449a61970/nifi-bootstrap/src/main/java/org/apache/nifi/bootstrap/RunNiFi.java#L1040]

However the version reported by openjdk 11+28 is “11”, this string doesn’t 
contain a period. Causing the failure. Using openjdk 11.0.2 resolves the issue.

 

Nifi bootstrap log:

 

With openjdk 11 +28

 
{code:java}
2020-08-11 11:47:06,846 DEBUG [main] o.a.n.b.NotificationServiceManager Found 0 
service elements
2020-08-11 11:47:06,846 INFO [main] o.a.n.b.NotificationServiceManager 
Successfully loaded the following 0 services: []
2020-08-11 11:47:06,846 INFO [main] org.apache.nifi.bootstrap.RunNiFi 
Registered no Notification Services for Notification Type NIFI_STARTED
2020-08-11 11:47:06,846 INFO [main] org.apache.nifi.bootstrap.RunNiFi 
Registered no Notification Services for Notification Type NIFI_STOPPED
2020-08-11 11:47:06,846 INFO [main] org.apache.nifi.bootstrap.RunNiFi 
Registered no Notification Services for Notification Type NIFI_DIED
2020-08-11 11:47:06,862 INFO [main] org.apache.nifi.bootstrap.RunNiFi Runtime 
Java version: 11
{code}
 

 

With openjdk 11.0.2

 
{code:java}
2020-08-11 12:09:20,942 DEBUG [main] o.a.n.b.NotificationServiceManager Found 0 
service elements
2020-08-11 12:09:20,959 INFO [main] o.a.n.b.NotificationServiceManager 
Successfully loaded the following 0 services: []
2020-08-11 12:09:20,959 INFO [main] org.apache.nifi.bootstrap.RunNiFi 
Registered no Notification Services for Notification Type NIFI_STARTED
2020-08-11 12:09:20,959 INFO [main] org.apache.nifi.bootstrap.RunNiFi 
Registered no Notification Services for Notification Type NIFI_STOPPED
2020-08-11 12:09:20,959 INFO [main] org.apache.nifi.bootstrap.RunNiFi 
Registered no Notification Services for Notification Type NIFI_DIED
2020-08-11 12:09:20,962 DEBUG [main] org.apache.nifi.bootstrap.Command Status 
File: C:\Programs\NIFI-1~1.4\bin\..\run\nifi.status
2020-08-11 12:09:20,963 DEBUG [main] org.apache.nifi.bootstrap.Command No 
status file to load properties from
2020-08-11 12:09:20,964 DEBUG [main] org.apache.nifi.bootstrap.Command No Port 
found in status file
2020-08-11 12:09:20,965 DEBUG [main] org.apache.nifi.bootstrap.Command Status 
File: C:\Programs\NIFI-1~1.4\bin\..\run\nifi.lock
2020-08-11 12:09:20,969 INFO [main] org.apache.nifi.bootstrap.RunNiFi Runtime 
Java version: 11.0.2
2020-08-11 12:09:20,983 INFO [main] org.apache.nifi.bootstrap.Command Starting 
Apache NiFi...
{code}
 

 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to