-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NullPointerException in getFullOrderBook() in Android 2.2 #31
Comments
Can you post a log with debug level logging for com.xeiam.xchange? Also (this may be a separate issue), a friend got an error with Bitcoinium (I built it for him from source) on HTC Wildfire S (Android 2.3). I don't know if it's the same. But I think the error occured "always", not rarely as in your case. I don't have a log though. Does it work for you on Android 2.3? |
It looks to me like the exchange-specific DTO coming from our REST proxy is null for some reason. This problem reminds me of the failed integration tests that Matija saw, but I did not. Matija, can you reproduce the failed tests still? |
The failed test I saw and Tim didn't were different: certificate issues with CaVirtEx (still always happens) and a signature issue with BTCE (happens occasionally). |
I'm not sure how to obtain a log for com.xeiam.xchange in android... I'll create an Android 2.3 AVD and I'll look into your friend's issue, Matija. Does he get the issue if he uses the version on Google Play? |
No, I forgot to mention: the version from Google Play works for him. On Mon, Jan 21, 2013 at 3:53 PM, veken0m notifications@github.com wrote:
|
Just tested Android 2.3.1 (API Level 9) and Android 2.3.3 (API Level 10) and can't seem to reproduce the issue. Perhaps the build you sent him contained unfinished code? I've been reworking some things in Orderbook/Graphing this past week. |
Thanks for testing! I sent him a version a week ago. It could have been On Mon, Jan 21, 2013 at 6:17 PM, veken0m notifications@github.com wrote:
|
I don't know how to see the logs on an Android but try replacing the slf4j jar that we use in XChange with the one designed for Android: http://www.slf4j.org/android/ This may help as well: http://stackoverflow.com/questions/4889782/android-cant-get-logs-with-slf4j-android One way or another you should be able to see logs coming out at different log levels. Use DEBUG to see everything. |
Thanks Tim! I swapped out the slf4j with the proper android one and now get com.xeiam.xchange stuff in my log. What's weird is that the NullPointerException happens after I "successfully" obtain the orderbook and about to print it. I say "successfully" because the orderbook fetching is done in a try/catch brace and there is no exception throw then. I need to catch it at a higher level... Anyways, here's the new log (I trimmed out most of the android stuff): 01-21 14:17:04.689: D/c_.x_.x_.ExchangeFacto_(332): Creating default exchange from class name |
Glad you got the logging working. That's great news. It looks like you made two calls for the full order book 10 seconds apart, and the second time, the response was empty. I'll have to think about that... |
Hmm, I hadn't noticed this before but if I make I make two calls for the BTC-E orderbook in a row the first call is always successful and the second call always fails. The pattern then repeats for any subsequent calls. The other exchanges don't have this problem. Bitstamp and VirtEx seem to fail at random intervals. |
They might have some throttling logic at BTC-E that causes this. You really shouldn't have to be calling it so often, right? On another note, Matija, does your REST proxy provide a means of checking header response codes? |
Correct, I was just testing to see when it fails. Oddly enough, two BTC-E Orderbook calls in a row work fine on my phone. |
The REST proxy uses practically unchanged (just a bit simplified) HttpTemplate, which uses URLConnection that is really a HttpURLConnection, which has a getResponseCode() method. But HttpTemplate doesn't currently check the response code or provide means to access it through the rest framework. |
As a start, I added response code log at debug level to the REST proxy. Go ahead and use the latest snapshot jars, and you may get some more insight. We probably will want to use the return codes intelligently in some way and not allow null Strings to be passed out... |
First thing that stands out: Request http status = -1 -> Failure 01-23 09:37:55.722: D/c_.x_.x_.ExchangeFacto_(276): Creating default exchange from class name |
Just chiming in, you get a -1 from HttpURLConnection when the response is not valid HTTP (see http://javasourcecode.org/html/open-source/jdk/jdk-6u23/java/net/HttpURLConnection.html#getResponseCode%28%29). It may be that virtex are using their own RMI approach that mimics HTTP. |
I looked into this last night a bit more. I think our Http proxy class (HttpTemplate.java) needs to redesigned. While looking into things, I also found that the underlying httpURLConnections should be handled differently for Android. I'm thinking of using this ultra-lightweight lib inside of XChange-core, at least pieces we need of it: http://code.google.com/p/basic-http-client/ That, along with a way to tell XChange that it's running on Android or not. Michael, for now, I'd say catch the null pointers and handle them appropriately. I think in version 1.5.0, we'll have a more robust http interface with better error handling, but for the short term, it's not possible. |
Tim, if it was a simple fix I would say go for it but if it's too much of a hassle it's not really worth |
Sounds good. I'll close this issue now. We'll clean it up in a later version. |
…-1.7.32 Bump slf4j-api from 1.7.31 to 1.7.32
This issue happens in Android 2.2 (my phone is running 4.2.1 and is not affected). MtGox and CampBX don't seem to be affected but it might just be matter of running more tests.
I catch the exception and display an error message to enable the user to try again so this isn't a problem for me anymore. It seems to always work on the second try and does not happen very often. Here are the stack traces if anyone wants to look into it:
Bitstamp:
01-20 18:28:24.303: W/System.err(333): java.lang.NullPointerException
01-20 18:28:24.303: W/System.err(333): at com.xeiam.xchange.bitstamp.BitstampAdapters.adaptOrders(BitstampAdapters.java:85)
01-20 18:28:24.303: W/System.err(333): at com.xeiam.xchange.bitstamp.service.marketdata.polling.BitstampPollingMarketDataService.getFullOrderBook(BitstampPollingMarketDataService.java:92)
BTC-E:
01-20 18:17:43.353: W/System.err(312): java.lang.NullPointerException
01-20 18:17:43.363: W/System.err(312): at com.xeiam.xchange.btce.service.marketdata.polling.BTCEPollingMarketDataService.getFullOrderBook(BTCEPollingMarketDataService.java:88)
VirtEx:
01-20 19:36:02.204: W/System.err(782): java.lang.NullPointerException
01-20 19:36:02.204: W/System.err(782): at com.xeiam.xchange.virtex.service.marketdata.polling.VirtExPollingMarketDataService.getFullOrderBook(VirtExPollingMarketDataService.java:94)
01-20 19:36:02.212: W/System.err(782): at com.veken0m.bitcoinium.OrderbookActivity.getOrderBook(OrderbookActivity.java:141)
The text was updated successfully, but these errors were encountered: