From 7201c0c21649fd2f6460688ad1d3f9701de6777b Mon Sep 17 00:00:00 2001 From: Sebastian Bazley Date: Thu, 8 Nov 2012 01:52:14 +0000 Subject: [PATCH] Unnecessary null check. Move setup of default value to where variable is declared git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1406892 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/http/impl/auth/DigestScheme.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/httpclient/src/main/java/org/apache/http/impl/auth/DigestScheme.java b/httpclient/src/main/java/org/apache/http/impl/auth/DigestScheme.java index cdf95b750..f51c20549 100644 --- a/httpclient/src/main/java/org/apache/http/impl/auth/DigestScheme.java +++ b/httpclient/src/main/java/org/apache/http/impl/auth/DigestScheme.java @@ -257,6 +257,10 @@ public class DigestScheme extends RFC2617Scheme { String opaque = getParameter("opaque"); String method = getParameter("methodname"); String algorithm = getParameter("algorithm"); + // If an algorithm is not specified, default to MD5. + if (algorithm == null) { + algorithm = "MD5"; + } Set qopset = new HashSet(8); int qop = QOP_UNKNOWN; @@ -280,10 +284,6 @@ public class DigestScheme extends RFC2617Scheme { throw new AuthenticationException("None of the qop methods is supported: " + qoplist); } - // If an algorithm is not specified, default to MD5. - if (algorithm == null) { - algorithm = "MD5"; - } String charset = getParameter("charset"); if (charset == null) { charset = "ISO-8859-1"; @@ -418,9 +418,8 @@ public class DigestScheme extends RFC2617Scheme { params.add(new BasicNameValuePair("nc", nc)); params.add(new BasicNameValuePair("cnonce", cnonce)); } - if (algorithm != null) { - params.add(new BasicNameValuePair("algorithm", algorithm)); - } + // algorithm cannot be null here + params.add(new BasicNameValuePair("algorithm", algorithm)); if (opaque != null) { params.add(new BasicNameValuePair("opaque", opaque)); }