Code Monkey home page Code Monkey logo

Comments (10)

mohamedmenasy avatar mohamedmenasy commented on June 15, 2024 1

I have the same exact issue, I am using okhttp + retrofit with Picasso to cache images. when I save objects it Success but when retrieve it with getAsync it fail. following is the stack trace :

11-16 09:15:57.436    1292-1292/com.myapp W/System.err﹕ java.lang.NullPointerException
11-16 09:15:57.436    1292-1292/com.myapp W/System.err﹕ at com.anupcowkur.reservoir.Reservoir$GetTask.doInBackground(Reservoir.java:180)
11-16 09:15:57.436    1292-1292/com.myapp W/System.err﹕ at com.anupcowkur.reservoir.Reservoir$GetTask.doInBackground(Reservoir.java:163)
11-16 09:15:57.436    1292-1292/com.myapp W/System.err﹕ at android.os.AsyncTask$2.call(AsyncTask.java:287)
11-16 09:15:57.436    1292-1292/com.myapp W/System.err﹕ at java.util.concurrent.FutureTask.run(FutureTask.java:234)
11-16 09:15:57.436    1292-1292/com.myapp W/System.err﹕ at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
11-16 09:15:57.436    1292-1292/com.myapp W/System.err﹕ at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
11-16 09:15:57.436    1292-1292/com.myapp W/System.err﹕ at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
11-16 09:15:57.436    1292-1292/com.myapp W/System.err﹕ at java.lang.Thread.run(Thread.java:841)

from reservoir.

xarlotie avatar xarlotie commented on June 15, 2024 1

I used it just as documented.

        Reservoir.putAsync(key, apiResponse, new ReservoirPutCallback() {
                @Override
                public void onSuccess() {
                    Log.i("RestCache", "[PUT] Success: " + key);
                }

                @Override
                public void onFailure(Exception e) {
                    Log.i("RestCache", "[PUT] Failed: " + key);
                }
        });

        Reservoir.getAsync(this.key, ApiResponse.class, new ReservoirGetCallback<ApiResponse>() {
                @Override
                public void onSuccess(ApiResponse apiResponse) {
                    Log.i("RestCache", "[GET] Success: " + key);
                    try {
                        Log.i("RestCache", "Using cached data...");
                        callback.apiSuccess(tag, apiResponse, null, null);
                    } catch (JSONException e) {
                        Log.i("RestCache", "Using cached data failed!");
                        e.printStackTrace();
                    }
                }

                @Override
                public void onFailure(Exception e) {
                     Log.i("RestCache", "[GET] Failed: " + key);
                     Log.i("RestCache", "Requesting new data...");
                     //some process here...
                }
        });

from reservoir.

matthew-reilly avatar matthew-reilly commented on June 15, 2024 1

Seeing this as well.

from reservoir.

anupcowkur avatar anupcowkur commented on June 15, 2024

Strange. The data is stored in the application's internal storage.

from reservoir.

xarlotie avatar xarlotie commented on June 15, 2024

I'm also having that problem. I don't have to setup any path for cache right? So what's the issue?

from reservoir.

anupcowkur avatar anupcowkur commented on June 15, 2024

@xarlotie no, you don't have to set up a path. Can you make a sample that reproduces this?

from reservoir.

anupcowkur avatar anupcowkur commented on June 15, 2024

Can you please give me the API response JSON that you receive and the ApiResponse class code as well?

from reservoir.

xarlotie avatar xarlotie commented on June 15, 2024

I already simplified it. I tried String instead of my complicated ApiResponse class. Still doesnt work.

I get the very same stacktrace posted by @mohamedmenasy

from reservoir.

anupcowkur avatar anupcowkur commented on June 15, 2024

The stack trace is fine but I need to see the exact server response and the model class if I am to fix this.

from reservoir.

xarlotie avatar xarlotie commented on June 15, 2024

Here's a sample data:

{
    "data":
    [
        {
            "movieid": 14920,
            "title": "Everly"
            "rating": "R-16",
            "poster": "http://ia.media-imdb.com/images/M/MV5BMjEyNTU4NTE5NV5BMl5BanBnXkFtZTgwNzY4NzIxNDE@._V1_SX214_AL_.jpg",
            "url": "http://www.imdb.com/title/tt1945084/",
            "release_date": "2015-02-11",
            "genre": "Action, Thriller",
            "critics_rating": 
                {
                    "title": "‘Everly’ Lacks the Imagination to Make Up for its Minor Ambitions",
                    "articleid": 25056,
                    "rating": 1.5,
                    "rating_img": "http://icons.iconarchive.com/icons/oxygen-icons.org/oxygen/32/Actions-rating-icon.png"
                }
        }
    ],
    "message": "",
    "status": true,
    "total": 22
}

But i already tried to treat that as a String and not a custom class. It still does not work.

from reservoir.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.