miya9022 / android-market-api

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

RuntimeException in MarketSession #23

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
If in flush method RuntimeException is occur, then subsequent calls to 
MarketSession will fail because of invalid state of "request" parameter. 
"request = Request.newBuilder();" will never be called.

Solution. Use following method:

        request.setContext(ctxt);
        try {
            Response resp = executeProtobuf(request.build());
            int i = 0;
            for (ResponseGroup grp : resp.getResponseGroupList()) {
                Object val = null;
                if (grp.hasAppsResponse())
                    val = grp.getAppsResponse();
                if (grp.hasCategoriesResponse())
                    val = grp.getCategoriesResponse();
                if (grp.hasCommentsResponse())
                    val = grp.getCommentsResponse();
                if (grp.hasImageResponse())
                    val = grp.getImageResponse();
                ((Callback) callbacks.get(i)).onResult(grp.getContext(), val);
                i++;
            }
        } finally {
            request = Request.newBuilder();
            callbacks.clear();
        }

Library version : 0.3

RuntimeException is quite common thing due to 400=Bad Request.

Original issue reported on code.google.com by dernashe...@gmail.com on 15 Sep 2010 at 6:22