@@ -238,14 +238,7 @@ public void testOverwriteAcksAndRetriesForIdempotentProducers() {
238
238
239
239
@ Test
240
240
public void testAcksAndIdempotenceForIdempotentProducers () {
241
- Properties baseProps = new Properties () {{
242
- setProperty (
243
- ProducerConfig .BOOTSTRAP_SERVERS_CONFIG , "localhost:9999" );
244
- setProperty (
245
- ProducerConfig .KEY_SERIALIZER_CLASS_CONFIG , StringSerializer .class .getName ());
246
- setProperty (
247
- ProducerConfig .VALUE_SERIALIZER_CLASS_CONFIG , StringSerializer .class .getName ());
248
- }};
241
+ Properties baseProps = baseProperties ();
249
242
250
243
Properties validProps = new Properties () {{
251
244
putAll (baseProps );
@@ -348,11 +341,7 @@ public void testAcksAndIdempotenceForIdempotentProducers() {
348
341
349
342
@ Test
350
343
public void testRetriesAndIdempotenceForIdempotentProducers () {
351
- Properties baseProps = new Properties () {{
352
- setProperty (ProducerConfig .BOOTSTRAP_SERVERS_CONFIG , "localhost:9999" );
353
- setProperty (ProducerConfig .KEY_SERIALIZER_CLASS_CONFIG , StringSerializer .class .getName ());
354
- setProperty (ProducerConfig .VALUE_SERIALIZER_CLASS_CONFIG , StringSerializer .class .getName ());
355
- }};
344
+ Properties baseProps = baseProperties ();
356
345
357
346
Properties validProps = new Properties () {{
358
347
putAll (baseProps );
@@ -414,13 +403,17 @@ public void testRetriesAndIdempotenceForIdempotentProducers() {
414
403
"Must set retries to non-zero when using the transactional producer." );
415
404
}
416
405
406
+ private Properties baseProperties () {
407
+ Properties baseProps = new Properties ();
408
+ baseProps .setProperty (ProducerConfig .BOOTSTRAP_SERVERS_CONFIG , "localhost:9999" );
409
+ baseProps .setProperty (ProducerConfig .KEY_SERIALIZER_CLASS_CONFIG , StringSerializer .class .getName ());
410
+ baseProps .setProperty (ProducerConfig .VALUE_SERIALIZER_CLASS_CONFIG , StringSerializer .class .getName ());
411
+ return baseProps ;
412
+ }
413
+
417
414
@ Test
418
415
public void testInflightRequestsAndIdempotenceForIdempotentProducers () {
419
- Properties baseProps = new Properties () {{
420
- setProperty (ProducerConfig .BOOTSTRAP_SERVERS_CONFIG , "localhost:9999" );
421
- setProperty (ProducerConfig .KEY_SERIALIZER_CLASS_CONFIG , StringSerializer .class .getName ());
422
- setProperty (ProducerConfig .VALUE_SERIALIZER_CLASS_CONFIG , StringSerializer .class .getName ());
423
- }};
416
+ Properties baseProps = baseProperties ();
424
417
425
418
Properties validProps = new Properties () {{
426
419
putAll (baseProps );
@@ -1590,7 +1583,7 @@ public void testMeasureAbortTransactionDuration() {
1590
1583
}
1591
1584
1592
1585
@ Test
1593
- public void testCommitTransactionWithRecordTooLargeException () throws Exception {
1586
+ public void testCommitTransactionWithRecordTooLargeException () {
1594
1587
Map <String , Object > configs = new HashMap <>();
1595
1588
configs .put (ProducerConfig .TRANSACTIONAL_ID_CONFIG , "some.id" );
1596
1589
configs .put (ProducerConfig .BOOTSTRAP_SERVERS_CONFIG , "localhost:9000" );
@@ -1620,7 +1613,7 @@ public void testCommitTransactionWithRecordTooLargeException() throws Exception
1620
1613
}
1621
1614
1622
1615
@ Test
1623
- public void testCommitTransactionWithMetadataTimeoutForMissingTopic () throws Exception {
1616
+ public void testCommitTransactionWithMetadataTimeoutForMissingTopic () {
1624
1617
Map <String , Object > configs = new HashMap <>();
1625
1618
configs .put (ProducerConfig .TRANSACTIONAL_ID_CONFIG , "some.id" );
1626
1619
configs .put (ProducerConfig .BOOTSTRAP_SERVERS_CONFIG , "localhost:9999" );
@@ -1657,7 +1650,7 @@ public void testCommitTransactionWithMetadataTimeoutForMissingTopic() throws Exc
1657
1650
}
1658
1651
1659
1652
@ Test
1660
- public void testCommitTransactionWithMetadataTimeoutForPartitionOutOfRange () throws Exception {
1653
+ public void testCommitTransactionWithMetadataTimeoutForPartitionOutOfRange () {
1661
1654
Map <String , Object > configs = new HashMap <>();
1662
1655
configs .put (ProducerConfig .TRANSACTIONAL_ID_CONFIG , "some.id" );
1663
1656
configs .put (ProducerConfig .BOOTSTRAP_SERVERS_CONFIG , "localhost:9999" );
@@ -1694,7 +1687,7 @@ public void testCommitTransactionWithMetadataTimeoutForPartitionOutOfRange() thr
1694
1687
}
1695
1688
1696
1689
@ Test
1697
- public void testCommitTransactionWithSendToInvalidTopic () throws Exception {
1690
+ public void testCommitTransactionWithSendToInvalidTopic () {
1698
1691
Map <String , Object > configs = new HashMap <>();
1699
1692
configs .put (ProducerConfig .TRANSACTIONAL_ID_CONFIG , "some.id" );
1700
1693
configs .put (ProducerConfig .BOOTSTRAP_SERVERS_CONFIG , "localhost:9000" );
@@ -2131,7 +2124,7 @@ public void testOnlyCanExecuteCloseAfterInitTransactionsTimeout() {
2131
2124
}
2132
2125
2133
2126
@ Test
2134
- public void testSendToInvalidTopic () throws Exception {
2127
+ public void testSendToInvalidTopic () {
2135
2128
Map <String , Object > configs = new HashMap <>();
2136
2129
configs .put (ProducerConfig .BOOTSTRAP_SERVERS_CONFIG , "localhost:9000" );
2137
2130
configs .put (ProducerConfig .MAX_BLOCK_MS_CONFIG , "15000" );
@@ -2937,9 +2930,13 @@ private MetricName expectedMetricName(String clientId, String config, Class<?> c
2937
2930
2938
2931
private static final String NAME = "name" ;
2939
2932
private static final String DESCRIPTION = "description" ;
2940
- private static final Map <String , String > TAGS = Collections . singletonMap ( "k" , "v" );
2933
+ private static final LinkedHashMap <String , String > TAGS = new LinkedHashMap <>( );
2941
2934
private static final double VALUE = 123.0 ;
2942
2935
2936
+ static {
2937
+ TAGS .put ("t1" , "v1" );
2938
+ }
2939
+
2943
2940
public static class MonitorableSerializer extends MockSerializer implements Monitorable {
2944
2941
2945
2942
@ Override
0 commit comments