java version parse error for gradle plugin 2.6.2 with Java JDK 10.0.1

380 views
Skip to first unread message

mic...@mraz.org

unread,
May 14, 2018, 3:45:31 PM5/14/18
to SonarQube
I would like to report a runtime exception I'm getting from java-frontend/src/main/java/org/sonar/java/model/JavaVersionImpl.java which I cannot figure out why it is occurring.
Any help resolving this would be appreciated.  I need to be able to support JDK10 for the environments I use.  Right now

SonarQube server Version 7.1 (build 11001)

Executing 'gradle sonarqube' results in:
> Task :sonarqube
Invalid java version (got "10"). The version will be ignored. Accepted formats are "1.X", or simply "X" (for instance: "1.5" or "5", "1.6" or "6", "1.7" or "7", etc.)


The application environment is gradle for a scala project.

Gradle 4.7
Build time:   2018-04-18 09:09:12 UTC
Revision:     b9a962bf70638332300e7f810689cb2febbd4a6c
Groovy:       2.4.12
Ant:          Apache Ant(TM) version 1.9.9 compiled on February 2 2017
JVM
:          10.0.1 ("Oracle Corporation" 10.0.1+10)
OS
:           Mac OS X 10.13.4 x86_64


The relevant build.gradle entries:

plugins {
    id
"org.sonarqube" version "2.6.2"
}

apply plugin
: 'java'
apply plugin
: 'scala'

sonarqube
{
    properties
{
        property
"sonar.projectName", "Scala :: $project.name"
        property
"sonar.projectKey", "$project.name"
        property
"sonar.languages", "scala"
        property
"sonar.sources", "src/main/scala,src/integration/scala"
        property
"sonar.java.source", 10
        property
"sonar.java.target", 10
        property
"sonar.java.binaries", "build/classes/scala/main,build/classes/scala/integration"
        property
"sonar.scoverage.reportPath", "build/reports/scoverage/scoverage.xml"
        property
"sonar.host.url", "http://127.0.0.1:9000"
   
}
}

It produces the same error if the source and target versions are not specified explicitly if I place quotes around the number "10" or if I use the string "1.10".  I can make it not raise an exception if I set "sonar.java.source" and "sonar.java.target" to "1.9"

I wrote a bit of test code using the same logic as is in JavaVersionImpl.java and could not get it to throw a NumberFormatException unless the argument had quotation marks around it.  Not sure if that's a red herring though.

package regex_test;

import java.lang.System.Logger;

public class RegexTest {

   
private static final Logger LOG = System.getLogger(RegexTest.class.getName());

   
public static void main(String[] args) {
       
String version = new String();
        version
= fromString(args[0]);
        LOG
.log(Logger.Level.INFO, "Version parsed: " + version);
   
}
   
public static String fromString(String javaVersion) {

       
try {
         
// javaVersion = javaVersion.replaceAll("\"|'|’|“|”", "");
         
String cleanedVersion = javaVersion.startsWith("1.") ? javaVersion.substring(2) : javaVersion;
         
int versionAsInt = Integer.parseInt(cleanedVersion);
         
return Integer.toString(versionAsInt);
       
} catch (NumberFormatException e) {
          LOG
.log(Logger.Level.WARNING, "Invalid java version (got \"" + javaVersion + "\"). "
           
+ "The version will be ignored. Accepted formats are \"1.X\", or simply \"X\" "
           
+ "(for instance: \"1.5\" or \"5\", \"1.6\" or \"6\", \"1.7\" or \"7\", etc.)");
         
return javaVersion;
       
}
   
}
}


Michael Gumowski

unread,
May 15, 2018, 3:15:45 AM5/15/18
to mic...@mraz.org, SonarQube
Hello Michael,

Can you check what is the version of the SonarJava Analyzer which is installed on your SonarQube instance?
As far as I can tell, we fixed this issue when working on support of Java 10 (commit). This have been released with version 5.3.0.13828 of SonarJava.

I guess that updating to latest released version should fix the issue. Don't hesitate to come back to us if it's not the case.

Cheers,
Michael

--
You received this message because you are subscribed to the Google Groups "SonarQube" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonarqube+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sonarqube/ad862387-54e7-4ebb-81f3-fda30c7aec48%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
Michael Gumowski | SonarSource
Software Developer, Language Team
https://www.sonarsource.com

mic...@mraz.org

unread,
May 15, 2018, 11:19:59 AM5/15/18
to SonarQube
Michael, thank you for the response.

This is occurring against freshly provisioned sonarqube docker container images.
I tried both mwizner/sonarqube-scala-plugins:2.4.0-full which is SonarQube 6.7.3 and sonarqube:latest which is SonarQube 7.1.  I'm using the latest version of the org.sonarqube gradle plugin, 2.6.2, as well.

It looks like the sonarqube:latest docker image comes with SonarJava 5.2 (build 13398).  After upgrading the plugin in the Admin interface and restarting the error is gone.

I would like to be able to deploy sonarqube:latest and have the most current plugins available.  Is there a project I can submit a PR against to make this the default?  Or do you have another suggestion on how to automate this version upgrade on provisioning and first boot of the instance?

Michael Gumowski

unread,
May 15, 2018, 11:36:00 AM5/15/18
to mic...@mraz.org, SonarQube
Hey,

Glad to see updating to latest SonarJava version fixed the issue.

SonarQube releases are bundled with most of the SonarQube analyzers, at their latest released versions at the time of the release.
Unfortunately for you, analyzers are not following the same lifecycle than SonarQube, and release more often than SonarQube.

Now, I hardly see how you could expect to have all the plugins with latest released versions all the time, but it's completely out of scope of my domain of expertise. Maybe someone around this mailing list can give you more insight about how to update docker images, or automate update of plugins.

Cheers,
Michael

--
You received this message because you are subscribed to the Google Groups "SonarQube" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonarqube+...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages