Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sonarQube fixes #599

Merged
merged 1 commit into from
Jan 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/main/java/com/microsoft/sqlserver/jdbc/DDC.java
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ static final Object convertFloatToObject(float floatVal,
return new BigDecimal(Float.toString(floatVal));
case FLOAT:
case DOUBLE:
return (new Float(floatVal)).doubleValue();
return ((Float)floatVal).doubleValue();
case BINARY:
return convertIntToBytes(Float.floatToRawIntBits(floatVal), 4);
default:
Expand Down Expand Up @@ -275,7 +275,7 @@ static final Object convertDoubleToObject(double doubleVal,
case DOUBLE:
return doubleVal;
case REAL:
return (new Double(doubleVal)).floatValue();
return ((Double)doubleVal).floatValue();
case INTEGER:
return (int) doubleVal;
case SMALLINT: // small and tinyint returned as short
Expand Down Expand Up @@ -439,7 +439,7 @@ private static byte[] convertToBytes(BigDecimal value,
}
}
int offset = numBytes - unscaledBytes.length;
System.arraycopy(unscaledBytes, offset - offset, ret, offset, numBytes - offset);
System.arraycopy(unscaledBytes, 0, ret, offset, numBytes - offset);
return ret;
}

Expand Down
19 changes: 7 additions & 12 deletions src/main/java/com/microsoft/sqlserver/jdbc/IOBuffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -1870,13 +1870,11 @@ private void validateFips(final String trustStoreType,

if (isEncryptOn && !isTrustServerCertificate) {
isValid = true;
if (isValidTrustStore) {
// In case of valid trust store we need to check TrustStoreType.
if (!isValidTrustStoreType) {
isValid = false;
if (logger.isLoggable(Level.FINER))
logger.finer(toString() + "TrustStoreType is required alongside with TrustStore.");
}
if (isValidTrustStore && !isValidTrustStoreType) {
// In case of valid trust store we need to check TrustStoreType.
isValid = false;
if (logger.isLoggable(Level.FINER))
logger.finer(toString() + "TrustStoreType is required alongside with TrustStore.");
}
}

Expand Down Expand Up @@ -2894,11 +2892,8 @@ void updateResult(Socket socket,
public void updateSelectedException(IOException ex,
String traceId) {
boolean updatedException = false;
if (selectedException == null) {
selectedException = ex;
updatedException = true;
}
else if ((!(ex instanceof SocketTimeoutException)) && (selectedException instanceof SocketTimeoutException)) {
if (selectedException == null ||
(!(ex instanceof SocketTimeoutException)) && (selectedException instanceof SocketTimeoutException)) {
selectedException = ex;
updatedException = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import java.time.OffsetTime;
import java.time.format.DateTimeFormatter;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1423,7 +1423,7 @@ Connection connectInternal(Properties propsIn,
sPropKey = SQLServerDriverIntProperty.STATEMENT_POOLING_CACHE_SIZE.toString();
if (activeConnectionProperties.getProperty(sPropKey) != null && activeConnectionProperties.getProperty(sPropKey).length() > 0) {
try {
int n = new Integer(activeConnectionProperties.getProperty(sPropKey));
int n = Integer.parseInt(activeConnectionProperties.getProperty(sPropKey));
this.setStatementPoolingCacheSize(n);
}
catch (NumberFormatException e) {
Expand Down Expand Up @@ -1560,7 +1560,7 @@ Connection connectInternal(Properties propsIn,
try {
String strPort = activeConnectionProperties.getProperty(sPropKey);
if (null != strPort) {
nPort = new Integer(strPort);
nPort = Integer.parseInt(strPort);

if ((nPort < 0) || (nPort > 65535)) {
MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_invalidPortNumber"));
Expand Down Expand Up @@ -1640,7 +1640,7 @@ else if (0 == requestedPacketSize)
nLockTimeout = defaultLockTimeOut; // Wait forever
if (activeConnectionProperties.getProperty(sPropKey) != null && activeConnectionProperties.getProperty(sPropKey).length() > 0) {
try {
int n = new Integer(activeConnectionProperties.getProperty(sPropKey));
int n = Integer.parseInt(activeConnectionProperties.getProperty(sPropKey));
if (n >= defaultLockTimeOut)
nLockTimeout = n;
else {
Expand All @@ -1661,7 +1661,7 @@ else if (0 == requestedPacketSize)
queryTimeoutSeconds = defaultQueryTimeout; // Wait forever
if (activeConnectionProperties.getProperty(sPropKey) != null && activeConnectionProperties.getProperty(sPropKey).length() > 0) {
try {
int n = new Integer(activeConnectionProperties.getProperty(sPropKey));
int n = Integer.parseInt(activeConnectionProperties.getProperty(sPropKey));
if (n >= defaultQueryTimeout) {
queryTimeoutSeconds = n;
}
Expand All @@ -1683,7 +1683,7 @@ else if (0 == requestedPacketSize)
socketTimeoutMilliseconds = defaultSocketTimeout; // Wait forever
if (activeConnectionProperties.getProperty(sPropKey) != null && activeConnectionProperties.getProperty(sPropKey).length() > 0) {
try {
int n = new Integer(activeConnectionProperties.getProperty(sPropKey));
int n = Integer.parseInt(activeConnectionProperties.getProperty(sPropKey));
if (n >= defaultSocketTimeout) {
socketTimeoutMilliseconds = n;
}
Expand All @@ -1703,7 +1703,7 @@ else if (0 == requestedPacketSize)
sPropKey = SQLServerDriverIntProperty.SERVER_PREPARED_STATEMENT_DISCARD_THRESHOLD.toString();
if (activeConnectionProperties.getProperty(sPropKey) != null && activeConnectionProperties.getProperty(sPropKey).length() > 0) {
try {
int n = new Integer(activeConnectionProperties.getProperty(sPropKey));
int n = Integer.parseInt(activeConnectionProperties.getProperty(sPropKey));
setServerPreparedStatementDiscardThreshold(n);
}
catch (NumberFormatException e) {
Expand Down Expand Up @@ -2164,7 +2164,7 @@ ServerPortPlaceHolder primaryPermissionCheck(String primary,
connectionlogger.fine(toString() + " SQL Server port returned by SQL Browser: " + instancePort);
try {
if (null != instancePort) {
primaryPortNumber = new Integer(instancePort);
primaryPortNumber = Integer.parseInt(instancePort);

if ((primaryPortNumber < 0) || (primaryPortNumber > 65535)) {
MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_invalidPortNumber"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -864,7 +864,7 @@ private void setIntProperty(Properties props,
int propValue) {
if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
loggerExternal.entering(getClassNameLogging(), "set" + propKey, propValue);
props.setProperty(propKey, new Integer(propValue).toString());
props.setProperty(propKey, ((Integer)propValue).toString());
loggerExternal.exiting(getClassNameLogging(), "set" + propKey);
}

Expand Down
Loading