ijuma commented on a change in pull request #9516:
URL: https://github.com/apache/kafka/pull/9516#discussion_r540197290



##########
File path: 
clients/src/test/java/org/apache/kafka/common/record/LazyDownConversionRecordsTest.java
##########
@@ -160,20 +161,21 @@ private static MemoryRecords convertRecords(MemoryRecords 
recordsToConvert, byte
                     inputRecords, toMagic, 0L, Time.SYSTEM);
             LazyDownConversionRecordsSend lazySend = lazyRecords.toSend();
             File outputFile = tempFile();
-            FileChannel channel = FileChannel.open(outputFile.toPath(), 
StandardOpenOption.READ, StandardOpenOption.WRITE);
-
-            int written = 0;
-            while (written < bytesToConvert)
-                written += lazySend.writeTo(channel, written, bytesToConvert - 
written);
-
-            FileRecords convertedRecords = FileRecords.open(outputFile, true, 
(int) channel.size(), false);
-            ByteBuffer convertedRecordsBuffer = 
ByteBuffer.allocate(convertedRecords.sizeInBytes());
-            convertedRecords.readInto(convertedRecordsBuffer, 0);
-
-            // cleanup
-            convertedRecords.close();
-            channel.close();
-
+            ByteBuffer convertedRecordsBuffer;
+            try (FileChannel fileChannel = 
FileChannel.open(outputFile.toPath(), StandardOpenOption.READ, 
StandardOpenOption.WRITE)) {
+                ByteBuffer buf;
+                try (org.apache.kafka.common.requests.ByteBufferChannel 
channel =
+                             new 
org.apache.kafka.common.requests.ByteBufferChannel(bytesToConvert)) {

Review comment:
       One more thing: why we are using a fully qualified name instead of 
relying on imports?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to