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 analysis #300

Merged
merged 43 commits into from
May 25, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
8288738
"" is provided externally to the method and not sanitized before use.
xiangyushawn May 12, 2017
712d10d
fix "Change this comparison to use the equals method"
xiangyushawn May 12, 2017
44dc0bd
Replace the synchronized class "Vector" by an unsynchronized one such…
xiangyushawn May 12, 2017
97fb164
adding an if condition to check for whether WARNING level is enabled …
xiangyushawn May 12, 2017
cb5e4e0
End this switch case with an unconditional break
xiangyushawn May 12, 2017
c44f771
Remove this useless assignment to local variable
xiangyushawn May 12, 2017
bb688cb
Replace the synchronized class "StringBuffer" by an unsynchronized on…
xiangyushawn May 12, 2017
2c3887d
Remove useless assignment to local variable
xiangyushawn May 12, 2017
9b7e127
Strings literals should be placed on the left side when checking for …
xiangyushawn May 15, 2017
d23113b
Remove this useless assignment
xiangyushawn May 15, 2017
49b3c1a
Strings literals should be placed on the left side when checking for …
xiangyushawn May 15, 2017
6927d4b
merged cases with the same return value
xiangyushawn May 15, 2017
4e26788
Remove this useless assignment
xiangyushawn May 15, 2017
44ae05e
Remove useless assignment
xiangyushawn May 15, 2017
38845f0
make sonarqube happy
xiangyushawn May 15, 2017
bb5e044
change "&" to "&&"
xiangyushawn May 15, 2017
c57741a
Invoke method(s) only conditionally
xiangyushawn May 15, 2017
5011012
use StringBuilder
xiangyushawn May 15, 2017
e764723
make SonarQube happy
xiangyushawn May 15, 2017
82ddc53
re-interrupt thread
xiangyushawn May 15, 2017
ab9d1ac
make sonarQube happy
xiangyushawn May 15, 2017
e3c0d88
fix assertion
xiangyushawn May 15, 2017
09814d7
remove dead code
xiangyushawn May 15, 2017
2d1c7f1
Remove this useless assignment
xiangyushawn May 15, 2017
0ab8389
Remove this useless assignment
xiangyushawn May 15, 2017
76b7b1c
remove useless assignments
xiangyushawn May 15, 2017
4d5c6df
make sonarqube happy
xiangyushawn May 15, 2017
2e6f4b3
make sonarqube happy
xiangyushawn May 15, 2017
3783ef1
split StringBuilder
xiangyushawn May 16, 2017
3488829
refactor DLLException#buildMsgParams base on @sehrope 's code review
xiangyushawn May 16, 2017
c4d9439
fix some warnnings in IOBuffer.java base on SonarQube
xiangyushawn May 16, 2017
1bcc7d3
added `toString()` to `this`
xiangyushawn May 16, 2017
c5ba0c4
fixed KerbAuthentication.java
xiangyushawn May 16, 2017
4f2babf
fix KeyStoreProviderCommon.java and PLPInputStream.java
xiangyushawn May 16, 2017
b4415c6
fix Parameter.java
xiangyushawn May 16, 2017
83db1ee
fixed SQLServerAeadAes256CbcHmac256Factory.java and SQLServerBlob.java
xiangyushawn May 16, 2017
434dcc7
fixed SQLServerBulkCSVFileRecord.java and SQLServerBulkCopy.java
xiangyushawn May 17, 2017
70604d3
fixed SQLServerBulkCopy42Helper.java
xiangyushawn May 17, 2017
b77809f
fixed SQLServerCallableStatement.java and SQLServerClob.java and SQLS…
xiangyushawn May 17, 2017
7d51c35
fixed AE and SQLServerColumnEncryptionCertificateStoreProvider.java ,…
xiangyushawn May 17, 2017
e08cef1
roll back assertions
xiangyushawn May 17, 2017
078b097
fixed SQLServerConnection.java
xiangyushawn May 17, 2017
3fb2ce7
fixed SQLServerDataSource.java
xiangyushawn May 17, 2017
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
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