luomuqinghan / weibo4j

Automatically exported from code.google.com/p/weibo4j
Other
0 stars 1 forks source link

Response.getResponseAsString() may not work #7

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
[code]
client.setOAuthAccessToken(accessToken);
Response response =  client.get(responseUrl,true);
if (response != null) {
    System.out.println(response.getResponseAsString());
}
[/code]

you may get "null" if the response.asString() has not been invoked yet.

What is the expected output? What do you see instead?
check the following codes in Response.java
[code]
    public String getResponseAsString() {
        return responseAsString;
    }
[/code]

it may be a nice getter, but it doesn't work sometimes.

a quick fix may like this,
[code]
    public String getResponseAsString() {
//      return responseAsString;
        if(this.responseAsString == null){
            try {
                this.responseAsString = asString();
            } catch (WeiboException e) {
                responseAsString = e.getMessage();
            }
        }
        return responseAsString;
    }

[/code]

What version of the product are you using? On what operating system?
Ubuntu 10.10

Please provide any additional information below.

Original issue reported on code.google.com by syncforw...@gmail.com on 30 Sep 2011 at 1:58