This is an automated email from the ASF dual-hosted git repository.

diwu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris-kafka-connector.git


The following commit(s) were added to refs/heads/master by this push:
     new ad38478  [improve]Release the resources of the input io stream (#45)
ad38478 is described below

commit ad3847853f172c0c4dbf575ae46fe6ceb096cd91
Author: wudongliang <[email protected]>
AuthorDate: Mon Oct 21 11:25:43 2024 +0800

    [improve]Release the resources of the input io stream (#45)
---
 .../kafka/connector/decode/avro/DorisAvroConverter.java     | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git 
a/src/main/java/org/apache/doris/kafka/connector/decode/avro/DorisAvroConverter.java
 
b/src/main/java/org/apache/doris/kafka/connector/decode/avro/DorisAvroConverter.java
index 56d8090..1fff2ca 100644
--- 
a/src/main/java/org/apache/doris/kafka/connector/decode/avro/DorisAvroConverter.java
+++ 
b/src/main/java/org/apache/doris/kafka/connector/decode/avro/DorisAvroConverter.java
@@ -179,12 +179,13 @@ public class DorisAvroConverter extends DorisConverter {
         // There are conversions for other logical types as well.
         genericData.addLogicalTypeConversion(new 
Conversions.DecimalConversion());
 
-        InputStream is = new ByteArrayInputStream(data);
-        Decoder decoder = DecoderFactory.get().binaryDecoder(is, null);
-        DatumReader<GenericRecord> reader =
-                new GenericDatumReader<>(writerSchema, readerSchema, 
genericData);
-        GenericRecord datum = reader.read(null, decoder);
-        return datum.toString();
+        try (InputStream is = new ByteArrayInputStream(data)) {
+            Decoder decoder = DecoderFactory.get().binaryDecoder(is, null);
+            DatumReader<GenericRecord> reader =
+                    new GenericDatumReader<>(writerSchema, readerSchema, 
genericData);
+            GenericRecord datum = reader.read(null, decoder);
+            return datum.toString();
+        }
     }
 
     @VisibleForTesting


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to