Strange thing happening here. When running any unit test that calls:
FileService fileService = FileServiceFactory.getFileService();
writeChannel = fileService.openWriteChannel(file, lock);
writeChannel.closeFinally();
i get the following exception – the code runs fine outside the unit test and on other workstations – so it’s an environment issue on a windows XP laptop i’m forced to use. Tests run fine on my other pcs and laptops (running ubuntu)
java.lang.RuntimeException: illegal blobKey: pIONuF92LGIK8TV41YSSdQ
at com.google.appengine.api.blobstore.dev.FileBlobStorage.getFileForBlob(FileBlobStorage.java:95)
at com.google.appengine.api.blobstore.dev.FileBlobStorage.storeBlob(FileBlobStorage.java:45)
at com.google.appengine.api.files.dev.BlobstoreFile.getOutputStream(BlobstoreFile.java:225)
at com.google.appengine.api.files.dev.FileMetadata.setFinalized(FileMetadata.java:97)
at com.google.appengine.api.files.dev.BlobstoreFile.setFinalized(BlobstoreFile.java:212)
at com.google.appengine.api.files.dev.LocalFileService.close(LocalFileService.java:334)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at com.google.appengine.tools.development.ApiProxyLocalImpl$AsyncApiCall.callInternal(ApiProxyLocalImpl.java:498)
at com.google.appengine.tools.development.ApiProxyLocalImpl$AsyncApiCall.call(ApiProxyLocalImpl.java:452)
at com.google.appengine.tools.development.ApiProxyLocalImpl$AsyncApiCall.call(ApiProxyLocalImpl.java:430)
at java.util.concurrent.Executors$PrivilegedCallable$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.util.concurrent.Executors$PrivilegedCallable.call(Unknown Source)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
You can avoid this by adding a LocalBlobstoreServiceTestConfig() to your LocalServiceTestHelper setup. I just got it working after adding this to the test class that was failing.
I’m not sure if this is indeed a bug. I supose that the bug was before when the SDK was providing the local blobstore emulation without proper test setup configuration.