bhavikpokar1993 / marketbilling

Automatically exported from code.google.com/p/marketbilling
0 stars 0 forks source link

race condition in queryInvenotoryAsync and dispose. #171

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
STEPS TO REPRODUCE:

1.  create instance of IabHelper
2. queryInventoryAsync 
3. dispose

If you can get the dispose to happen before the thread starts for 
queryInventory then you will get an exception from check dispose.

EXPECTED OUTPUT:
onQueryInventoryFinished called.

ACTUAL OUTPUT:
Error

AFFECTED ORDER IDS (IF RELEVANT):

OS VERSION:

MARKET/MYAPPS VERSION:

DEVICE:

OUTPUT FROM ADB BUGREPORT ATTACHED:
(Note: The output from "adb bugreport" is required for all bug reports.)

NOTES:

Fixed code is attached.
Change mDispose to boolean, and add synchronized blocks to dispose, and 
queryInventoryAsync
(new Thread(new Runnable() {
            public void run() {
                IabResult result;
                Inventory inv = null;
                synchronized (mDisposed) {
                    if (mDisposed) {
                        result = new IabResult
                                (IABHELPER_DISPOSED_DURING_ASYNC,
                                        "Connection has been closed");
                    } else {
                        result = new IabResult(BILLING_RESPONSE_RESULT_OK, "Inventory refresh successful.");
                        try {
                            inv = queryInventory(querySkuDetails, moreSkus);
                        } catch (IabException ex) {
                            result = ex.getResult();
                        }
                    }
                }

Original issue reported on code.google.com by marcp...@gmail.com on 15 Jan 2014 at 4:23

Attachments: