diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/Column.java b/src/main/java/com/microsoft/sqlserver/jdbc/Column.java index 20453b2b7..fdd71facb 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/Column.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/Column.java @@ -214,7 +214,7 @@ void updateValue(JDBCType jdbcType, Object value, JavaType javaType, StreamSette if (JDBCType.TINYINT == cryptoMetadata.getBaseTypeInfo().getSSType().getJDBCType() && javaType == JavaType.SHORT) { if (value instanceof Boolean) { - if (true == ((boolean) value)) { + if ((boolean) value) { value = 1; } else { value = 0; @@ -251,7 +251,7 @@ else if (jdbcType.isBinary()) { } if (Util.shouldHonorAEForParameters(stmtColumnEncriptionSetting, con)) { - if ((null == cryptoMetadata) && true == forceEncrypt) { + if ((null == cryptoMetadata) && forceEncrypt) { MessageFormat form = new MessageFormat( SQLServerException.getErrString("R_ForceEncryptionTrue_HonorAETrue_UnencryptedColumnRS")); Object[] msgArgs = {parameterIndex}; @@ -273,7 +273,7 @@ else if (jdbcType.isBinary()) { } } } else { - if (true == forceEncrypt) { + if (forceEncrypt) { MessageFormat form = new MessageFormat( SQLServerException.getErrString("R_ForceEncryptionTrue_HonorAEFalseRS")); Object[] msgArgs = {parameterIndex}; diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/FailOverMapSingleton.java b/src/main/java/com/microsoft/sqlserver/jdbc/FailOverMapSingleton.java index c0936b09c..c87beb042 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/FailOverMapSingleton.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/FailOverMapSingleton.java @@ -31,7 +31,7 @@ private static String concatPrimaryDatabase(String primary, String instance, Str static FailoverInfo getFailoverInfo(SQLServerConnection connection, String primaryServer, String instance, String database) { synchronized (FailoverMapSingleton.class) { - if (true == failoverMap.isEmpty()) { + if (failoverMap.isEmpty()) { return null; } else { String mapKey = concatPrimaryDatabase(primaryServer, instance, database); diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/IOBuffer.java b/src/main/java/com/microsoft/sqlserver/jdbc/IOBuffer.java index 0cabb2936..088cf0301 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/IOBuffer.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/IOBuffer.java @@ -2473,7 +2473,7 @@ private void findSocketUsingJavaNIO(InetAddress[] inetAddrs, int portNumber, // ch.finishConnect should either return true or throw an exception // as we have subscribed for OP_CONNECT. - assert connected == true : "finishConnect on channel:" + ch + " cannot be false"; + assert connected : "finishConnect on channel:" + ch + " cannot be false"; selectedChannel = ch; diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/Parameter.java b/src/main/java/com/microsoft/sqlserver/jdbc/Parameter.java index 6e8e0a2da..f1e0295d2 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/Parameter.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/Parameter.java @@ -296,7 +296,7 @@ void setValue(JDBCType jdbcType, Object value, JavaType javaType, StreamSetterAr } // forceEncryption is true, shouldhonorae is false - if ((true == forceEncrypt) && (false == Util.shouldHonorAEForParameters(stmtColumnEncriptionSetting, con))) { + if (forceEncrypt && !Util.shouldHonorAEForParameters(stmtColumnEncriptionSetting, con)) { MessageFormat form = new MessageFormat( SQLServerException.getErrString("R_ForceEncryptionTrue_HonorAEFalse")); diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCopy.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCopy.java index 068e40011..3675e702c 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCopy.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCopy.java @@ -770,7 +770,7 @@ private void writeColumnMetaDataColumnData(TDSWriter tdsWriter, int idx) throws // the driver will not sent AE information, so, we need to set Encryption bit flag to 0. if (null == srcColumnMetadata.get(srcColumnIndex).cryptoMeta && null == destColumnMetadata.get(destColumnIndex).cryptoMeta - && true == copyOptions.isAllowEncryptedValueModifications()) { + && copyOptions.isAllowEncryptedValueModifications()) { // flags[1]>>3 & 0x01 is the encryption bit flag. // it is the 4th least significant bit in this byte, so minus 8 to set it to 0. @@ -1477,15 +1477,15 @@ private String createInsertBulkCommand(TDSWriter tdsWriter) throws SQLServerExce } } - if (true == copyOptions.isCheckConstraints()) { + if (copyOptions.isCheckConstraints()) { bulkOptions.add("CHECK_CONSTRAINTS"); } - if (true == copyOptions.isFireTriggers()) { + if (copyOptions.isFireTriggers()) { bulkOptions.add("FIRE_TRIGGERS"); } - if (true == copyOptions.isKeepNulls()) { + if (copyOptions.isKeepNulls()) { bulkOptions.add("KEEP_NULLS"); } @@ -1493,11 +1493,11 @@ private String createInsertBulkCommand(TDSWriter tdsWriter) throws SQLServerExce bulkOptions.add("ROWS_PER_BATCH = " + copyOptions.getBatchSize()); } - if (true == copyOptions.isTableLock()) { + if (copyOptions.isTableLock()) { bulkOptions.add("TABLOCK"); } - if (true == copyOptions.isAllowEncryptedValueModifications()) { + if (copyOptions.isAllowEncryptedValueModifications()) { bulkOptions.add("ALLOW_ENCRYPTED_VALUE_MODIFICATIONS"); } diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java index 0ba3f48d3..4340188ec 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java @@ -1324,7 +1324,7 @@ Connection connectInternal(Properties propsIn, } trustedServerNameAE = sPropValue; - if (true == serverNameAsACE) { + if (serverNameAsACE) { try { sPropValue = java.net.IDN.toASCII(sPropValue); } catch (IllegalArgumentException ex) { @@ -1529,8 +1529,8 @@ Connection connectInternal(Properties propsIn, } authenticationString = SqlAuthentication.valueOfString(sPropValue).toString(); - if ((true == integratedSecurity) - && (!authenticationString.equalsIgnoreCase(SqlAuthentication.NotSpecified.toString()))) { + if (integratedSecurity + && !authenticationString.equalsIgnoreCase(SqlAuthentication.NotSpecified.toString())) { if (connectionlogger.isLoggable(Level.SEVERE)) { connectionlogger.severe(toString() + " " + SQLServerException.getErrString("R_SetAuthenticationWhenIntegratedSecurityTrue")); @@ -1591,7 +1591,7 @@ Connection connectInternal(Properties propsIn, throw new SQLServerException(SQLServerException.getErrString("R_AccessTokenCannotBeEmpty"), null); } - if ((true == integratedSecurity) && (null != accessTokenInByte)) { + if (integratedSecurity && (null != accessTokenInByte)) { if (connectionlogger.isLoggable(Level.SEVERE)) { connectionlogger.severe(toString() + " " + SQLServerException.getErrString("R_SetAccesstokenWhenIntegratedSecurityTrue")); @@ -2983,7 +2983,7 @@ String sqlStatementToSetTransactionIsolationLevel() throws SQLServerException { * @return the required syntax */ static String sqlStatementToSetCommit(boolean autoCommit) { - return (true == autoCommit) ? "set implicit_transactions off " : "set implicit_transactions on "; + return autoCommit ? "set implicit_transactions off " : "set implicit_transactions on "; } @Override @@ -3033,7 +3033,7 @@ public void setAutoCommit(boolean newAutoCommitMode) throws SQLServerException { // When changing to auto-commit from inside an existing transaction, // commit that transaction first. - if (newAutoCommitMode == true) + if (newAutoCommitMode) commitPendingTransaction = "IF @@TRANCOUNT > 0 COMMIT TRAN "; if (connectionlogger.isLoggable(Level.FINER)) { @@ -3457,11 +3457,11 @@ int writeFedAuthFeatureRequest(boolean write, TDSWriter tdsWriter, // set upper 7 bits of options to indicate fed auth library type switch (fedAuthFeatureExtensionData.libraryType) { case TDS.TDS_FEDAUTH_LIBRARY_ADAL: - assert federatedAuthenticationInfoRequested == true; + assert federatedAuthenticationInfoRequested; options |= TDS.TDS_FEDAUTH_LIBRARY_ADAL << 1; break; case TDS.TDS_FEDAUTH_LIBRARY_SECURITYTOKEN: - assert federatedAuthenticationRequested == true; + assert federatedAuthenticationRequested; options |= TDS.TDS_FEDAUTH_LIBRARY_SECURITYTOKEN << 1; break; default: @@ -3469,7 +3469,7 @@ int writeFedAuthFeatureRequest(boolean write, TDSWriter tdsWriter, break; } - options |= (byte) (fedAuthFeatureExtensionData.fedAuthRequiredPreLoginResponse == true ? 0x01 : 0x00); + options |= (byte) (fedAuthFeatureExtensionData.fedAuthRequiredPreLoginResponse ? 0x01 : 0x00); // write FeatureDataLen tdsWriter.writeInt(dataLen); @@ -4279,7 +4279,7 @@ private void onFeatureExtAck(byte featureId, byte[] data) throws SQLServerExcept } byte enabled = data[1]; - serverSupportsDataClassification = (enabled == 0) ? false : true; + serverSupportsDataClassification = enabled != 0; } case TDS.TDS_FEATURE_EXT_UTF8SUPPORT: { if (connectionlogger.isLoggable(Level.FINER)) { @@ -4977,7 +4977,7 @@ public void releaseSavepoint(Savepoint savepoint) throws SQLException { } final private Savepoint setNamedSavepoint(String sName) throws SQLServerException { - if (true == databaseAutoCommitMode) { + if (databaseAutoCommitMode) { SQLServerException.makeFromDriverError(this, this, SQLServerException.getErrString("R_cantSetSavepoint"), null, false); } @@ -5028,7 +5028,7 @@ public void rollback(Savepoint s) throws SQLServerException { loggerExternal.finer(toString() + " ActivityId: " + ActivityCorrelator.getNext().toString()); } checkClosed(); - if (true == databaseAutoCommitMode) { + if (databaseAutoCommitMode) { SQLServerException.makeFromDriverError(this, this, SQLServerException.getErrString("R_cantInvokeRollback"), null, false); } @@ -5988,7 +5988,7 @@ boolean isAzureDW() throws SQLServerException, SQLException { // Base data type: int final int ENGINE_EDITION_FOR_SQL_AZURE_DW = 6; rs.next(); - isAzureDW = (rs.getInt(1) == ENGINE_EDITION_FOR_SQL_AZURE_DW) ? true : false; + isAzureDW = rs.getInt(1) == ENGINE_EDITION_FOR_SQL_AZURE_DW; } return isAzureDW; } else { diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataSource.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataSource.java index a0b32b32e..e20b0a8e8 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataSource.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataSource.java @@ -1090,7 +1090,7 @@ Reference getReferenceInternal(String dataSourceClassString) { if (propertyName.equals(SQLServerDriverStringProperty.TRUST_STORE_PASSWORD.toString())) { // The property set and the variable set at the same time is not // possible - assert trustStorePasswordStripped == false; + assert !trustStorePasswordStripped; ref.add(new StringRefAddr("trustStorePasswordStripped", "true")); } else { // do not add passwords to the collection. we have normal diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPreparedStatement.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPreparedStatement.java index 41844f813..2475baceb 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPreparedStatement.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPreparedStatement.java @@ -925,7 +925,7 @@ private void getParameterEncryptionMetadata(Parameter[] params) throws SQLServer // Decrypt the symmetric key.(This will also validate and throw if needed). SQLServerSecurityUtility.decryptSymmetricKey(params[paramIndex].cryptoMeta, connection); } else { - if (true == params[paramIndex].getForceEncryption()) { + if (params[paramIndex].getForceEncryption()) { MessageFormat form = new MessageFormat( SQLServerException.getErrString("R_ForceEncryptionTrue_HonorAETrue_UnencryptedColumn")); Object[] msgArgs = {userSQL, paramIndex + 1}; @@ -1081,7 +1081,7 @@ private ResultSet buildExecuteMetaData() throws SQLServerException { internalStmt = (SQLServerStatement) connection.createStatement(); emptyResultSet = internalStmt.executeQueryInternal("set fmtonly on " + fmtSQL + "\nset fmtonly off"); } catch (SQLException sqle) { - if (false == sqle.getMessage().equals(SQLServerException.getErrString("R_noResultset"))) { + if (!sqle.getMessage().equals(SQLServerException.getErrString("R_noResultset"))) { // if the error is not no resultset then throw a processings error. MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_processingError")); Object[] msgArgs = {sqle.getMessage()}; diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/Util.java b/src/main/java/com/microsoft/sqlserver/jdbc/Util.java index 087c2408b..81944e33d 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/Util.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/Util.java @@ -380,7 +380,7 @@ else if (ch == ':') name = SQLServerDriver.getNormalizedPropertyName(name, logger); if (null != name) { if (logger.isLoggable(Level.FINE)) { - if (false == name.equals(SQLServerDriverStringProperty.USER.toString())) { + if (!name.equals(SQLServerDriverStringProperty.USER.toString())) { if (!name.toLowerCase(Locale.ENGLISH).contains("password") && !name.toLowerCase(Locale.ENGLISH).contains("keystoresecret")) { logger.fine("Property:" + name + " Value:" + value); @@ -417,8 +417,8 @@ else if (ch == ':') name = SQLServerDriver.getNormalizedPropertyName(name, logger); if (null != name) { if (logger.isLoggable(Level.FINE)) { - if ((false == name.equals(SQLServerDriverStringProperty.USER.toString())) - && (false == name.equals(SQLServerDriverStringProperty.PASSWORD.toString()))) + if (!name.equals(SQLServerDriverStringProperty.USER.toString()) + && !name.equals(SQLServerDriverStringProperty.PASSWORD.toString())) logger.fine("Property:" + name + " Value:" + value); } p.put(name, value); @@ -487,9 +487,9 @@ else if (ch == ':') name = SQLServerDriver.getNormalizedPropertyName(name, logger); if (null != name) { if (logger.isLoggable(Level.FINE)) { - if ((false == name.equals(SQLServerDriverStringProperty.USER.toString())) - && (false == name.equals(SQLServerDriverStringProperty.PASSWORD.toString())) - && (false == name.equals(SQLServerDriverStringProperty.KEY_STORE_SECRET.toString()))) + if (!name.equals(SQLServerDriverStringProperty.USER.toString()) + && !name.equals(SQLServerDriverStringProperty.PASSWORD.toString()) + && !name.equals(SQLServerDriverStringProperty.KEY_STORE_SECRET.toString())) logger.fine("Property:" + name + " Value:" + value); } p.put(name, value);