Skip to content

Commit

Permalink
Merge pull request #300 from v-xiangs/SonarQubeAnalysis
Browse files Browse the repository at this point in the history
SonarQube analysis
  • Loading branch information
xiangyushawn authored May 25, 2017
2 parents 5718b5b + 3fb2ce7 commit d2fd9c4
Show file tree
Hide file tree
Showing 25 changed files with 312 additions and 220 deletions.
11 changes: 6 additions & 5 deletions src/main/java/com/microsoft/sqlserver/jdbc/AE.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

package com.microsoft.sqlserver.jdbc;

import java.util.Vector;
import java.util.ArrayList;
import java.util.List;

/**
* Represents a single encrypted value for a CEK. It contains the encrypted CEK,the store type, name,the key path and encryption algorithm.
Expand Down Expand Up @@ -45,19 +46,19 @@ class EncryptionKeyInfo {

/**
* Represents a unique CEK as an entry in the CekTable. A unique (plaintext is unique) CEK can have multiple encrypted CEKs when using multiple CMKs.
* These encrypted CEKs are represented by a member vector.
* These encrypted CEKs are represented by a member ArrayList.
*/
class CekTableEntry {
static final private java.util.logging.Logger aeLogger = java.util.logging.Logger.getLogger("com.microsoft.sqlserver.jdbc.AE");

Vector<EncryptionKeyInfo> columnEncryptionKeyValues;
List<EncryptionKeyInfo> columnEncryptionKeyValues;
int ordinal;
int databaseId;
int cekId;
int cekVersion;
byte[] cekMdVersion;

Vector<EncryptionKeyInfo> getColumnEncryptionKeyValues() {
List<EncryptionKeyInfo> getColumnEncryptionKeyValues() {
return columnEncryptionKeyValues;
}

Expand Down Expand Up @@ -87,7 +88,7 @@ byte[] getCekMdVersion() {
cekId = 0;
cekVersion = 0;
cekMdVersion = null;
columnEncryptionKeyValues = new Vector<EncryptionKeyInfo>();
columnEncryptionKeyValues = new ArrayList<EncryptionKeyInfo>();
}

int getSize() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

package com.microsoft.sqlserver.jdbc;

import java.util.logging.Level;

class FedAuthDllInfo {
byte[] accessTokenBytes = null;
long expiresIn = 0;
Expand Down Expand Up @@ -102,7 +104,9 @@ byte[] GenerateClientContext(byte[] pin,
int failure = SNISecGenClientContext(sniSec, sniSecLen, pin, pin.length, pOut, outsize, done, DNSName, port, null, null, authLogger);

if (failure != 0) {
authLogger.warning(toString() + " Authentication failed code : " + failure);
if (authLogger.isLoggable(Level.WARNING)) {
authLogger.warning(toString() + " Authentication failed code : " + failure);
}
con.terminate(SQLServerException.DRIVER_ERROR_NONE, SQLServerException.getErrString("R_integratedAuthenticationFailed"), linkError);
}
// allocate space based on the size returned
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/microsoft/sqlserver/jdbc/Column.java
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,7 @@ else if (SSType.SMALLDATETIME == basicSSType)
return JDBCType.GUID;
if (SSType.VARCHARMAX == basicSSType)
return JDBCType.LONGVARCHAR;
return jdbcType;

default:
return jdbcType;
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/microsoft/sqlserver/jdbc/DDC.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ static final Object convertLongToObject(long longVal,
return new Float(longVal);
case BINARY:
byte[] convertedBytes = convertLongToBytes(longVal);
int bytesToReturnLength = 0;
int bytesToReturnLength;
byte[] bytesToReturn;

switch (baseSSType) {
Expand Down Expand Up @@ -467,7 +467,7 @@ static final Object convertBytesToObject(byte[] bytesValue,

if ((SSType.BINARY == baseTypeInfo.getSSType()) && (str.length() < (baseTypeInfo.getPrecision() * 2))) {

StringBuffer strbuf = new StringBuffer(str);
StringBuilder strbuf = new StringBuilder(str);

while (strbuf.length() < (baseTypeInfo.getPrecision() * 2)) {
strbuf.append('0');
Expand Down Expand Up @@ -781,7 +781,7 @@ static final Object convertTemporalToObject(JDBCType jdbcType,
// For other data types, the date and time parts are assumed to be relative to the local time zone.
TimeZone componentTimeZone = (SSType.DATETIMEOFFSET == ssType) ? UTC.timeZone : localTimeZone;

int subSecondNanos = 0;
int subSecondNanos;

// The date and time parts assume a Gregorian calendar with Gregorian leap year behavior
// over the entire supported range of values. Create and initialize such a calendar to
Expand Down Expand Up @@ -909,7 +909,7 @@ static final Object convertTemporalToObject(JDBCType jdbcType,
default:
throw new AssertionError("Unexpected SSType: " + ssType);
}
int localMillisOffset = 0;
int localMillisOffset;
if (null == timeZoneCalendar) {
TimeZone tz = TimeZone.getDefault();
GregorianCalendar _cal = new GregorianCalendar(componentTimeZone, Locale.US);
Expand Down
20 changes: 10 additions & 10 deletions src/main/java/com/microsoft/sqlserver/jdbc/DLLException.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,40 +88,40 @@ static void buildException(int errCode,
String errMessage = getErrMessage(errCode);
MessageFormat form = new MessageFormat(SQLServerException.getErrString(errMessage));

Object[] msgArgs = {null, null, null};

buildMsgParams(errMessage, msgArgs, param1, param2, param3);
String[] msgArgs = buildMsgParams(errMessage, param1, param2, param3);

throw new SQLServerException(null, form.format(msgArgs), null, 0, false);
}

private static void buildMsgParams(String errMessage,
Object[] msgArgs,
private static String[] buildMsgParams(String errMessage,
String parameter1,
String parameter2,
String parameter3) {

if (errMessage.equalsIgnoreCase("R_AECertLocBad")) {
String[] msgArgs = new String[3];

if ("R_AECertLocBad".equalsIgnoreCase(errMessage)) {
msgArgs[0] = parameter1;
msgArgs[1] = parameter1 + "/" + parameter2 + "/" + parameter3;
}
else if (errMessage.equalsIgnoreCase("R_AECertStoreBad")) {
else if ("R_AECertStoreBad".equalsIgnoreCase(errMessage)) {
msgArgs[0] = parameter2;
msgArgs[1] = parameter1 + "/" + parameter2 + "/" + parameter3;
}
else if (errMessage.equalsIgnoreCase("R_AECertHashEmpty")) {
else if ("R_AECertHashEmpty".equalsIgnoreCase(errMessage)) {
msgArgs[0] = parameter1 + "/" + parameter2 + "/" + parameter3;

}
else {
msgArgs[0] = parameter1;
msgArgs[1] = parameter2;
msgArgs[2] = parameter3;
}

return msgArgs;
}

private static String getErrMessage(int errCode) {
String message = null;
String message;
switch (errCode) {
case 1:
message = "R_AEKeypathEmpty";
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/com/microsoft/sqlserver/jdbc/DataTypes.java
Original file line number Diff line number Diff line change
Expand Up @@ -1379,20 +1379,19 @@ boolean isUnsupported() {
* JDBC3 types are expected for SE 5. JDBC4 types are expected for SE 6 and later.
*/
int asJavaSqlType() {
if (Util.SYSTEM_SPEC_VERSION.equals("1.5")) {
if ("1.5".equals(Util.SYSTEM_SPEC_VERSION)) {
switch (this) {
case NCHAR:
return java.sql.Types.CHAR;
case NVARCHAR:
case SQLXML:
return java.sql.Types.VARCHAR;
case LONGNVARCHAR:
return java.sql.Types.LONGVARCHAR;
case NCLOB:
return java.sql.Types.CLOB;
case ROWID:
return java.sql.Types.OTHER;
case SQLXML:
return java.sql.Types.VARCHAR;
default:
return intValue;
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/microsoft/sqlserver/jdbc/FailOverInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ private void setupInfo(SQLServerConnection con) throws SQLServerException {
else {
// 3.3006 get the instance name
int px = failoverPartner.indexOf('\\');
String instancePort = null;
String instanceValue = null;
String instancePort;
String instanceValue;

// found the instance name with the severname
if (px >= 0) {
Expand Down
Loading

0 comments on commit d2fd9c4

Please sign in to comment.