Skip to content

Commit

Permalink
Deadlock and null TDSCommand counter fix
Browse files Browse the repository at this point in the history
  • Loading branch information
tkyc committed Nov 15, 2024
1 parent 70d0f96 commit 29a12c9
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -3280,12 +3280,10 @@ else if (0 == requestedPacketSize)
}

String quotedIdentifierOption = OnOffOption.valueOfString(quotedIdentifierValue).toString();
try (SQLServerStatement stmt = (SQLServerStatement) this.createStatement()) {
stmt.executeQueryInternal("SET QUOTED_IDENTIFIER "
+ ((quotedIdentifierOption.compareToIgnoreCase(OnOffOption.OFF.toString()) == 0) ? "OFF"
: "ON"));
} catch (Exception e) {
throw new SQLServerException(e.getMessage(), null);
if (quotedIdentifierOption.compareToIgnoreCase(OnOffOption.OFF.toString()) == 0) {
connectionCommand("SET QUOTED_IDENTIFIER OFF", "quotedIdentifier");
} else if (quotedIdentifierOption.compareToIgnoreCase(OnOffOption.ON.toString()) == 0) {
connectionCommand("SET QUOTED_IDENTIFIER ON", "quotedIdentifier");

Check warning on line 3286 in src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java#L3286

Added line #L3286 was not covered by tests
}

// check CONCAT_NULL_YIELDS_NULL property
Expand All @@ -3296,12 +3294,11 @@ else if (0 == requestedPacketSize)
activeConnectionProperties.setProperty(concatNullYieldsNullProperty, concatNullYieldsNullValue);
}
String concatNullYieldsNullOption = OnOffOption.valueOfString(concatNullYieldsNullValue).toString();
try (SQLServerStatement stmt = (SQLServerStatement) this.createStatement()) {
stmt.executeQueryInternal("SET CONCAT_NULL_YIELDS_NULL "
+ ((concatNullYieldsNullOption.compareToIgnoreCase(OnOffOption.OFF.toString()) == 0) ? "OFF"
: "ON"));
} catch (Exception e) {
throw new SQLServerException(e.getMessage(), null);
if (concatNullYieldsNullOption.compareToIgnoreCase(OnOffOption.OFF.toString()) == 0) {
connectionCommand("SET CONCAT_NULL_YIELDS_NULL OFF", "concatNullYieldsNull");

} else if (concatNullYieldsNullOption.compareToIgnoreCase(OnOffOption.ON.toString()) == 0) {
connectionCommand("SET CONCAT_NULL_YIELDS_NULL ON", "concatNullYieldsNull");

Check warning on line 3301 in src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java#L3301

Added line #L3301 was not covered by tests
}

// Socket timeout is bounded by loginTimeout during the login phase.
Expand Down Expand Up @@ -4557,6 +4554,7 @@ boolean executeReconnectCommand(TDSCommand newCommand) throws SQLServerException
*/
boolean commandComplete = false;
try {
newCommand.createCounter(null, activeConnectionProperties);
commandComplete = newCommand.execute(tdsChannel.getWriter(), tdsChannel.getReader(newCommand));
} finally {
/*
Expand Down

0 comments on commit 29a12c9

Please sign in to comment.