fix sonar rule check violations

This commit is contained in:
wenshao
2012-08-29 19:02:22 +08:00
parent f3d2a88c4d
commit e72a2c5e0f
14 changed files with 123 additions and 108 deletions
@@ -201,9 +201,9 @@ public class StatViewServlet extends HttpServlet {
}
if ("/submitLogin".equals(path)) {
String _username = request.getParameter(PARAM_NAME_USERNAME);
String _password = request.getParameter(PARAM_NAME_PASSWORD);
if (username.equals(_username) && password.equals(_password)) {
String usernameParam = request.getParameter(PARAM_NAME_USERNAME);
String passwordParam = request.getParameter(PARAM_NAME_PASSWORD);
if (username.equals(usernameParam) && password.equals(passwordParam)) {
request.getSession().setAttribute(SESSION_USER_KEY, username);
response.getWriter().print("success");
} else {
@@ -581,7 +581,7 @@ public class WebAppStat {
}
boolean isIE = userAgent.startsWith("MSIE", MOZILLA_COMPATIBLE_OFFSET);
int ie_prefix_index = 30; // "Mozilla/5.0 (compatible; MSIE ".length();
int iePrefixIndex = 30; // "Mozilla/5.0 (compatible; MSIE ".length();
boolean isGoogleToolbar = false;
@@ -592,7 +592,7 @@ public class WebAppStat {
int tmp = userAgent.indexOf("IE ");
if (tmp != -1) {
isIE = true;
ie_prefix_index = tmp + 3;
iePrefixIndex = tmp + 3;
}
}
}
@@ -602,11 +602,11 @@ public class WebAppStat {
browserIECount.incrementAndGet();
char v1 = ' ', v2 = ' ';
if (userAgent.length() > ie_prefix_index + 1) {
v1 = userAgent.charAt(ie_prefix_index);
v2 = userAgent.charAt(ie_prefix_index + 1);
} else if (userAgent.length() > ie_prefix_index) {
v1 = userAgent.charAt(ie_prefix_index);
if (userAgent.length() > iePrefixIndex + 1) {
v1 = userAgent.charAt(iePrefixIndex);
v2 = userAgent.charAt(iePrefixIndex + 1);
} else if (userAgent.length() > iePrefixIndex) {
v1 = userAgent.charAt(iePrefixIndex);
}
switch (v1) {
@@ -262,9 +262,9 @@ public class IPAddress implements Cloneable {
throw new IllegalArgumentException("Invalid IP Address [" + ipAddressStr + "]");
}
} catch (NoSuchElementException ex) {
throw new IllegalArgumentException("Invalid IP Address [" + ipAddressStr + "]");
throw new IllegalArgumentException("Invalid IP Address [" + ipAddressStr + "]", ex);
} catch (NumberFormatException ex) {
throw new IllegalArgumentException("Invalid IP Address [" + ipAddressStr + "]");
throw new IllegalArgumentException("Invalid IP Address [" + ipAddressStr + "]", ex);
}
return result;
@@ -226,7 +226,7 @@ public class IPRange {
// create the corresponding subnet decimal
extendedNetworkPrefix = computeNetworkPrefixFromMask(ipSubnetMask);
if (extendedNetworkPrefix == -1) {
throw new IllegalArgumentException("Invalid IP range [" + range + "]");
throw new IllegalArgumentException("Invalid IP range [" + range + "]", ex);
}
}
}