From 8cc363adfa68c14a75f1ecb58df24c96306c82ee Mon Sep 17 00:00:00 2001 From: Jesse Morgan Date: Sat, 1 Feb 2014 19:16:47 -0800 Subject: Fixing resource leak. --- src/com/p4square/f1oauth/SecondPartyVerifier.java | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/com/p4square/f1oauth/SecondPartyVerifier.java b/src/com/p4square/f1oauth/SecondPartyVerifier.java index 9635283..b1afcfa 100644 --- a/src/com/p4square/f1oauth/SecondPartyVerifier.java +++ b/src/com/p4square/f1oauth/SecondPartyVerifier.java @@ -74,14 +74,20 @@ public class SecondPartyVerifier implements Verifier { request.setChallengeResponse(user.getChallengeResponse()); Response response = mDispatcher.handle(request); - Status status = response.getStatus(); - if (status.isSuccess()) { - JacksonRepresentation entity = new JacksonRepresentation(response.getEntity(), Map.class); - Map data = entity.getObject(); - return new F1User(user, data); - - } else { - throw new OAuthException(status); + try { + Status status = response.getStatus(); + if (status.isSuccess()) { + JacksonRepresentation entity = new JacksonRepresentation(response.getEntity(), Map.class); + Map data = entity.getObject(); + return new F1User(user, data); + + } else { + throw new OAuthException(status); + } + } finally { + if (response.getEntity() != null) { + response.release(); + } } } } -- cgit v1.2.3