keenlabs / KeenClient-Java

Official Java client for the Keen IO API. Build analytics features directly into your Java apps.
https://keen.io/docs
MIT License
74 stars 43 forks source link

NPE in KeenClient.getKeenCacheSubDirectories() when getKeenCacheDirectory() returns an invalid directory #7

Closed dkador closed 10 years ago

dkador commented 10 years ago

The bug I found is a NullPointerException on line 318 of KeenClient.java. Working backwards, that means that getKeenCacheSubDirectories() returns null, which happens because getKeenCacheDirectory() returns an invalid directory.

To fix the bug, I run the following code before calling KeenClient.upload():

java.io.File keenDir = new java.io.File(context.getCacheDir(), "keen");
if(!keenDir.exists()) {
    keenDir.mkdir();
}
dkador commented 10 years ago

Wrong project. This should be in KeenClient-Android.