问题
I'm developing an application that receives several massage queue containing 20-30 gmail addresses. My app owns a single google drive folder that must be shared with all of the users. My app uses Google drive Java client and for the HTTP calls I'm using Google batching
The problem is that I'm getting internal error 500 when I'm trying to share the folder with 30 users simultaneously by multithreading. However when I use threads synchronisation everything is fine but the performance is terrible about 0.5 second per user!
Can anyone explain Why I'm receiving this error?
500 OK
{
"code" : 500,
"errors" : [ {
"domain" : "global",
"message" : "Internal Error. User message: \"An internal error has occurred which prevented the sharing of these item(s): fileame\"",
"reason" : "internalError"
} ],
"message" : "Internal Error. User message: \"An internal error has occurred which prevented the sharing of these item(s): filename\""
}
Here is the thread code:
try {
//batch start
BatchRequest batch = service.batch();
ArrayList<String> users = readUsers(this.file);
Permission[] permissions= new Permission[users.size()];
for (int i = 0 ; i < users.size(); i++){
permissions[i]= new Permission();
permissions[i].setValue(users.get(i)+"@gmail.com");
permissions[i].setType("user");
permissions[i].setRole("writer");
service.permissions().insert(fileId, permissions[i]).setSendNotificationEmails(Boolean.FALSE) .queue(batch, callback);
}
//batch execute
batch.execute();
} catch (IOException e) {
System.out.println("An error occurred and I am " + id + ": " + e);
}
来源:https://stackoverflow.com/questions/37967707/google-drive-rest-api-internal-error-500