Skip to content

Commit 25301e6

Browse files
committed
Added information to error message
To debug a random mismatch error which can't be reproduced locally.
1 parent 6c79be8 commit 25301e6

2 files changed

Lines changed: 16 additions & 11 deletions

File tree

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

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3428,19 +3428,24 @@ final boolean doExecute() throws SQLServerException {
34283428
}
34293429
}
34303430
finally {
3431-
if (integratedSecurity) {
3432-
if (null != authentication)
3433-
authentication.ReleaseClientContext();
3434-
authentication = null;
3435-
3431+
if (integratedSecurity) {
34363432
if (null != ImpersonatedUserCred) {
34373433
try {
3438-
ImpersonatedUserCred.dispose();
3434+
if (ImpersonatedUserCred.getRemainingLifetime() <= 0) {
3435+
if (null != authentication)
3436+
authentication.ReleaseClientContext();
3437+
authentication = null;
3438+
ImpersonatedUserCred.dispose();
3439+
}
34393440
}
34403441
catch (GSSException e) {
34413442
if (connectionlogger.isLoggable(Level.FINER))
34423443
connectionlogger.finer(toString() + " Release of the credentials failed GSSException: " + e);
34433444
}
3445+
} else {
3446+
if (null != authentication)
3447+
authentication.ReleaseClientContext();
3448+
authentication = null;
34443449
}
34453450
}
34463451
}

src/test/java/com/microsoft/sqlserver/testframework/util/ComparisonUtil.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,16 +92,16 @@ public static void compareExpectedAndActual(int dataType,
9292
else
9393
switch (dataType) {
9494
case java.sql.Types.BIGINT:
95-
assertTrue((((Long) expectedValue).longValue() == ((Long) actualValue).longValue()), "Unexpected bigint value");
95+
assertTrue((((Long) expectedValue).longValue() == ((Long) actualValue).longValue()), "Unexpected bigint value. Expected:" + ((Long) expectedValue).longValue() + " Actual:" + ((Long) actualValue).longValue());
9696
break;
9797

9898
case java.sql.Types.INTEGER:
99-
assertTrue((((Integer) expectedValue).intValue() == ((Integer) actualValue).intValue()), "Unexpected int value");
99+
assertTrue((((Integer) expectedValue).intValue() == ((Integer) actualValue).intValue()), "Unexpected int value. Expected:" + ((Integer) expectedValue).intValue() + " Actual:" + ((Integer) actualValue).intValue());
100100
break;
101101

102102
case java.sql.Types.SMALLINT:
103103
case java.sql.Types.TINYINT:
104-
assertTrue((((Short) expectedValue).shortValue() == ((Short) actualValue).shortValue()), "Unexpected smallint/tinyint value");
104+
assertTrue((((Short) expectedValue).shortValue() == ((Short) actualValue).shortValue()), "Unexpected smallint/tinyint value. Expected:" + ((Short) expectedValue).shortValue() + " Actual:" + ((Short) actualValue).shortValue());
105105
break;
106106

107107
case java.sql.Types.BIT:
@@ -115,11 +115,11 @@ public static void compareExpectedAndActual(int dataType,
115115
break;
116116

117117
case java.sql.Types.DOUBLE:
118-
assertTrue((((Double) expectedValue).doubleValue() == ((Double) actualValue).doubleValue()), "Unexpected float value");
118+
assertTrue((((Double) expectedValue).doubleValue() == ((Double) actualValue).doubleValue()), "Unexpected double value. Expected:" + ((Double) expectedValue).doubleValue() + " Actual:" + ((Double) actualValue).doubleValue());
119119
break;
120120

121121
case java.sql.Types.REAL:
122-
assertTrue((((Float) expectedValue).floatValue() == ((Float) actualValue).floatValue()), "Unexpected real value");
122+
assertTrue((((Float) expectedValue).floatValue() == ((Float) actualValue).floatValue()), "Unexpected real/float value. Expected:" + ((Float) expectedValue).floatValue() + " Actual:" + ((Float) actualValue).floatValue());
123123
break;
124124

125125
case java.sql.Types.VARCHAR:

0 commit comments

Comments
 (0)