Skip to content

Commit

Permalink
Formatted all files (#2260)
Browse files Browse the repository at this point in the history
  • Loading branch information
tkyc authored Nov 22, 2023
1 parent 41c1f8a commit e56deb1
Show file tree
Hide file tree
Showing 68 changed files with 2,916 additions and 2,844 deletions.
12 changes: 6 additions & 6 deletions src/main/java/com/microsoft/sqlserver/jdbc/DDC.java
Original file line number Diff line number Diff line change
Expand Up @@ -893,9 +893,9 @@ private static String fractionalSecondsString(long subSecondNanos, int scale) {
*
* @return a Java object of the desired type.
*/
static final Object convertTemporalToObject(
SQLServerConnection connection, JDBCType jdbcType, SSType ssType, Calendar timeZoneCalendar,
int daysSinceBaseDate, long ticksSinceMidnight, int fractionalSecondsScale) throws SQLServerException {
static final Object convertTemporalToObject(SQLServerConnection connection, JDBCType jdbcType, SSType ssType,
Calendar timeZoneCalendar, int daysSinceBaseDate, long ticksSinceMidnight,
int fractionalSecondsScale) throws SQLServerException {

// In cases where a Calendar object (and therefore Timezone) is not passed to the method,
// use the path below instead to optimize performance.
Expand Down Expand Up @@ -1132,9 +1132,9 @@ static final Object convertTemporalToObject(
ts2.setNanos(subSecondNanos);
if (jdbcType == JDBCType.LOCALDATETIME) {
if (connection.getIgnoreOffsetOnDateTimeOffsetConversion()) {
return LocalDateTime.of(
cal.get(Calendar.YEAR), cal.get(Calendar.MONTH) + 1, cal.get(Calendar.DAY_OF_MONTH),
cal.get(Calendar.HOUR_OF_DAY), cal.get(Calendar.MINUTE), cal.get(Calendar.SECOND), subSecondNanos);
return LocalDateTime.of(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH) + 1,
cal.get(Calendar.DAY_OF_MONTH), cal.get(Calendar.HOUR_OF_DAY), cal.get(Calendar.MINUTE),
cal.get(Calendar.SECOND), subSecondNanos);
} else {
return ts2.toLocalDateTime();
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/microsoft/sqlserver/jdbc/DataTypes.java
Original file line number Diff line number Diff line change
Expand Up @@ -1115,7 +1115,8 @@ private DataTypes() {
static final void throwConversionError(String fromType, String toType) throws SQLServerException {
MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_unsupportedConversionFromTo"));
Object[] msgArgs = {fromType, toType};
SQLServerException.makeFromDriverError(null, null, form.format(msgArgs), SQLState.ERROR_IN_ASSIGNMENT.getSQLStateCode(), true);
SQLServerException.makeFromDriverError(null, null, form.format(msgArgs),
SQLState.ERROR_IN_ASSIGNMENT.getSQLStateCode(), true);
}

/**
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 @@ -99,8 +99,8 @@ void failoverAdd(SQLServerConnection connection, boolean actualUseFailoverPartne
try {
if (useFailoverPartner != actualUseFailoverPartner) {
if (connection.getConnectionLogger().isLoggable(Level.FINE))
connection.getConnectionLogger()
.fine(connection.toString() + " Failover detected. failover partner=" + actualFailoverPartner);
connection.getConnectionLogger().fine(
connection.toString() + " Failover detected. failover partner=" + actualFailoverPartner);
useFailoverPartner = actualUseFailoverPartner;
}
// The checking for actualUseFailoverPartner may look weird but this is required
Expand Down
19 changes: 8 additions & 11 deletions src/main/java/com/microsoft/sqlserver/jdbc/IOBuffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -3763,16 +3763,14 @@ void writeDatetime(java.sql.Timestamp dateValue) throws SQLServerException {
int subSecondNanos;
subSecondNanos = ldt.getNano();


// Number of days there have been since the SQL Base Date.
// These are based on SQL Server algorithms
int daysSinceSQLBaseDate = DDC.daysSinceBaseDate(ldt.getYear(),
ldt.getDayOfYear(), TDS.BASE_YEAR_1900);
int daysSinceSQLBaseDate = DDC.daysSinceBaseDate(ldt.getYear(), ldt.getDayOfYear(), TDS.BASE_YEAR_1900);

// Number of milliseconds since midnight of the current day.
int millisSinceMidnight = (subSecondNanos + Nanos.PER_MILLISECOND / 2) / Nanos.PER_MILLISECOND + // Millis into
// the current
// second
// the current
// second
1000 * ldt.getSecond() + // Seconds into the current minute
60 * 1000 * ldt.getMinute() + // Minutes into the current hour
60 * 60 * 1000 * ldt.getHour(); // Hours into the current day
Expand Down Expand Up @@ -5029,8 +5027,8 @@ void writeTVPRows(TVP value) throws SQLServerException {
}

private void writeInternalTVPRowValues(JDBCType jdbcType, String currentColumnStringValue, Object currentObject,
Map.Entry<Integer, SQLServerMetaData> columnPair, boolean isSqlVariant)
throws SQLServerException, IllegalArgumentException {
Map.Entry<Integer, SQLServerMetaData> columnPair,
boolean isSqlVariant) throws SQLServerException, IllegalArgumentException {
boolean isShortValue, isNull;
int dataLength;
switch (jdbcType) {
Expand Down Expand Up @@ -5104,7 +5102,6 @@ private void writeInternalTVPRowValues(JDBCType jdbcType, String currentColumnSt
* setScale of all BigDecimal value based on metadata as scale is not sent separately for individual
* value. Use the rounding used in Server. Say, for BigDecimal("0.1"), if scale in metadata is 0,
* then ArithmeticException would be thrown if RoundingMode is not set
*
* Additionally, we should check here if the scale is within the bounds of SQLServer as it is
* possible for a number with a scale larger than 38 to be passed in.
*/
Expand Down Expand Up @@ -7278,9 +7275,9 @@ final Object readDate(int valueLength, Calendar appTimeZoneCalendar, JDBCType jd

// Convert the DATE value to the desired Java type.
return DDC.convertTemporalToObject(con, jdbcType, SSType.DATE, appTimeZoneCalendar, localDaysIntoCE, 0, // midnight
// local to
// app time
// zone
// local to
// app time
// zone
0); // scale (ignored for DATE)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.io.Serializable;
import java.sql.SQLException;


/**
* Provides an interface used to create classes that read in data from any source (such as a file) and allows a
* SQLServerBulkCopy class to write the data to SQL Server tables.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ CallableStatement prepareCall(String sql, int nType, int nConcur, int nHold,
* Returns the current flag for calcBigDecimalScale.
*
* @return calcBigDecimalScale
* Whether calculating big decimal scale from input values is enabled.
* Whether calculating big decimal scale from input values is enabled.
*/
boolean getCalcBigDecimalScale();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -883,13 +883,14 @@ public interface ISQLServerDataSource extends javax.sql.CommonDataSource {
boolean getUseDefaultJaasConfig();

/**
* Sets whether the default JAAS Configuration will be used. This means the system-wide JAAS configuration
* Sets whether the default JAAS Configuration will be used. This means the system-wide JAAS configuration
* is ignored to avoid conflicts with libraries that override the JAAS configuration.
*
* @param useDefaultJaasConfig
* boolean property to use the default JAAS configuration
* boolean property to use the default JAAS configuration
*/
void setUseDefaultJaasConfig(boolean useDefaultJaasConfig);

/**
* Sets whether Fips Mode should be enabled/disabled on the connection. For FIPS enabled JVM this property should be
* true.
Expand Down Expand Up @@ -1337,7 +1338,7 @@ public interface ISQLServerDataSource extends javax.sql.CommonDataSource {
* Returns value of 'calcBigDecimalScale' from Connection String.
*
* @param calcBigDecimalScale
* indicates whether the driver should attempt to calculate scale from inputted big decimal values
* indicates whether the driver should attempt to calculate scale from inputted big decimal values
*/
void setCalcBigDecimalScale(boolean calcBigDecimalScale);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import java.io.Serializable;


/**
* Provides an interface to the {@link SQLServerStatement} class.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -426,16 +426,17 @@ private ReconnectThread() {}
eReceived = null;
stopRequested = false;
if (loggerResiliency.isLoggable(Level.FINER)) {
loggerResiliency.finer("Idle connection resiliency - ReconnectThread initialized. Connection retry count = " + connectRetryCount
+ "; Command = " + cmd.toString());
loggerResiliency.finer("Idle connection resiliency - ReconnectThread initialized. Connection retry count = "
+ connectRetryCount + "; Command = " + cmd.toString());
}

}

@Override
public void run() {
if (loggerResiliency.isLoggable(Level.FINER)) {
loggerResiliency.finer("Idle connection resiliency - starting ReconnectThread for command: " + command.toString());
loggerResiliency
.finer("Idle connection resiliency - starting ReconnectThread for command: " + command.toString());
}
boolean interruptsEnabled = command.getInterruptsEnabled();
/*
Expand All @@ -460,8 +461,8 @@ public void run() {

while ((connectRetryCount >= 0) && (!stopRequested) && keepRetrying) {
if (loggerResiliency.isLoggable(Level.FINER)) {
loggerResiliency.finer("Idle connection resiliency - running reconnect for command: " + command.toString() + " ; connectRetryCount = "
+ connectRetryCount);
loggerResiliency.finer("Idle connection resiliency - running reconnect for command: "
+ command.toString() + " ; connectRetryCount = " + connectRetryCount);
}

try {
Expand All @@ -470,21 +471,26 @@ public void run() {
keepRetrying = false;

if (loggerResiliency.isLoggable(Level.FINE)) {
loggerResiliency.fine("Idle connection resiliency - reconnect attempt succeeded ; connectRetryCount = " + connectRetryCount);
loggerResiliency
.fine("Idle connection resiliency - reconnect attempt succeeded ; connectRetryCount = "
+ connectRetryCount);
}

} catch (SQLServerException e) {

if (loggerResiliency.isLoggable(Level.FINE)) {
loggerResiliency.fine("Idle connection resiliency - reconnect attempt failed ; connectRetryCount = " + connectRetryCount);
loggerResiliency.fine("Idle connection resiliency - reconnect attempt failed ; connectRetryCount = "
+ connectRetryCount);
}

if (!stopRequested) {
eReceived = e;
if (con.isFatalError(e)) {

if (loggerResiliency.isLoggable(Level.FINER)) {
loggerResiliency.finer("Idle connection resiliency - reconnect for command: " + command.toString() + " encountered fatal error: " + e.getMessage() + " - stopping reconnect attempt.");
loggerResiliency.finer("Idle connection resiliency - reconnect for command: "
+ command.toString() + " encountered fatal error: " + e.getMessage()
+ " - stopping reconnect attempt.");
}

keepRetrying = false;
Expand All @@ -495,7 +501,8 @@ public void run() {
}
} catch (InterruptedException ie) {
if (loggerResiliency.isLoggable(Level.FINER)) {
loggerResiliency.finer("Idle connection resiliency - query timed out for command: " + command.toString() + ". Stopping reconnect attempt.");
loggerResiliency.finer("Idle connection resiliency - query timed out for command: "
+ command.toString() + ". Stopping reconnect attempt.");
}

// re-interrupt thread
Expand All @@ -513,7 +520,8 @@ public void run() {
command.checkForInterrupt();
} catch (SQLServerException e) {
if (loggerResiliency.isLoggable(Level.FINER)) {
loggerResiliency.finer("Idle connection resiliency - timeout occurred on reconnect: " + command.toString() + ". Stopping reconnect attempt.");
loggerResiliency.finer("Idle connection resiliency - timeout occurred on reconnect: "
+ command.toString() + ". Stopping reconnect attempt.");
}
// Interrupted, timeout occurred. Stop retrying.
keepRetrying = false;
Expand All @@ -530,7 +538,8 @@ public void run() {
command.setInterruptsEnabled(interruptsEnabled);

if (loggerResiliency.isLoggable(Level.FINER)) {
loggerResiliency.finer("Idle connection resiliency - ReconnectThread exiting for command: " + command.toString());
loggerResiliency
.finer("Idle connection resiliency - ReconnectThread exiting for command: " + command.toString());
}

if (timeout != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ private void initAuthInit() throws SQLServerException {
GSSName remotePeerName = manager.createName(spn, null);

if (useDefaultNativeGSSCredential) {
peerCredentials = manager.createCredential(null, GSSCredential.DEFAULT_LIFETIME, kerberos, GSSCredential.INITIATE_ONLY);
peerCredentials = manager.createCredential(null, GSSCredential.DEFAULT_LIFETIME, kerberos,
GSSCredential.INITIATE_ONLY);
}

if (null != peerCredentials) {
Expand All @@ -82,13 +83,13 @@ private void initAuthInit() throws SQLServerException {
SQLServerDriverBooleanProperty.USE_DEFAULT_JAAS_CONFIG.toString(),
Boolean.toString(SQLServerDriverBooleanProperty.USE_DEFAULT_JAAS_CONFIG.getDefaultValue())));

if (!configName.equals(
SQLServerDriverStringProperty.JAAS_CONFIG_NAME.getDefaultValue()) && useDefaultJaas) {
if (!configName.equals(SQLServerDriverStringProperty.JAAS_CONFIG_NAME.getDefaultValue())
&& useDefaultJaas) {
// Reset configName to default -- useDefaultJaas setting takes priority over jaasConfigName
if (authLogger.isLoggable(Level.WARNING)) {
authLogger.warning(toString() + String.format(
"Using default JAAS configuration, configured %s=%s will not be used.",
SQLServerDriverStringProperty.JAAS_CONFIG_NAME, configName));
authLogger.warning(toString()
+ String.format("Using default JAAS configuration, configured %s=%s will not be used.",
SQLServerDriverStringProperty.JAAS_CONFIG_NAME, configName));
}
configName = SQLServerDriverStringProperty.JAAS_CONFIG_NAME.getDefaultValue();
}
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/com/microsoft/sqlserver/jdbc/Parameter.java
Original file line number Diff line number Diff line change
Expand Up @@ -594,8 +594,8 @@ private void setTypeDefinition(DTV dtv) {
} else {
if (con.getCalcBigDecimalScale() && dtv.getJavaType() == JavaType.BIGDECIMAL
&& null != dtv.getSetterValue()) {
String[] plainValueArray
= ((BigDecimal) dtv.getSetterValue()).abs().toPlainString().split("\\.");
String[] plainValueArray = ((BigDecimal) dtv.getSetterValue()).abs().toPlainString()
.split("\\.");

// Precision is computed as opposed to using BigDecimal.precision(). This is because the
// BigDecimal method can lead to inaccurate results.
Expand All @@ -611,12 +611,12 @@ private void setTypeDefinition(DTV dtv) {
} else {
calculatedPrecision = plainValueArray[0].length() + plainValueArray[1].length();
}
} else {
} else {
calculatedPrecision = plainValueArray[0].length();
}

param.typeDefinition = SSType.DECIMAL.toString() + "(" + calculatedPrecision + "," +
(plainValueArray.length == 2 ? plainValueArray[1].length() : 0) + ")";
param.typeDefinition = SSType.DECIMAL.toString() + "(" + calculatedPrecision + ","
+ (plainValueArray.length == 2 ? plainValueArray[1].length() : 0) + ")";
} else {
param.typeDefinition = SSType.DECIMAL.toString() + "("
+ SQLServerConnection.MAX_DECIMAL_PRECISION + "," + scale + ")";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ public void beforeCacheAccess(ITokenCacheAccessContext iTokenCacheAccessContext)
public void afterCacheAccess(ITokenCacheAccessContext iTokenCacheAccessContext) {
lock.lock();
try {
if (null != iTokenCacheAccessContext && iTokenCacheAccessContext.hasCacheChanged() && null != iTokenCacheAccessContext.tokenCache())
if (null != iTokenCacheAccessContext && iTokenCacheAccessContext.hasCacheChanged()
&& null != iTokenCacheAccessContext.tokenCache())
cache = iTokenCacheAccessContext.tokenCache().serialize();
} finally {
lock.unlock();
Expand Down
Loading

0 comments on commit e56deb1

Please sign in to comment.