Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.0
    • Fix Version/s: 2.4
    • Component/s: Hotspots View
    • Labels:
      None
    • Number of attachments :
      1

      Description

      The received the following exception (from Eclipse log file):

      !ENTRY org.eclipse.core.jobs 4 2 2011-01-31 11:08:52.294
      !MESSAGE An internal error occurred during: "Loading hotspots".
      !STACK 0
      java.lang.NullPointerException
      	at org.sonar.wsclient.unmarshallers.AbstractUnmarshaller.toModels(AbstractUnmarshaller.java:48)
      	at org.sonar.wsclient.Sonar.findAll(Sonar.java:64)
      	at org.sonar.ide.eclipse.internal.ui.views.HotspotsView$5.run(HotspotsView.java:239)
      	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
      

      Here are the steps on how I got this NPE:

      Given

      • Sonar IDE plugin is activated for a project in Eclipse
      • In the Sonar perspective
      • The Sonar > Hotspots view is opened

      Then

      • I opened a file in Eclipse

      Expected result:

      • The hotspots are loaded in the Sonar > Hotspots view.
        Actual result:
      • I received the NPE mentioned above and the hotspots are not loaded in the Sonar > Hotspots view.

        Activity

        Hide
        Jean-Noel Rouvignac added a comment - - edited

        Prior to that I got another exception in the same place but from a different path:

        !ENTRY org.sonar.ide.eclipse.ui 4 0 2011-01-31 11:08:47.280
        !MESSAGE 
        !STACK 0
        java.lang.NullPointerException
        	at org.sonar.wsclient.unmarshallers.AbstractUnmarshaller.toModel(AbstractUnmarshaller.java:35)
        	at org.sonar.wsclient.Sonar.find(Sonar.java:52)
        	at org.sonar.ide.wsclient.RemoteSonarIndex.search(RemoteSonarIndex.java:78)
        	at org.sonar.ide.wsclient.RemoteSonar.search(RemoteSonar.java:48)
        	at org.sonar.ide.eclipse.internal.EclipseSonar.search(EclipseSonar.java:66)
        	at org.sonar.ide.eclipse.internal.EclipseSonar.search(EclipseSonar.java:90)
        	at org.sonar.ide.eclipse.internal.ui.jobs.RefreshViolationsJob.retrieveDatas(RefreshViolationsJob.java:65)
        	at org.sonar.ide.eclipse.internal.ui.jobs.AbstractRefreshModelJob.retrieveMarkers(AbstractRefreshModelJob.java:107)
        	at org.sonar.ide.eclipse.internal.ui.jobs.AbstractRefreshModelJob.visit(AbstractRefreshModelJob.java:93)
        	at org.eclipse.core.internal.resources.Resource$2.visit(Resource.java:112)
        	at org.eclipse.core.internal.resources.Resource$1.visitElement(Resource.java:64)
        	at org.eclipse.core.internal.watson.ElementTreeIterator.doIteration(ElementTreeIterator.java:82)
        	at org.eclipse.core.internal.watson.ElementTreeIterator.iterate(ElementTreeIterator.java:127)
        	at org.eclipse.core.internal.resources.Resource.accept(Resource.java:74)
        	at org.eclipse.core.internal.resources.Resource.accept(Resource.java:110)
        	at org.eclipse.core.internal.resources.Resource.accept(Resource.java:94)
        	at org.sonar.ide.eclipse.internal.ui.jobs.AbstractRefreshModelJob.run(AbstractRefreshModelJob.java:72)
        	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
        
        Show
        Jean-Noel Rouvignac added a comment - - edited Prior to that I got another exception in the same place but from a different path: !ENTRY org.sonar.ide.eclipse.ui 4 0 2011-01-31 11:08:47.280 !MESSAGE !STACK 0 java.lang.NullPointerException at org.sonar.wsclient.unmarshallers.AbstractUnmarshaller.toModel(AbstractUnmarshaller.java:35) at org.sonar.wsclient.Sonar.find(Sonar.java:52) at org.sonar.ide.wsclient.RemoteSonarIndex.search(RemoteSonarIndex.java:78) at org.sonar.ide.wsclient.RemoteSonar.search(RemoteSonar.java:48) at org.sonar.ide.eclipse.internal.EclipseSonar.search(EclipseSonar.java:66) at org.sonar.ide.eclipse.internal.EclipseSonar.search(EclipseSonar.java:90) at org.sonar.ide.eclipse.internal.ui.jobs.RefreshViolationsJob.retrieveDatas(RefreshViolationsJob.java:65) at org.sonar.ide.eclipse.internal.ui.jobs.AbstractRefreshModelJob.retrieveMarkers(AbstractRefreshModelJob.java:107) at org.sonar.ide.eclipse.internal.ui.jobs.AbstractRefreshModelJob.visit(AbstractRefreshModelJob.java:93) at org.eclipse.core.internal.resources.Resource$2.visit(Resource.java:112) at org.eclipse.core.internal.resources.Resource$1.visitElement(Resource.java:64) at org.eclipse.core.internal.watson.ElementTreeIterator.doIteration(ElementTreeIterator.java:82) at org.eclipse.core.internal.watson.ElementTreeIterator.iterate(ElementTreeIterator.java:127) at org.eclipse.core.internal.resources.Resource.accept(Resource.java:74) at org.eclipse.core.internal.resources.Resource.accept(Resource.java:110) at org.eclipse.core.internal.resources.Resource.accept(Resource.java:94) at org.sonar.ide.eclipse.internal.ui.jobs.AbstractRefreshModelJob.run(AbstractRefreshModelJob.java:72) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
        Hide
        Jean-Noel Rouvignac added a comment - - edited

        I also got a "Read timed out" exception before one of the NPE stack traces, so this could be linked. However, I think the NPE should still not happen.

        !ENTRY org.eclipse.core.jobs 4 2 2011-01-31 11:08:51.666
        !MESSAGE An internal error occurred during: "Loading hotspots".
        !STACK 0
        org.sonar.wsclient.connectors.ConnectionException: Can not read response for query http://SILOCZC0031HFR:9000/api/resources?resource=com.im:allocations-api&metrics=duplicated_lines&scopes=FIL&depth=-1&limit=20&verbose=false& :
        Read timed out
        	at org.sonar.ide.client.ExtendedHttpClient3Connector.executeRequest(ExtendedHttpClient3Connector.java:122)
        	at org.sonar.ide.client.ExtendedHttpClient3Connector.execute(ExtendedHttpClient3Connector.java:99)
        	at org.sonar.wsclient.Sonar.findAll(Sonar.java:58)
        	at org.sonar.ide.eclipse.internal.ui.views.HotspotsView$5.run(HotspotsView.java:239)
        	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
        Caused by: java.net.SocketTimeoutException: Read timed out
        	at java.net.SocketInputStream.socketRead0(Native Method)
        	at java.net.SocketInputStream.read(SocketInputStream.java:129)
        	at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
        	at java.io.BufferedInputStream.read(BufferedInputStream.java:237)
        	at org.apache.commons.httpclient.HttpParser.readRawLine(HttpParser.java:78)
        	at org.apache.commons.httpclient.HttpParser.readLine(HttpParser.java:106)
        	at org.apache.commons.httpclient.HttpConnection.readLine(HttpConnection.java:1116)
        	at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$HttpConnectionAdapter.readLine(MultiThreadedHttpConnectionManager.java:1413)
        	at org.apache.commons.httpclient.HttpMethodBase.readStatusLine(HttpMethodBase.java:1973)
        	at org.apache.commons.httpclient.HttpMethodBase.readResponse(HttpMethodBase.java:1735)
        	at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:1098)
        	at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:398)
        	at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
        	at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
        	at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:323)
        	at org.sonar.ide.client.ExtendedHttpClient3Connector.executeRequest(ExtendedHttpClient3Connector.java:113)
        	... 4 more
        
        !ENTRY org.eclipse.core.jobs 4 2 2011-01-31 11:08:52.294
        !MESSAGE An internal error occurred during: "Loading hotspots".
        !STACK 0
        java.lang.NullPointerException
        	at org.sonar.wsclient.unmarshallers.AbstractUnmarshaller.toModels(AbstractUnmarshaller.java:48)
        	at org.sonar.wsclient.Sonar.findAll(Sonar.java:64)
        	at org.sonar.ide.eclipse.internal.ui.views.HotspotsView$5.run(HotspotsView.java:239)
        	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
        
        Show
        Jean-Noel Rouvignac added a comment - - edited I also got a "Read timed out" exception before one of the NPE stack traces, so this could be linked. However, I think the NPE should still not happen. !ENTRY org.eclipse.core.jobs 4 2 2011-01-31 11:08:51.666 !MESSAGE An internal error occurred during: "Loading hotspots". !STACK 0 org.sonar.wsclient.connectors.ConnectionException: Can not read response for query http://SILOCZC0031HFR:9000/api/resources?resource=com.im:allocations-api&metrics=duplicated_lines&scopes=FIL&depth=-1&limit=20&verbose=false& : Read timed out at org.sonar.ide.client.ExtendedHttpClient3Connector.executeRequest(ExtendedHttpClient3Connector.java:122) at org.sonar.ide.client.ExtendedHttpClient3Connector.execute(ExtendedHttpClient3Connector.java:99) at org.sonar.wsclient.Sonar.findAll(Sonar.java:58) at org.sonar.ide.eclipse.internal.ui.views.HotspotsView$5.run(HotspotsView.java:239) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54) Caused by: java.net.SocketTimeoutException: Read timed out at java.net.SocketInputStream.socketRead0(Native Method) at java.net.SocketInputStream.read(SocketInputStream.java:129) at java.io.BufferedInputStream.fill(BufferedInputStream.java:218) at java.io.BufferedInputStream.read(BufferedInputStream.java:237) at org.apache.commons.httpclient.HttpParser.readRawLine(HttpParser.java:78) at org.apache.commons.httpclient.HttpParser.readLine(HttpParser.java:106) at org.apache.commons.httpclient.HttpConnection.readLine(HttpConnection.java:1116) at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$HttpConnectionAdapter.readLine(MultiThreadedHttpConnectionManager.java:1413) at org.apache.commons.httpclient.HttpMethodBase.readStatusLine(HttpMethodBase.java:1973) at org.apache.commons.httpclient.HttpMethodBase.readResponse(HttpMethodBase.java:1735) at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:1098) at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:398) at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171) at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397) at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:323) at org.sonar.ide.client.ExtendedHttpClient3Connector.executeRequest(ExtendedHttpClient3Connector.java:113) ... 4 more !ENTRY org.eclipse.core.jobs 4 2 2011-01-31 11:08:52.294 !MESSAGE An internal error occurred during: "Loading hotspots". !STACK 0 java.lang.NullPointerException at org.sonar.wsclient.unmarshallers.AbstractUnmarshaller.toModels(AbstractUnmarshaller.java:48) at org.sonar.wsclient.Sonar.findAll(Sonar.java:64) at org.sonar.ide.eclipse.internal.ui.views.HotspotsView$5.run(HotspotsView.java:239) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
        Hide
        Jean-Noel Rouvignac added a comment -

        I just realised the code throwing the NPE is from Sonar project. You might need to reassign the ug to the Sonar project:
        http://svn.codehaus.org/sonar/trunk/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/AbstractUnmarshaller.java

        and it seems like there is an opportunity for NPEs. It might be good to add null checks there:

          public final MODEL toModel(String json) {
            MODEL  result = null;
            JSONArray array = (JSONArray) JSONValue.parse(json);
        // FIXME: Next line is an opportunity for an NPE
        // (The javadoc for JSONValue.parse() mentions null as a possible return value)
            if (array.size() >= 1) {
              JSONObject elt = (JSONObject) array.get(0);
              if (elt != null) {
                result = parse(elt);
              }
            }
            return result;
          }
        
          public final List<MODEL> toModels(String json) {
            List<MODEL> result = new ArrayList<MODEL>();
            JSONArray array = (JSONArray) JSONValue.parse(json);
        // FIXME: Next line is an opportunity for an NPE
        // (The javadoc for JSONValue.parse() mentions null as a possible return value)
            for (Object anArray : array) {
              JSONObject elt = (JSONObject) anArray;
              if (elt != null) {
                result.add(parse(elt));
              }
            }
            return result;
          }
        
        Show
        Jean-Noel Rouvignac added a comment - I just realised the code throwing the NPE is from Sonar project. You might need to reassign the ug to the Sonar project: http://svn.codehaus.org/sonar/trunk/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/AbstractUnmarshaller.java and it seems like there is an opportunity for NPEs. It might be good to add null checks there: public final MODEL toModel( String json) { MODEL result = null ; JSONArray array = (JSONArray) JSONValue.parse(json); // FIXME: Next line is an opportunity for an NPE // (The javadoc for JSONValue.parse() mentions null as a possible return value) if (array.size() >= 1) { JSONObject elt = (JSONObject) array.get(0); if (elt != null ) { result = parse(elt); } } return result; } public final List<MODEL> toModels( String json) { List<MODEL> result = new ArrayList<MODEL>(); JSONArray array = (JSONArray) JSONValue.parse(json); // FIXME: Next line is an opportunity for an NPE // (The javadoc for JSONValue.parse() mentions null as a possible return value) for ( Object anArray : array) { JSONObject elt = (JSONObject) anArray; if (elt != null ) { result.add(parse(elt)); } } return result; }

          People

          • Assignee:
            David Gageot
            Reporter:
            Jean-Noel Rouvignac
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: