@@ -635,6 +635,56 @@ public void testCreatingStatementsDoesNotRegisterChildLoggers() throws Exception
635635 + " statements must not register additional child loggers on the driver root logger" );
636636 }
637637
638+ @ Test
639+ public void testCreatingPreparedAndCallableStatementsDoesNotRegisterChildLoggers ()
640+ throws Exception {
641+ BigQueryConnection connection = mock (BigQueryConnection .class );
642+ doReturn ("leak-test-connection" ).when (connection ).getConnectionId ();
643+ doReturn (BigQueryConnection .SessionState .empty ()).when (connection ).getSessionStateSnapshot ();
644+
645+ Logger rootLogger = BigQueryJdbcRootLogger .getRootLogger ();
646+ // Warm up so that any one-time, class-level logger is registered before we measure.
647+ new BigQueryPreparedStatement (connection , "SELECT 1" );
648+ new BigQueryCallableStatement (connection , "CALL my_proc()" );
649+ int childrenBefore = childLoggerCount (rootLogger );
650+
651+ for (int i = 0 ; i < OBJECT_COUNT ; i ++) {
652+ new BigQueryPreparedStatement (connection , "SELECT 1" );
653+ new BigQueryCallableStatement (connection , "CALL my_proc()" );
654+ }
655+
656+ assertEquals (
657+ childrenBefore ,
658+ childLoggerCount (rootLogger ),
659+ "Creating "
660+ + OBJECT_COUNT
661+ + " PreparedStatements and CallableStatements must not register additional child"
662+ + " loggers on the driver root logger" );
663+ }
664+
665+ @ Test
666+ public void testCreatingParameterHandlersAndBulkInsertWritersDoesNotRegisterChildLoggers ()
667+ throws ReflectiveOperationException {
668+ Logger rootLogger = BigQueryJdbcRootLogger .getRootLogger ();
669+ // Warm up so that any one-time, class-level logger is registered before we measure.
670+ new BigQueryParameterHandler (1 );
671+ new BigQueryJdbcBulkInsertWriter ();
672+ int childrenBefore = childLoggerCount (rootLogger );
673+
674+ for (int i = 0 ; i < OBJECT_COUNT ; i ++) {
675+ new BigQueryParameterHandler (1 );
676+ new BigQueryJdbcBulkInsertWriter ();
677+ }
678+
679+ assertEquals (
680+ childrenBefore ,
681+ childLoggerCount (rootLogger ),
682+ "Creating "
683+ + OBJECT_COUNT
684+ + " ParameterHandlers and BulkInsertWriters must not register additional child loggers"
685+ + " on the driver root logger" );
686+ }
687+
638688 @ Test
639689 public void testCreatingDatabaseMetaDataDoesNotRegisterChildLoggers ()
640690 throws ReflectiveOperationException {
0 commit comments