ianlee-dev / facebook-java-api

Automatically exported from code.google.com/p/facebook-java-api
0 stars 0 forks source link

FacebookJsonRestClass.executeBatch() doesn't fail properly when buffer.size() > BATCH_LIMIT #156

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
If one were to call too many methods for one batch call, the method would
make two server requests, one with the first 20 calls, and another with all
method calls.

Once the while loop has popped off twenty items from queries, then the if
statement will execute, hitting the server, and populating result with the
twenty responses. However, once that for loop completes, control will pass
back to the while loop, which pops the remaining items in queries, and then
once queries is empty, the if statement will be executed again, hitting the
server with the full list of queries.

I propose that we instead throw an exception right away if
this.queries.size() > BATCH_LIMIT.

Original issue reported on code.google.com by divergen...@gmail.com on 2 Jan 2009 at 5:04

GoogleCodeExporter commented 8 years ago
The intended behaviour is that if you submit 25 requests as part of a batch, the
first 20 go off and we get a response back followed by the next 5 (and we get a
separate response back).

The two batches are then parsed and individual responses are returned to the 
client code.

Are you not seeing this expected behaviour? Do you think it's better to fail if 
there
are more than 20 requests? If so, why?

Original comment by david.j....@googlemail.com on 7 Jan 2009 at 9:51

GoogleCodeExporter commented 8 years ago
Ah, I see. No, I am not seeing this expected behavior. When I run the attached 
test
case, I see in the logging statements that the first batch.run call goes out and
returns successfully, but the second one returns with 

1230 [main] DEBUG com.google.code.facebookapi.FacebookJsonRestClient  -
facebook.batch.run: {"request_args":......,"error_code":950,"error_msg":"Each 
batch
API can not contain more than 20 items"}

In this case, I think we need to clear buffer in between server calls

Original comment by divergen...@gmail.com on 7 Jan 2009 at 4:31

Attachments:

GoogleCodeExporter commented 8 years ago
Thanks for the test. I'll take a look.

Original comment by david.j....@googlemail.com on 13 Jan 2009 at 11:28

GoogleCodeExporter commented 8 years ago

Original comment by david.j....@googlemail.com on 13 Jan 2009 at 11:29

GoogleCodeExporter commented 8 years ago
I've checked in a fix for this (yes, it was a problem with the buffer not being
emptied) and a JUnit test. I'll check at home that this runs! (then will mark 
this
issue as fixed if all is well).

Original comment by david.j....@googlemail.com on 13 Jan 2009 at 12:08

GoogleCodeExporter commented 8 years ago
Works fine now.

Original comment by david.j....@googlemail.com on 15 Jan 2009 at 3:04