简体   繁体   中英

FinalizationException - AppEngine Java Blobstore API

I tried to use the experimental Writing Files to Blobstore and even with the demo code, I keep getting FinalizationException upon trying to read the file.

The code I use is below:

FileService fileService = FileServiceFactory.getFileService();

AppEngineFile file = null;
file = fileService.createNewBlobFile("text/plain");

FileWriteChannel writeChannel = fileService.openWriteChannel(file, true);

PrintWriter out = new PrintWriter(Channels.newWriter(writeChannel, "UTF8"));
out.println("The woods are lovely dark and deep.");
out.println("But I have promises to keep.");

out.close();
String path = file.getFullPath();

file = new AppEngineFile(path);

writeChannel = fileService.openWriteChannel(file, true);

writeChannel.write(ByteBuffer.wrap("And miles to go before I sleep.".getBytes()));

writeChannel.closeFinally();

The read code where I get the FinalizationException within another request is as below:

    FileService fileService = FileServiceFactory.getFileService();

    String path = //get the path code       
    AppEngineFile file = new AppEngineFile(path);

    FileReadChannel readChannel;
    try {
        readChannel = fileService.openReadChannel(file, false);
    } catch (FileNotFoundException e) { }

I get the Finalization Exception at the openReadChannel line

Any help would be appreciated.

该示例在开发服务器上运行良好。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM