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

orpiske pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new dc625e1  (chores) camel-soroush cleanup (#5692)
dc625e1 is described below

commit dc625e1123c9a64f47530664e31a3184ea01e6b9
Author: Otavio Rodolfo Piske <[email protected]>
AuthorDate: Thu Jun 17 14:19:59 2021 +0200

    (chores) camel-soroush cleanup (#5692)
    
    - ensure resources are closed to avoid leaking them
---
 .../camel/component/soroushbot/component/SoroushBotEndpoint.java | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git 
a/components/camel-soroush/src/main/java/org/apache/camel/component/soroushbot/component/SoroushBotEndpoint.java
 
b/components/camel-soroush/src/main/java/org/apache/camel/component/soroushbot/component/SoroushBotEndpoint.java
index 71f399c..b727848 100644
--- 
a/components/camel-soroush/src/main/java/org/apache/camel/component/soroushbot/component/SoroushBotEndpoint.java
+++ 
b/components/camel-soroush/src/main/java/org/apache/camel/component/soroushbot/component/SoroushBotEndpoint.java
@@ -502,10 +502,11 @@ public class SoroushBotEndpoint extends DefaultEndpoint {
         //this for handle connection retry if sending request failed.
         for (int count = 0; count <= maxConnectionRetry; count++) {
             waitBeforeRetry(count);
-            MultiPart multipart = new MultiPart();
-            multipart.setMediaType(MediaType.MULTIPART_FORM_DATA_TYPE);
-            multipart.bodyPart(new StreamDataBodyPart("file", inputStream, 
null, MediaType.APPLICATION_OCTET_STREAM_TYPE));
-            try {
+
+            try (MultiPart multipart = new MultiPart()) {
+                multipart.setMediaType(MediaType.MULTIPART_FORM_DATA_TYPE);
+                multipart.bodyPart(new StreamDataBodyPart("file", inputStream, 
null, MediaType.APPLICATION_OCTET_STREAM_TYPE));
+
                 if (LOG.isDebugEnabled()) {
                     LOG.debug("try to upload {} for the {} time for message: 
{}", fileType,
                             StringUtils.ordinal(count + 1), message);

Reply via email to