moukail/android-market-api

RuntimeException in MarketSession

Opened this issue · 0 comments

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