From 1a252e4a9e95163da53ebc947086c1b8ee903198 Mon Sep 17 00:00:00 2001 From: Terry Chow Date: Mon, 8 Jul 2024 15:37:32 -0700 Subject: [PATCH] Corrected test for internal testing --- .../jdbc/unit/statement/BatchExecutionTest.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/test/java/com/microsoft/sqlserver/jdbc/unit/statement/BatchExecutionTest.java b/src/test/java/com/microsoft/sqlserver/jdbc/unit/statement/BatchExecutionTest.java index a5c6465ee..00e99a0f7 100644 --- a/src/test/java/com/microsoft/sqlserver/jdbc/unit/statement/BatchExecutionTest.java +++ b/src/test/java/com/microsoft/sqlserver/jdbc/unit/statement/BatchExecutionTest.java @@ -161,9 +161,15 @@ public void testSqlServerBulkCopyCachingConnectionLevel() throws Exception { stmt.execute(createSqlTable1); stmt.execute(createSqlTable2); - Field bulkcopyMetadataCacheField = TestUtils.getJVMVersion() > 8 ? - con.getClass().getSuperclass().getDeclaredField("BULK_COPY_OPERATION_CACHE") : - con.getClass().getDeclaredField("BULK_COPY_OPERATION_CACHE"); + Field bulkcopyMetadataCacheField; + + if (con.getClass().getName().equals("com.microsoft.sqlserver.jdbc.SQLServerConnection43")) { + bulkcopyMetadataCacheField = con.getClass().getSuperclass() + .getDeclaredField("BULK_COPY_OPERATION_CACHE"); + } else { + bulkcopyMetadataCacheField = con.getClass().getDeclaredField("BULK_COPY_OPERATION_CACHE"); + } + bulkcopyMetadataCacheField.setAccessible(true); Object bulkcopyCache = bulkcopyMetadataCacheField.get(con);