Open jagged91 opened 5 years ago
Just tested with an older version of OKHTTP (3.9.0) and still have the same issue.
Hey @jgadsby, do you use Filestack SDK inside of a SyncAdapter
? Is this 0.9.0 version? Would you mind trying 0.8.2?
Caused by: java.lang.NullPointerException:
Attempt to invoke virtual method 'java.io.InputStream
java.lang.ClassLoader.getResourceAsStream(java.lang.String)' on a null object reference at
com.filestack.internal.Util.getVersion(Util.java:30) at
I see that there is some issue with acquiring the SDK version from system resources. This is not really necessary for us to do and it might be the cause of the problem. I don't really think that the OkHttp version has anything to do with it (fortunately :))
So, I tried 0.8.2 and the exception seems to disappear, but there's still something going wrong - when I place a log statement right after the client is created, the log statement is never called.
Log.d("FileStackHandler", "Creating client...")
// Create a Filestack client
val config = Config("<API KEY>")
val client = Client(config)
Log.d("FileStackHandler", "Created client")
Anyway, it doesn't matter right now as I'm unable to get the response via the library (see the other issue - https://github.com/filestack/filestack-java/issues/81). A slightly unrelated question: When I try to upload a file via the FileStack API and OKHTTP directly, I always get 'unexpected end of stream'. Any idea why?
Some more details:
Part of the code for the image + filestack endpoint:
val fileName = "${image.id}_${System.currentTimeMillis()}"
val URL = "https://www.filestackapi.com/api/store/S3?key=<key>&mimetype=image/jpeg&filename=$fileName"
val bitmap = MediaStore.Images.Media.getBitmap(provider.context.contentResolver, image.bitmapUri)
val contentLength = BitmapCompat.getAllocationByteCount(bitmap).toLong()
Never mind - I figured out the OKHTTP upload issue. I needed to provide the following to my OkHttpClient.Builder:
.pingInterval(1, TimeUnit.SECONDS) .writeTimeout(60L, TimeUnit.SECONDS)
So, I tried 0.8.2 and the exception seems to disappear, but there's still something going wrong - when I place a log statement right after the client is created, the log statement is never called.
Log.d("FileStackHandler", "Creating client...") // Create a Filestack client val config = Config("<API KEY>") val client = Client(config) Log.d("FileStackHandler", "Created client")
Does this issue still exists?
Also - do you instantiate and use Client
class inside of a SyncAdapter
?
Also - do you instantiate and use Client class inside of a SyncAdapter?
Yep!
This is in an Android app running in debug (i.e. no proguard/obfuscation). The client is unable to initialize. Here's the stacktrace:
java.lang.IllegalStateException: Fatal Exception thrown on Scheduler.Worker thread. at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:59) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:457) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636) at java.lang.Thread.run(Thread.java:764) Caused by: java.lang.NoClassDefFoundError: com.filestack.internal.Networking at com.filestack.internal.Networking.getCdnService(Networking.java:87) at com.filestack.Client.<init>(Client.java:48) at com.myapp.app.support.DatabaseArchiver$uploadArchive$1.call(DatabaseArchiver.kt:172) at com.myapp.app.support.DatabaseArchiver$uploadArchive$1.call(DatabaseArchiver.kt:47) at rx.internal.operators.OnSubscribeFromCallable.call(OnSubscribeFromCallable.java:48) at rx.internal.operators.OnSubscribeFromCallable.call(OnSubscribeFromCallable.java:33) at rx.Observable.unsafeSubscribe(Observable.java:10150) at rx.internal.operators.OperatorSubscribeOn$1.call(OperatorSubscribeOn.java:94) at rx.internal.schedulers.CachedThreadScheduler$EventLoopWorker$1.call(CachedThreadScheduler.java:228) at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:55) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:457) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636) at java.lang.Thread.run(Thread.java:764) Caused by: java.lang.ExceptionInInitializerError at com.filestack.internal.Networking.getCdnService(Networking.java:87) at com.filestack.Client.<init>(Client.java:48) at com.myapp.api.sync.SyncService$SyncAdapter.onPerformSync(SyncService.java:153) at android.content.AbstractThreadedSyncAdapter$SyncThread.run(AbstractThreadedSyncAdapter.java:321) Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.io.InputStream java.lang.ClassLoader.getResourceAsStream(java.lang.String)' on a null object reference at com.filestack.internal.Util.getVersion(Util.java:30) at com.filestack.internal.HeaderInterceptor.<init>(HeaderInterceptor.java:22) at com.filestack.internal.Networking.buildOkHtttpClient(Networking.java:33) at com.filestack.internal.Networking.<clinit>(Networking.java:29) at com.filestack.internal.Networking.getCdnService(Networking.java:87) at com.filestack.Client.<init>(Client.java:48) at com.myapp.api.sync.SyncService$SyncAdapter.onPerformSync(SyncService.java:153) at android.content.AbstractThreadedSyncAdapter$SyncThread.run(AbstractThreadedSyncAdapter.java:321)
I'm using OKHTTP 3.11.0 currently - could this be why?