<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Infinite loop when there are no results using JSON output in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/Infinite-loop-when-there-are-no-results-using-JSON-output/m-p/29312#M326</link>
    <description>&lt;P&gt;I am using Splunk 5.0.2 with Java SDK 1.1. If I run a search that does not return any result, and use the ResultReaderJson class to parse the result the &lt;CODE&gt;com.splunk.ResultsReaderJson#readEvent&lt;/CODE&gt; method gets into an infinite loop and does not return.&lt;/P&gt;

&lt;P&gt;The problem is that when Splunk tries to parse the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{"results":[{"count":0}]}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;It starts reading the object starting at the &lt;CODE&gt;{&lt;/CODE&gt;, it reads the count as name (in /com/splunk/ResultsReaderJson.java:287) then the next Json token is a JsonToken.NUMBER with the value 0, but the method does not handle it, it expects only *_START/ *_END, NAME and STRING tokens.&lt;/P&gt;</description>
    <pubDate>Thu, 09 May 2013 19:26:24 GMT</pubDate>
    <dc:creator>andras_kerekes</dc:creator>
    <dc:date>2013-05-09T19:26:24Z</dc:date>
    <item>
      <title>Infinite loop when there are no results using JSON output</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Infinite-loop-when-there-are-no-results-using-JSON-output/m-p/29312#M326</link>
      <description>&lt;P&gt;I am using Splunk 5.0.2 with Java SDK 1.1. If I run a search that does not return any result, and use the ResultReaderJson class to parse the result the &lt;CODE&gt;com.splunk.ResultsReaderJson#readEvent&lt;/CODE&gt; method gets into an infinite loop and does not return.&lt;/P&gt;

&lt;P&gt;The problem is that when Splunk tries to parse the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{"results":[{"count":0}]}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;It starts reading the object starting at the &lt;CODE&gt;{&lt;/CODE&gt;, it reads the count as name (in /com/splunk/ResultsReaderJson.java:287) then the next Json token is a JsonToken.NUMBER with the value 0, but the method does not handle it, it expects only *_START/ *_END, NAME and STRING tokens.&lt;/P&gt;</description>
      <pubDate>Thu, 09 May 2013 19:26:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Infinite-loop-when-there-are-no-results-using-JSON-output/m-p/29312#M326</guid>
      <dc:creator>andras_kerekes</dc:creator>
      <dc:date>2013-05-09T19:26:24Z</dc:date>
    </item>
    <item>
      <title>Re: Infinite loop when there are no results using JSON output</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Infinite-loop-when-there-are-no-results-using-JSON-output/m-p/29313#M327</link>
      <description>&lt;P&gt;Upgrading to Splunk 5.0.3 resolves the problem as it returns an empty array for results:&lt;BR /&gt;
&lt;CODE&gt;&lt;BR /&gt;
 "results":[]&lt;BR /&gt;
&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;The ResultReaderJson then can correctly parse it.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jun 2013 22:17:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Infinite-loop-when-there-are-no-results-using-JSON-output/m-p/29313#M327</guid>
      <dc:creator>andras_kerekes</dc:creator>
      <dc:date>2013-06-27T22:17:19Z</dc:date>
    </item>
  </channel>
</rss>

