-
-
Save lookfirst/4961a204f1f5773f46eb5c9421191069 to your computer and use it in GitHub Desktop.
Demonstrates bug in remote api transactional task handling
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.remoteapi.bug; | |
import com.google.appengine.api.datastore.*; | |
import com.google.appengine.api.taskqueue.Queue; | |
import com.google.appengine.api.taskqueue.QueueFactory; | |
import com.google.appengine.api.taskqueue.TaskOptions; | |
import com.google.appengine.tools.remoteapi.RemoteApiInstaller; | |
import com.google.appengine.tools.remoteapi.RemoteApiOptions; | |
import java.io.IOException; | |
public class RemoteApiExample { | |
public static void main(String[] args) throws IOException, EntityNotFoundException { | |
RemoteApiOptions options = new RemoteApiOptions() | |
.server("remoteapi-transaction-bug.appspot.com", 443) | |
.useApplicationDefaultCredential(); | |
RemoteApiInstaller installer = new RemoteApiInstaller(); | |
installer.install(options); | |
try { | |
insertIntoDatasore(); | |
} finally { | |
installer.uninstall(); | |
} | |
} | |
private static void insertIntoDatasore() throws EntityNotFoundException { | |
DatastoreService datastore = DatastoreServiceFactory.getDatastoreService(); | |
final Queue defaultQueue = QueueFactory.getDefaultQueue(); | |
Transaction txn = datastore.beginTransaction(); | |
try { | |
Entity employee = new Entity(KeyFactory.createKey("Employee", "Joe")); | |
datastore.put(txn,employee); | |
defaultQueue.add(txn, TaskOptions.Builder.withUrl("/")); | |
txn.commit(); | |
} finally { | |
if (txn.isActive()) { | |
txn.rollback(); | |
} | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Exception in thread "main" com.google.appengine.api.taskqueue.TransactionalTaskException | |
at com.google.appengine.api.taskqueue.QueueApiHelper.translateError(QueueApiHelper.java:102) | |
at com.google.appengine.api.taskqueue.QueueApiHelper.translateError(QueueApiHelper.java:159) | |
at com.google.appengine.api.taskqueue.QueueApiHelper$1.convertException(QueueApiHelper.java:55) | |
at com.google.appengine.api.utils.FutureWrapper.get(FutureWrapper.java:96) | |
at com.google.appengine.api.utils.FutureWrapper.get(FutureWrapper.java:88) | |
at com.google.appengine.api.utils.FutureWrapper.get(FutureWrapper.java:88) | |
at com.google.appengine.api.taskqueue.QueueApiHelper.getInternal(QueueApiHelper.java:78) | |
at com.google.appengine.api.taskqueue.QueueImpl.add(QueueImpl.java:433) | |
at com.remoteapi.bug.RemoteApiExample.insertIntoDatasore(RemoteApiExample.java:33) | |
at com.remoteapi.bug.RemoteApiExample.main(RemoteApiExample.java:19) | |
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) | |
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) | |
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) | |
at java.lang.reflect.Method.invoke(Method.java:498) | |
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144) | |
Caused by: java.lang.IllegalArgumentException: | |
at com.google.appengine.api.datastore.DatastoreApiHelper.translateError(DatastoreApiHelper.java:54) | |
at com.google.appengine.api.taskqueue.QueueApiHelper.translateError(QueueApiHelper.java:104) | |
... 14 more | |
Process finished with exit code 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment