paxxie2 opened a new issue, #15355:
URL: https://github.com/apache/dubbo/issues/15355

   ### Pre-check
   
   - [x] I am sure that all the content I provide is in English.
   
   
   ### Search before asking
   
   - [x] I had searched in the 
[issues](https://github.com/apache/dubbo/issues?q=is%3Aissue) and found no 
similar issues.
   
   
   ### Apache Dubbo Component
   
   Java SDK (apache/dubbo)
   
   ### Dubbo Version
   
   Dubbo 3.3.1 , JDK 17, mac  15.3.2
   
   ### Steps to reproduce this issue
   
   ```
      public byte[] compress(byte[] payloadByteArr) throws RpcException {
           if (null == payloadByteArr || 0 == payloadByteArr.length) {
               return new byte[0];
           }
   
           ByteArrayOutputStream out = new ByteArrayOutputStream();
           BZip2CompressorOutputStream cos;
           try {
               cos = new BZip2CompressorOutputStream(out);
               cos.write(payloadByteArr);
               cos.close();
           } catch (Exception e) {
               throw new IllegalStateException(e);
           }
   
           return out.toByteArray();
       }
   ```
   If the cos.write() operation encounters an IO exception, the cos.close() 
method will not execute, which may result in incorrect resource release. Should 
execute close() in finally {} or use try-with-resources
   
   
   ### What you expected to happen
   
   Using try-with-resources to manipulate BZip2CompressorOutputStream
   
   
   ### Anything else
   
   _No response_
   
   ### Are you willing to submit a pull request to fix on your own?
   
   - [x] Yes I am willing to submit a pull request on my own!
   
   ### Code of Conduct
   
   - [x] I agree to follow this project's [Code of 
Conduct](https://www.apache.org/foundation/policies/conduct)
   


-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to