Process empty record list in Amazon KCL Medium

Processing empty records from getRecords operations is more efficient by setting withCallProcessRecordsEvenForEmptyRecordList to TRUE during Kinesis Client Library (KCL) initialization. This will allow for differentiation of empty records so that they may be treated differently.

Detector ID
java/kcl-with-call-process-records@v1.0
Category
Common Weakness Enumeration (CWE) external icon

Noncompliant example

1public KinesisClientLibConfiguration configureKCLNoncompliant() {
2    // Noncompliant: doesn't set withCallProcessRecordsEvenForEmptyRecordList to true during Kinesis Client Library (KCL) initialization.
3    KinesisClientLibConfiguration kclConfig = new KinesisClientLibConfiguration(applicationName,
4            streamARN, ddbStreamCredentials, workerID)
5            .withMaxRecords(maxRecords)
6            .withIdleTimeBetweenReadsInMillis(idleTimeBetweenReadsInMillis)
7            .withFailoverTimeMillis(leaseFailOverTimeInMillis)
8            .withInitialPositionInStream(InitialPositionInStream.TRIM_HORIZON);
9    return kclConfig;
10}

Compliant example

1public KinesisClientLibConfiguration configureKCLCompliant() {
2    // Compliant: sets withCallProcessRecordsEvenForEmptyRecordList to true during Kinesis Client Library (KCL) initialization.
3    KinesisClientLibConfiguration kclConfig = new KinesisClientLibConfiguration(applicationName,
4            streamARN, ddbStreamCredentials, workerID)
5            .withMaxRecords(maxRecords)
6            .withCallProcessRecordsEvenForEmptyRecordList(true)
7            .withIdleTimeBetweenReadsInMillis(idleTimeBetweenReadsInMillis)
8            .withFailoverTimeMillis(leaseFailOverTimeInMillis)
9            .withInitialPositionInStream(InitialPositionInStream.TRIM_HORIZON);
10    return kclConfig;
11}