SonarQube Runner
  1. SonarQube Runner
  2. SONARUNNER-44

By default, do not display the stack trace when the analysis fails

    Details

    • Type: Improvement Improvement
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.1
    • Labels:
      None
    • Number of attachments :
      0

      Description

      When an analysis fails, the stack trace is always printed out at the end - which is good for support purposes.
      However, it usually takes too much space compared to the rest of the result status of the analysis, the whole space it takes is often not usefull for most users ant it can even "hide" information like in the following example :

      My Project$ sonar-runner -Dsonar.host.url=http://localhost:5555
      Runner configuration file: /.../conf/sonar-runner.properties
      Project configuration file: /.../My Project/sonar-project.properties
      Runner version: 2.1-SNAPSHOT
      Java version: 1.6.0_37, vendor: Apple Inc.
      OS name: "Mac OS X", version: "10.6.8", arch: "x86_64"
      Default locale: "en_US", source code encoding: "UTF-8"
      Server: http://localhost:5555
      Work directory: /.../My Project/.sonar
      ERROR: Sonar server 'http://localhost:5555' can not be reached
      Total time: 0.041s
      Final Memory: 0M/81M
      Exception in thread "main" java.lang.IllegalStateException: Fail to request server version
              at org.sonar.runner.Bootstrapper.getServerVersion(Bootstrapper.java:80)
              at org.sonar.runner.Runner.checkSonarVersion(Runner.java:225)
              at org.sonar.runner.Runner.execute(Runner.java:150)
              at org.sonar.runner.Main.execute(Main.java:88)
              at org.sonar.runner.Main.main(Main.java:57)
      Caused by: java.net.ConnectException: Connection refused
              at java.net.PlainSocketImpl.socketConnect(Native Method)
              at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351)
              at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213)
              at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200)
              at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:432)
              at java.net.Socket.connect(Socket.java:529)
              at sun.net.NetworkClient.doConnect(NetworkClient.java:158)
              at sun.net.www.http.HttpClient.openServer(HttpClient.java:388)
              at sun.net.www.http.HttpClient.openServer(HttpClient.java:523)
              at sun.net.www.http.HttpClient.<init>(HttpClient.java:227)
              at sun.net.www.http.HttpClient.New(HttpClient.java:300)
              at sun.net.www.http.HttpClient.New(HttpClient.java:317)
              at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:970)
              at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:911)
              at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:836)
              at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1172)
              at sun.net.www.protocol.http.HttpURLConnection.getHeaderField(HttpURLConnection.java:2300)
              at java.net.URLConnection.getContentType(URLConnection.java:485)
              at org.sonar.runner.Bootstrapper.remoteContent(Bootstrapper.java:134)
              ... 5 more
      

      => in this case, it's harder to see the clean "ERROR: Sonar server 'http://localhost:5555' can not be reached" message.

      Maybe we could do like Maven:

      • by default, no stack trace is printed out
      • there's a "-e" parameter that can show it if we need it

      If we do that, this has some consequences:

      • we must modify the last lines of the log to clearly add the analysis result status (which is currently not the case)
      • we must make sure that as we don't print out the stack trace by default, a clean ERROR message must printed out with the message carried out by the stack trace in order to give a first hint to the user

      (basically, all what Maven does pretty nicely in terms of logging related to this topic)

        Activity

        Hide
        Julien HENRY added a comment -

        I have reworked the error reporting trying to mimic what is done in Maven cli.

        Show
        Julien HENRY added a comment - I have reworked the error reporting trying to mimic what is done in Maven cli.
        Hide
        Fabrice Bellingard added a comment -

        Great Julien!
        Manually tested.

        Show
        Fabrice Bellingard added a comment - Great Julien! Manually tested.
        Hide
        Julien HENRY added a comment -

        ITs will be added later

        Show
        Julien HENRY added a comment - ITs will be added later

          People

          • Assignee:
            Julien HENRY
            Reporter:
            Fabrice Bellingard
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: