Skip to content

Commit

Permalink
Revert "Remove redundant if/else statements"
Browse files Browse the repository at this point in the history
  • Loading branch information
AfsanehR-zz authored Sep 22, 2017
1 parent 24dfd49 commit 139ea00
Show file tree
Hide file tree
Showing 14 changed files with 70 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,12 @@ public final class SQLServerColumnEncryptionCertificateStoreProvider extends SQL
static final String myCertificateStore = "My";

static {
isWindows = System.getProperty("os.name").toLowerCase(Locale.ENGLISH).startsWith("windows");
if (System.getProperty("os.name").toLowerCase(Locale.ENGLISH).startsWith("windows")) {
isWindows = true;
}
else {
isWindows = false;
}
}
private Path keyStoreDirectoryPath = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1968,7 +1968,10 @@ else if (name.equals(SQLServerDriverIntProperty.PORT_NUMBER.toString())) {
case ResultSet.TYPE_SCROLL_INSENSITIVE:
// case SQLServerResultSet.TYPE_SS_SCROLL_STATIC: sensitive synonym
case SQLServerResultSet.TYPE_SS_DIRECT_FORWARD_ONLY:
return ResultSet.CONCUR_READ_ONLY == concurrency;
if (ResultSet.CONCUR_READ_ONLY == concurrency)
return true;
else
return false;
}
// per spec if we do not know we do not support.
return false;
Expand All @@ -1977,48 +1980,60 @@ else if (name.equals(SQLServerDriverIntProperty.PORT_NUMBER.toString())) {
/* L0 */ public boolean ownUpdatesAreVisible(int type) throws SQLServerException {
checkClosed();
checkResultType(type);
return type == SQLServerResultSet.TYPE_SS_SCROLL_DYNAMIC || SQLServerResultSet.TYPE_FORWARD_ONLY == type
if (type == SQLServerResultSet.TYPE_SS_SCROLL_DYNAMIC || SQLServerResultSet.TYPE_FORWARD_ONLY == type
|| SQLServerResultSet.TYPE_SCROLL_SENSITIVE == type || SQLServerResultSet.TYPE_SS_SCROLL_KEYSET == type
|| SQLServerResultSet.TYPE_SS_SERVER_CURSOR_FORWARD_ONLY == type;
|| SQLServerResultSet.TYPE_SS_SERVER_CURSOR_FORWARD_ONLY == type)
return true;
return false;
}

/* L0 */ public boolean ownDeletesAreVisible(int type) throws SQLServerException {
checkClosed();
checkResultType(type);
return type == SQLServerResultSet.TYPE_SS_SCROLL_DYNAMIC || SQLServerResultSet.TYPE_FORWARD_ONLY == type
if (type == SQLServerResultSet.TYPE_SS_SCROLL_DYNAMIC || SQLServerResultSet.TYPE_FORWARD_ONLY == type
|| SQLServerResultSet.TYPE_SCROLL_SENSITIVE == type || SQLServerResultSet.TYPE_SS_SCROLL_KEYSET == type
|| SQLServerResultSet.TYPE_SS_SERVER_CURSOR_FORWARD_ONLY == type;
|| SQLServerResultSet.TYPE_SS_SERVER_CURSOR_FORWARD_ONLY == type)
return true;
return false;
}

/* L0 */ public boolean ownInsertsAreVisible(int type) throws SQLServerException {
checkClosed();
checkResultType(type);
return type == SQLServerResultSet.TYPE_SS_SCROLL_DYNAMIC || SQLServerResultSet.TYPE_FORWARD_ONLY == type
if (type == SQLServerResultSet.TYPE_SS_SCROLL_DYNAMIC || SQLServerResultSet.TYPE_FORWARD_ONLY == type
|| SQLServerResultSet.TYPE_SCROLL_SENSITIVE == type || SQLServerResultSet.TYPE_SS_SCROLL_KEYSET == type
|| SQLServerResultSet.TYPE_SS_SERVER_CURSOR_FORWARD_ONLY == type;
|| SQLServerResultSet.TYPE_SS_SERVER_CURSOR_FORWARD_ONLY == type)
return true;
return false;
}

/* L0 */ public boolean othersUpdatesAreVisible(int type) throws SQLServerException {
checkClosed();
checkResultType(type);
return type == SQLServerResultSet.TYPE_SS_SCROLL_DYNAMIC || SQLServerResultSet.TYPE_FORWARD_ONLY == type
if (type == SQLServerResultSet.TYPE_SS_SCROLL_DYNAMIC || SQLServerResultSet.TYPE_FORWARD_ONLY == type
|| SQLServerResultSet.TYPE_SCROLL_SENSITIVE == type || SQLServerResultSet.TYPE_SS_SCROLL_KEYSET == type
|| SQLServerResultSet.TYPE_SS_SERVER_CURSOR_FORWARD_ONLY == type;
|| SQLServerResultSet.TYPE_SS_SERVER_CURSOR_FORWARD_ONLY == type)
return true;
return false;
}

/* L0 */ public boolean othersDeletesAreVisible(int type) throws SQLServerException {
checkClosed();
checkResultType(type);
return type == SQLServerResultSet.TYPE_SS_SCROLL_DYNAMIC || SQLServerResultSet.TYPE_FORWARD_ONLY == type
if (type == SQLServerResultSet.TYPE_SS_SCROLL_DYNAMIC || SQLServerResultSet.TYPE_FORWARD_ONLY == type
|| SQLServerResultSet.TYPE_SCROLL_SENSITIVE == type || SQLServerResultSet.TYPE_SS_SCROLL_KEYSET == type
|| SQLServerResultSet.TYPE_SS_SERVER_CURSOR_FORWARD_ONLY == type;
|| SQLServerResultSet.TYPE_SS_SERVER_CURSOR_FORWARD_ONLY == type)
return true;
return false;
}

/* L0 */ public boolean othersInsertsAreVisible(int type) throws SQLServerException {
checkClosed();
checkResultType(type);
return type == SQLServerResultSet.TYPE_SS_SCROLL_DYNAMIC || SQLServerResultSet.TYPE_FORWARD_ONLY == type
|| SQLServerResultSet.TYPE_SS_SERVER_CURSOR_FORWARD_ONLY == type;
if (type == SQLServerResultSet.TYPE_SS_SCROLL_DYNAMIC || SQLServerResultSet.TYPE_FORWARD_ONLY == type
|| SQLServerResultSet.TYPE_SS_SERVER_CURSOR_FORWARD_ONLY == type)
return true;
return false;
}

/* L0 */ public boolean updatesAreDetected(int type) throws SQLServerException {
Expand All @@ -2030,7 +2045,10 @@ else if (name.equals(SQLServerDriverIntProperty.PORT_NUMBER.toString())) {
/* L0 */ public boolean deletesAreDetected(int type) throws SQLServerException {
checkClosed();
checkResultType(type);
return SQLServerResultSet.TYPE_SS_SCROLL_KEYSET == type;
if (SQLServerResultSet.TYPE_SS_SCROLL_KEYSET == type)
return true;
else
return false;
}

// Check the result types to make sure the user does not pass a bad value.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,12 @@ private void checkClosed() throws SQLServerException {
rsProcedureMeta = s.executeQueryInternal("exec sp_sproc_columns " + sProc + ", @ODBCVer=3");

// if rsProcedureMeta has next row, it means the stored procedure is found
procedureIsFound = rsProcedureMeta.next();
if (rsProcedureMeta.next()) {
procedureIsFound = true;
}
else {
procedureIsFound = false;
}
rsProcedureMeta.beforeFirst();

// Sixth is DATA_TYPE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6280,7 +6280,8 @@ boolean onRow(TDSReader tdsReader) throws SQLServerException {

// Consume the ROW token, leaving tdsReader at the start of
// this row's column values.
assert TDS.TDS_ROW == tdsReader.readUnsignedByte();
if (TDS.TDS_ROW != tdsReader.readUnsignedByte())
assert false;
fetchBufferCurrentRowType = RowType.ROW;
return false;
}
Expand All @@ -6290,7 +6291,8 @@ boolean onNBCRow(TDSReader tdsReader) throws SQLServerException {

// Consume the NBCROW token, leaving tdsReader at the start of
// nullbitmap.
assert TDS.TDS_NBCROW == tdsReader.readUnsignedByte();
if (TDS.TDS_NBCROW != tdsReader.readUnsignedByte())
assert false;

fetchBufferCurrentRowType = RowType.NBCROW;
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ final class StreamColInfo extends StreamPacket {
}

void setFromTDS(TDSReader tdsReader) throws SQLServerException {
assert TDS.TDS_COLINFO == tdsReader.readUnsignedByte() : "Not a COLINFO token";
if (TDS.TDS_COLINFO != tdsReader.readUnsignedByte())
assert false : "Not a COLINFO token";

this.tdsReader = tdsReader;
int tokenLength = tdsReader.readUnsignedShort();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ CryptoMetadata readCryptoMetadata(TDSReader tdsReader) throws SQLServerException
* @throws SQLServerException
*/
void setFromTDS(TDSReader tdsReader) throws SQLServerException {
assert TDS.TDS_COLMETADATA == tdsReader.readUnsignedByte();
if (TDS.TDS_COLMETADATA != tdsReader.readUnsignedByte())
assert false;

int nTotColumns = tdsReader.readUnsignedShort();

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/microsoft/sqlserver/jdbc/StreamError.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ final int getErrorSeverity() {
}

void setFromTDS(TDSReader tdsReader) throws SQLServerException {
assert TDS.TDS_ERR == tdsReader.readUnsignedByte();
if (TDS.TDS_ERR != tdsReader.readUnsignedByte())
assert false;
setContentsFromTDS(tdsReader);
}

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/microsoft/sqlserver/jdbc/StreamInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ final class StreamInfo extends StreamPacket {
}

void setFromTDS(TDSReader tdsReader) throws SQLServerException {
assert TDS.TDS_MSG == tdsReader.readUnsignedByte();
if (TDS.TDS_MSG != tdsReader.readUnsignedByte())
assert false;
msg.setContentsFromTDS(tdsReader);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ final class StreamLoginAck extends StreamPacket {
}

void setFromTDS(TDSReader tdsReader) throws SQLServerException {
assert TDS.TDS_LOGIN_ACK == tdsReader.readUnsignedByte();
if (TDS.TDS_LOGIN_ACK != tdsReader.readUnsignedByte())
assert false;
tdsReader.readUnsignedShort(); // length of this token stream
tdsReader.readUnsignedByte(); // SQL version accepted by the server
tdsVersion = tdsReader.readIntBigEndian(); // TDS version accepted by the server
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ final int getStatus() {
}

void setFromTDS(TDSReader tdsReader) throws SQLServerException {
assert TDS.TDS_RET_STAT == tdsReader.readUnsignedByte();
if (TDS.TDS_RET_STAT != tdsReader.readUnsignedByte())
assert false;
status = tdsReader.readInt();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ final int getOrdinalOrLength() {
}

void setFromTDS(TDSReader tdsReader) throws SQLServerException {
assert TDS.TDS_RETURN_VALUE == tdsReader.readUnsignedByte();
if (TDS.TDS_RETURN_VALUE != tdsReader.readUnsignedByte())
assert false;
ordinalOrLength = tdsReader.readUnsignedShort();
paramName = tdsReader.readUnicodeString(tdsReader.readUnsignedByte());
status = tdsReader.readUnsignedByte();
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/microsoft/sqlserver/jdbc/StreamSSPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ final class StreamSSPI extends StreamPacket {
}

void setFromTDS(TDSReader tdsReader) throws SQLServerException {
assert TDS.TDS_SSPI == tdsReader.readUnsignedByte();
if (TDS.TDS_SSPI != tdsReader.readUnsignedByte())
assert false;
int blobLength = tdsReader.readUnsignedShort();
sspiBlob = new byte[blobLength];
tdsReader.readBytes(sspiBlob, 0, blobLength);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ final class StreamTabName extends StreamPacket {
}

void setFromTDS(TDSReader tdsReader) throws SQLServerException {
assert TDS.TDS_TABNAME == tdsReader.readUnsignedByte() : "Not a TABNAME token";
if (TDS.TDS_TABNAME != tdsReader.readUnsignedByte())
assert false : "Not a TABNAME token";

this.tdsReader = tdsReader;
int tokenLength = tdsReader.readUnsignedShort();
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/com/microsoft/sqlserver/jdbc/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,10 @@ static final String readGUID(byte[] inputGUID) throws SQLServerException {
static boolean IsActivityTraceOn() {
LogManager lm = LogManager.getLogManager();
String activityTrace = lm.getProperty(ActivityIdTraceProperty);
return "on".equalsIgnoreCase(activityTrace);
if ("on".equalsIgnoreCase(activityTrace))
return true;
else
return false;
}

/**
Expand Down

0 comments on commit 139ea00

Please sign in to comment.