RequestCreator .get() fails when no callback is specified
I want to load a feed synchronously, and am attempting to use the following syntax as shown (roughly) in the readme:
List<Article> articles = PkRSS.with(context).load(url).get();
However, that line always seems to result in the following exception:
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object java.lang.ref.WeakReference.get()' on a null object reference
at com.pkmmte.pkrss.PkRSS.load(PkRSS.java:166)
at com.pkmmte.pkrss.RequestCreator.get(RequestCreator.java:182)
Adding a dummy callback, however, makes everything work just fine:
List<Article> articles = PkRSS.with(context).load(url).callback(new Callback() {
@Override
public void onPreload() {}
@Override
public void onLoaded( List<Article> newArticles ) {}
@Override
public void onLoadFailed() {}
} ).get();
So I've found a solution, but I'm not sure if this way of things was intentional or not. If the callback is supposed to be required even for synchronous requests, it wasn't clear to me from the javadoc.
Oops, looks like this bug was added when I implemented weak references. I'll fix this as soon as I get some time!
In the meantime, well, you already know about the workaround. :)