• AShetty755695 (Community Member)

    I have used try-with-resources in JAVA

     

    Blob blob = storage

    .get(System.getenv("name"), System.getenv("location"));

     

    try( ReadChannel readChannel = blob.reader();

    FileOutputStream fileOutputStream = new FileOutputStream("abc.txt")) {

    fileOutputStream.getChannel().transferFrom(readChannel, 0, Long.MAX_VALUE);

    }

     

    still I am getting Improper Resource Shutdown or Release (CWE ID 404)  error on the line which is inside try block.

     

    Expand Post
    • Hi @AShetty755695 (Community Member)​ ,

       

      The try-with-resources construct is a good solution for this flaw category.

       

      If this is not automatically detected by Veracode Static Analysis please ensure you have compiled the file with debugging symbols ( you can see this with "javap -v ClassName.class") and that the construct is in the compiled file (you can check this with a tool like JD-GUI).

       

      If both of this is the case and it is still not automatically detected by Veracode Static Analysis I would recommend you contact our technical support team. Here's how you can log a case:

      1. Navigate to the upper right corner of any page in the Community, click on your user avatar.

      2. Select Contact Support from the drop-down menu.

       

      Thank you,

      Boy Baukema

      Expand Post

Topics (4)

No articles found
Loading

Ask the Community

Get answers, share a use case, discuss your favorite features, or get input from the community.