summaryrefslogtreecommitdiff
path: root/src/com/p4square
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
commit0daa3ec0fa105c5bcbabec35cb61e07a20049e93 (patch)
tree959a828a947fc5267937abf1bd5318bab4a56ee2 /src/com/p4square
parentf93d756c47433d3399d43b5b1975182720b0b6e9 (diff)
Fixing connection leak on failed login
Diffstat (limited to 'src/com/p4square')
-rw-r--r--src/com/p4square/restlet/oauth/OAuthHelper.java20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/com/p4square/restlet/oauth/OAuthHelper.java b/src/com/p4square/restlet/oauth/OAuthHelper.java
index 544e4e3..39c1b02 100644
--- a/src/com/p4square/restlet/oauth/OAuthHelper.java
+++ b/src/com/p4square/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();
}
}