title: jackson failing to map empty array with No content to map to Object due to end of input
body: <p>I send a query to an api and map the json results to my classes using Jackson.
  When I get some results it works fine, but when there are no results it fails with </p>
  
  <pre><code>java.io.EOFException: No content to map to Object due to end of input
  at org.codehaus.jackson.map.ObjectMapper._initForReading(ObjectMapper.java:2766)
  at org.codehaus.jackson.map.ObjectMapper._readMapAndClose(ObjectMapper.java:2709)
  at org.codehaus.jackson.map.ObjectMapper.readValue(ObjectMapper.java:1854)
  at com.jthink.discogs.query.DiscogsServerQuery.mapQuery(DiscogsServerQuery.java:382)
  at com.jthink.discogs.query.SearchQuery.mapQuery(SearchQuery.java:37)*
  </code></pre>
  
  <p>But the thing is the api isn't returning nothing at all, so I dont see why it is failing. </p>
  
  <p>Here is the query:</p>
  
  <pre><code>http://api.discogs.com/database/search?page=1&amp;type=release&amp;release_title=nude+and+rude+the+best+of+iggy+pop
  </code></pre>
  
  <p>this is what I get back</p>
  
  <pre><code>{
      "pagination": {
          "per_page": 50,
          "pages": 1,
          "page": 1,
          "urls": {},
          "items": 0
      },
      "results": []
  }
  </code></pre>
  
  <p>and here is the top level object Im trying to map to</p>
  
  <pre><code>public class Search
  {
      private Pagination pagination;
      private Result[] results;
  
      public Pagination getPagination() {
          return pagination;
      }
  
      public void setPagination(Pagination pagination) {
          this.pagination = pagination;
      }
  
      public Result[] getResults() {
          return results;
      }
  
      public void setResults(Result[] results) {
          this.results = results;
      }
  }
  </code></pre>
  
  <p>Im guessing the problem is something to do with the results array being returned being blank, but cant see what Im doing wrong</p>
  
  <p>EDIT:
  The comment below was correct, although I usually receive</p>
  
  <pre><code>{
      "pagination": {
          "per_page": 50,
          "pages": 1,
          "page": 1,
          "urls": {},
          "items": 0
      },
      "results": []
  }
  </code></pre>
  
  <p>and in these cases there is no problem but sometimes I seem to just get an empty String. Now Im wondering if the problem is how I read from the inputstream </p>
  
  <pre><code> if (responseCode == HttpURLConnection.HTTP_OK)
          InputStreamReader in= new InputStreamReader(uc.getInputStream());
          BufferedReader    br= new BufferedReader(in);
          while(br.ready())
          {
              String next = br.readLine();
              sb.append(next);
          }
          return sb.toString();
    }
  </code></pre>
  
  <p>although I dont read until I get the response code, is it possible that the first time I call br.ready() that I call it before it is ready, and therefore I don't read the input</p>
  
  <p>EDIT 2:</p>
  
  <p>Changing above code to simply</p>
  
  <pre><code>        String line;
          while ((line = br.readLine()) != null)
          {
              sb.append(line);
          }
  </code></pre>
  
  <p>resolved the issue.</p>