summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJesse Morgan <jesse@jesterpm.net>2013-10-01 22:15:31 -0700
committerJesse Morgan <jesse@jesterpm.net>2013-10-01 22:15:31 -0700
commit13fe4388c758d6272327e1ca086df29ef78e32a1 (patch)
tree0e98bfbfc6b84ab3852036839adedfa06ea10ab3 /src
parent8f1c301d823a441935e783cdb6c39ba7bcddb9eb (diff)
Fixing connection leak on failed login
Diffstat (limited to 'src')
-rw-r--r--src/net/jesterpm/restlet/oauth/OAuthHelper.java20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/net/jesterpm/restlet/oauth/OAuthHelper.java b/src/net/jesterpm/restlet/oauth/OAuthHelper.java
index a4a05cd..235fa28 100644
--- a/src/net/jesterpm/restlet/oauth/OAuthHelper.java
+++ b/src/net/jesterpm/restlet/oauth/OAuthHelper.java
@@ -17,6 +17,7 @@ import org.restlet.data.Method;
import org.restlet.data.Reference;
import org.restlet.data.Status;
import org.restlet.engine.Engine;
+import org.restlet.representation.Representation;
/**
* Helper Class for OAuth 1.0 Authentication.
@@ -99,16 +100,21 @@ public abstract class OAuthHelper {
*/
protected Token processTokenRequest(Response response) throws OAuthException {
Status status = response.getStatus();
+ Representation entity = response.getEntity();
- if (status.isSuccess()) {
- Form form = new Form(response.getEntity());
- String token = form.getFirstValue("oauth_token");
- String secret = form.getFirstValue("oauth_token_secret");
+ try {
+ if (status.isSuccess()) {
+ Form form = new Form(entity);
+ String token = form.getFirstValue("oauth_token");
+ String secret = form.getFirstValue("oauth_token_secret");
- return new Token(token, secret);
+ return new Token(token, secret);
- } else {
- throw new OAuthException(status);
+ } else {
+ throw new OAuthException(status);
+ }
+ } finally {
+ entity.release();
}
}