Skip to content

Commit

Permalink
Fix | Review comment changes
Browse files Browse the repository at this point in the history
  • Loading branch information
cheenamalhotra committed Jun 18, 2018
1 parent 6a7da23 commit 29e33c5
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 41 deletions.
7 changes: 3 additions & 4 deletions src/main/java/com/microsoft/sqlserver/jdbc/IOBuffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -6396,8 +6396,8 @@ final SQLServerConnection getConnection() {
private final byte valueBytes[] = new byte[256];

protected SensitivityClassification sensitivityClassification;
private static final AtomicInteger lastReaderID = new AtomicInteger(0);

private static final AtomicInteger lastReaderID = new AtomicInteger(0);

private static int nextReaderID() {
return lastReaderID.incrementAndGet();
Expand Down Expand Up @@ -7139,9 +7139,8 @@ final void tryProcessFeatureExtAck(boolean featureExtAckReceived) throws SQLServ
throw new SQLServerException(this, SQLServerException.getErrString("R_AE_NotSupportedByServer"), null, 0, false);
}

boolean trySetSensitivityClassification(SensitivityClassification sensitivityClassification) {
final void trySetSensitivityClassification(SensitivityClassification sensitivityClassification) {
this.sensitivityClassification = sensitivityClassification;
return true;
}
}

Expand Down
40 changes: 17 additions & 23 deletions src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ boolean getServerSupportsColumnEncryption() {
}

private boolean serverSupportsDataClassification = false;

boolean getServerSupportsDataClassification() {
return serverSupportsDataClassification;
}
Expand Down Expand Up @@ -3437,15 +3437,15 @@ int writeFedAuthFeatureRequest(boolean write,
return totalLen;
}

int writeDataClassificationFeatureRequest (boolean write /* if false just calculates the length */,
TDSWriter tdsWriter) throws SQLServerException {
int writeDataClassificationFeatureRequest(boolean write /* if false just calculates the length */,
TDSWriter tdsWriter) throws SQLServerException {
int len = 6; // 1byte = featureID, 4bytes = featureData length, 1 bytes = Version

if (write) {
// Write Feature ID, length of the version# field and Sensitivity Classification Version#
tdsWriter.writeByte(TDS.TDS_FEATURE_EXT_DATACLASSIFICATION);
tdsWriter.writeInt(1);
tdsWriter.writeByte(TDS.MAX_SUPPORTED_DATA_CLASSIFICATION_VERSION);
tdsWriter.writeByte(TDS.TDS_FEATURE_EXT_DATACLASSIFICATION);
tdsWriter.writeInt(1);
tdsWriter.writeByte(TDS.MAX_SUPPORTED_DATA_CLASSIFICATION_VERSION);
}
return len; // size of data written
}
Expand Down Expand Up @@ -4148,32 +4148,26 @@ private void onFeatureExtAck(byte featureId,
break;
}
case TDS.TDS_FEATURE_EXT_DATACLASSIFICATION: {
if (connectionlogger.isLoggable(Level.FINER)) {
if (connectionlogger.isLoggable(Level.FINER)) {
connectionlogger.fine(toString() + " Received feature extension acknowledgement for Data Classification.");
}

if (1 > data.length) {
if (connectionlogger.isLoggable(Level.SEVERE)) {
if (2 != data.length) {
if (connectionlogger.isLoggable(Level.SEVERE)) {
connectionlogger.severe(toString() + " Unknown token for Data Classification.");
}
throw new SQLServerException(SQLServerException.getErrString("R_UnknownDataClsTokenNumber"), null);
}

byte supportedDataClassificationVersion = data[0];
if ((0 == supportedDataClassificationVersion) || (supportedDataClassificationVersion > TDS.MAX_SUPPORTED_DATA_CLASSIFICATION_VERSION)) {
if (connectionlogger.isLoggable(Level.SEVERE)) {
if ((0 == supportedDataClassificationVersion)
|| (supportedDataClassificationVersion > TDS.MAX_SUPPORTED_DATA_CLASSIFICATION_VERSION)) {
if (connectionlogger.isLoggable(Level.SEVERE)) {
connectionlogger.severe(toString() + " Invalid version number for Data Classification");
}
throw new SQLServerException(SQLServerException.getErrString("R_InvalidDataClsVersionNumber"), null);
}

if (data.length != 2) {
if (connectionlogger.isLoggable(Level.SEVERE)) {
connectionlogger.severe(toString() + " Unknown token for Data Classification");
}
throw new SQLServerException(SQLServerException.getErrString("R_UnknownDataClsTokenNumber"), null);
}

byte enabled = data[1];
serverSupportsDataClassification = (enabled == 0) ? false : true;
break;
Expand Down Expand Up @@ -4463,8 +4457,8 @@ else if (serverMajorVersion >= 9) // Yukon (9.0) --> TDS 7.2 // Prelogin disconn
if (federatedAuthenticationInfoRequested || federatedAuthenticationRequested) {
len2 = len2 + writeFedAuthFeatureRequest(false, tdsWriter, fedAuthFeatureExtensionData);
}
//Data Classification is always enabled (by default)


// Data Classification is always enabled (by default)
len2 += writeDataClassificationFeatureRequest(false, tdsWriter);

len2 = len2 + 1; // add 1 to length because of FeatureEx terminator
Expand Down Expand Up @@ -4647,9 +4641,9 @@ else if (serverMajorVersion >= 9) // Yukon (9.0) --> TDS 7.2 // Prelogin disconn
if (federatedAuthenticationInfoRequested || federatedAuthenticationRequested) {
writeFedAuthFeatureRequest(true, tdsWriter, fedAuthFeatureExtensionData);
}

writeDataClassificationFeatureRequest(true, tdsWriter);

tdsWriter.writeByte((byte) TDS.FEATURE_EXT_TERMINATOR);
tdsWriter.setDataLoggable(true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ public final class SQLServerException extends java.sql.SQLException {
static final int DRIVER_ERROR_INTERMITTENT_TLS_FAILED = 7;
static final int ERROR_SOCKET_TIMEOUT = 8;
static final int ERROR_QUERY_TIMEOUT = 9;
static final int DataClassificationInvalidVersion = 24;
static final int DataClassificationNotExpected = 25;
static final int DataClassificationInvalidLabelIndex = 26;
static final int DataClassificationInvalidInformationTypeIndex = 27;
static final int DATA_CLASSIFICATION_INVALID_VERSION = 24;
static final int DATA_CLASSIFICATION_NOT_EXPECTED = 25;
static final int DATA_CLASSIFICATION_INVALID_LABEL_INDEX = 26;
static final int DATA_CLASSIFICATION_INVALID_INFORMATION_TYPE_INDEX = 27;

private int driverErrorCode = DRIVER_ERROR_NONE;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,20 +216,20 @@ protected TDSReader getTDSReader() {
private final FetchBuffer fetchBuffer;

/**
* Exposes Data Classification information for the current ResultSet
* For SQL Servers that do not support Data Classification or results that do not fetch any classified columns, this data can be null
* Exposes Data Classification information for the current ResultSet For SQL Servers that do not support Data Classification or results that do
* not fetch any classified columns, this data can be null
*
* @return SensitivityClassification
*/
public SensitivityClassification getSensitivityClassification() {
return tdsReader.sensitivityClassification;
return tdsReader.sensitivityClassification;
}

/**
* Make a new result set
*
* @param stmtIn
* the generating statement
* the generating statement
*/
SQLServerResultSet(SQLServerStatement stmtIn) throws SQLServerException {
int resultSetID = nextResultSetID();
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/com/microsoft/sqlserver/jdbc/StreamColumns.java
Original file line number Diff line number Diff line change
Expand Up @@ -230,10 +230,8 @@ void setFromTDS(TDSReader tdsReader) throws SQLServerException {

private String readByteString(TDSReader tdsReader) throws SQLServerException {
String value = "";

int byteLen = (int) tdsReader.readUnsignedByte();
value = tdsReader.readUnicodeString(byteLen);

return value;
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/microsoft/sqlserver/jdbc/tdsparser.java
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ final StreamError getDatabaseError() {
return databaseError;
}

TDSTokenHandler(String logContext) {
TDSTokenHandler(String logContext) {
this.logContext = logContext;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/*
* Microsoft JDBC Driver for SQL Server
*
* Copyright(c) Microsoft Corporation All rights reserved.
*
* This program is made available under the terms of the MIT License. See the LICENSE file in the project root for more information.
*/
package com.microsoft.sqlserver.jdbc.resultset;

import java.sql.Connection;
Expand Down Expand Up @@ -42,7 +49,6 @@ public void testDataClassificationMetadata() throws Exception {
*
* @param connection
* @param stmt
* @param tableName
* @throws SQLException
*/
private void createTable(Connection connection,
Expand Down Expand Up @@ -98,7 +104,6 @@ private void createTable(Connection connection,
* Selects data from the table and triggers verifySensitivityClassification method
*
* @param stmt
* @param queries
* @throws Exception
*/
private void runTestsForServer(Statement stmt) throws Exception {
Expand All @@ -108,7 +113,7 @@ private void runTestsForServer(Statement stmt) throws Exception {
}

/**
* Verifies resultset recieved to contain data classification information as set.
* Verifies resultset received to contain data classification information as set.
*
* @param rs
* @throws SQLException
Expand Down

0 comments on commit 29e33c5

Please sign in to comment.