Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8131113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T08:58:56+00:00 2026-06-06T08:58:56+00:00

I send a query to an api and map the json results to my

  • 0

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

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)*

But the thing is the api isn’t returning nothing at all, so I dont see why it is failing.

Here is the query:

http://api.discogs.com/database/search?page=1&type=release&release_title=nude+and+rude+the+best+of+iggy+pop

this is what I get back

{
    "pagination": {
        "per_page": 50,
        "pages": 1,
        "page": 1,
        "urls": {},
        "items": 0
    },
    "results": []
}

and here is the top level object Im trying to map to

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;
    }
}

Im guessing the problem is something to do with the results array being returned being blank, but cant see what Im doing wrong

EDIT:
The comment below was correct, although I usually receive

{
    "pagination": {
        "per_page": 50,
        "pages": 1,
        "page": 1,
        "urls": {},
        "items": 0
    },
    "results": []
}

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

 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();
  }

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

EDIT 2:

Changing above code to simply

        String line;
        while ((line = br.readLine()) != null)
        {
            sb.append(line);
        }

resolved the issue.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T08:58:58+00:00Added an answer on June 6, 2026 at 8:58 am

    Changing above code to simply

            String line;
            while ((line = br.readLine()) != null)
            {
                sb.append(line);
            }
    

    resolved the issue.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to query an api through JSON / REST using Ruby. require
I am developing an API using php where I just send out the query
i am trying to send multiple data using j query $.ajax method to my
Why do I get the answer no? jQuery to send data to php query
I send email through Outlook using VB.Net 2005; this is working fine. At the
I need to make a Ember Resource to send its query using one of
Using the Query object in the Google Visualization API , I need to find
Using the API call notifications.sendEmail you can send an email to a application user
I'm using the Twilio API to send broadcast SMS messages based on an approved
I want to send a query to Wikipedia. The Reponse contains some informations about

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.