Android Volley Execution throw an Exception: Unparseable date
Asked Answered
S

0

6

I'm getting an exception in logcart since last few days, this exception is generated by volley lib but most interesting thing is that it does not harm execution.

Anybody, please help why this happening.

I'm using volley lib 1.1 with android Target SDK version 27.

minSdkVersion 16
targetSdkVersion 27

/* Volley dependency */
compile 'com.android.volley:volley:1.1.0'

These logs which I'm getting

E/Volley: [538] HttpHeaderParser.parseDateAsEpoch: Unable to parse dateStr: Thu, 01 Jan 1970 05:30:00 IST, falling back to 0
                                                                       java.text.ParseException: Unparseable date: "Thu, 01 Jan 1970 05:30:00 IST"
                                                                           at java.text.DateFormat.parse(DateFormat.java:362)
                                                                           at com.android.volley.toolbox.HttpHeaderParser.parseDateAsEpoch(HttpHeaderParser.java:142)
                                                                           at com.android.volley.toolbox.HttpHeaderParser.parseCacheHeaders(HttpHeaderParser.java:100)
                                                                           at com.android.volley.toolbox.JsonObjectRequest.parseNetworkResponse(JsonObjectRequest.java:69)
                                                                           at com.android.volley.NetworkDispatcher.processRequest(NetworkDispatcher.java:132)
                                                                           at com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:87)

enter image description here

Volley Execution Code:

public void executeRequest(String url) {
    try {
        JsonObjectRequest jsonObjReq = new JsonObjectRequest(method, url, paramObject, new Response.Listener<JSONObject>() {

            @Override
            public void onResponse(JSONObject jsonObject) {
                try {
                    Log.d(Constants.DEBUG_TAG, "** Result ***: " + jsonObject);
                    if (jsonObject != null) {
                        listener.onSuccess(jsonObject, someFlag);
                    } else {
                        // If response is NULL or some error in format then show server error
                        listener.onServerError(context.getResources().getString(R.string.oops_error));
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }, new Response.ErrorListener() {

            @Override
            public void onErrorResponse(VolleyError e) {
                e.printStackTrace();
                listener.onServerError(context.getResources().getString(R.string.oops_error));
            }
        }) {

            /**
             * Passing some request headers
             * */
            @Override
            public Map<String, String> getHeaders() throws AuthFailureError {
                return headersParam;
            }
        };

        jsonObjReq.setRetryPolicy(new DefaultRetryPolicy(90000,
                DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
                DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));

        // Adding request to request queue
        NSApplication.getInstance().addToRequestQueue(jsonObjReq);
    } catch (Exception e) {
        e.printStackTrace();
        listener.onServerError(context.getString(R.string.oops_error));
    }
}

Calling Volley Method

HashMap<String, String> headerMap = new HashMap<>();
headerMap.put("Content-Type", "application/json");

VolleyConnection connection = new VolleyConnection(this, this, LOAD_ADDRESS, headerMap);
connection.executeRequest(WebApi.GET_ADDRESS + preference.getUserId());
Slurp answered 27/6, 2018 at 14:35 Comment(2)
Did you found any solution ?Amrita
@Arash Hatami No dude not yet.Slurp

© 2022 - 2024 — McMap. All rights reserved.