Free Support Forum - groupdocs.com

File locked after calling getDocumentInfo


#1

Hello,

In a Java web application that uses groupdocs viewer 17.2.0, I am having problems when I try to delete files that were used by the viewer, more especifically, after using getDocumentInfo method from class ViewerHtmlHandler on them. The virtual machine won’t let me delete a file (in java nor in Windows) because it keeps it open. I created the following code that illustrates the problem:

public static void main(String[] args) throws Exception{
    ViewerConfig config = new ViewerConfig();
    config.setUseCache(true);
    ViewerHtmlHandler viewerHandler = new ViewerHtmlHandler(config);
    viewerHandler.clearCache();
    
    String file = "C:\\Users\\Jorge Eduardo\\Desktop\\Infolluviaacida.jpg";
    
    DocumentInfoContainer info = viewerHandler.getDocumentInfo(file);
    
    System.out.println(info.getSize());
    
    Thread.sleep(30000);
    System.out.println("Finished!");
}

While this program is sleeping, I am unable to delete the file I used. Is there a method to “free” the file I used on the viewer?

Thanks in advance.

Best Regards,

Jorge Flórez


#2

@jorgeeflorez,

We are able to reproduce this behavior using GroupDocs.Viewer for Java 17.2.0, however, this issue has been fixed since version 17.5.0. Therefore, we will recommend you to upgrade the API to v17.5.0 or greater.


#3

Thank you for your reply. The company is considering to use a newer version, but it seems it will take some time.


#4

@jorgeeflorez,

Sure, please take your time.