sander120786 / oauth-signpost

Automatically exported from code.google.com/p/oauth-signpost
0 stars 0 forks source link

NULL exception after CommonsHttpOAuthProvider is de-serialized #70

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Create OAuthProvider and OAuthConsumer and call retrieveRequestToken() and 
start to authenticate as usual;
2. serialize OAuthProvider and OAuthConsumer;
3. de-serialize OAuthProvider and OAuthConsumer, use them to call 
retrieveAccessToken()

What is the expected output? What do you see instead?
It should work OK, but it actually encounter NULL exception:
W/System.err(11149): Caused by: java.lang.NullPointerException
W/System.err(11149):    at 
oauth.signpost.commonshttp.CommonsHttpOAuthProvider.sendRequest(CommonsHttpOAuth
Provider.java:64)
W/System.err(11149):    at 
oauth.signpost.AbstractOAuthProvider.retrieveToken(AbstractOAuthProvider.java:17
7)
W/System.err(11149):    ... 18 more

Please provide any additional information below.

The root cause should be in CommonsHttpOAuthProvider:
public class CommonsHttpOAuthProvider extends AbstractOAuthProvider {
    private static final long serialVersionUID = 1L;
    private transient HttpClient httpClient;
...

httpClient is transient, so after de-serialize it is NULL, and that's why it 
get NULL exception on 
oauth.signpost.commonshttp.CommonsHttpOAuthProvider.sendRequest(CommonsHttpOAuth
Provider.java:64)

Original issue reported on code.google.com by mine260...@gmail.com on 8 Dec 2011 at 1:51