Couchbase java-client IllegalReferenceCountException

时间:2015-06-09 15:16:45

标签: java couchbase

我在06-10 00:35:52.976: E/Trace(1938): error opening trace file: No such file or directory (2) 06-10 00:35:53.716: D/libEGL(1938): loaded /system/lib/egl/libEGL_emulation.so 06-10 00:35:53.716: D/libEGL(1938): loaded /system/lib/egl/libGLESv1_CM_emulation.so 06-10 00:35:53.716: D/libEGL(1938): loaded /system/lib/egl/libGLESv2_emulation.so 06-10 00:35:53.726: D/(1938): HostConnection::get() New Host Connection established 0xb8c6d868, tid 1938 06-10 00:35:53.887: W/EGL_emulation(1938): eglSurfaceAttrib not implemented 06-10 00:35:53.906: D/OpenGLRenderer(1938): Enabling debug mode 0 06-10 00:36:26.367: W/EGL_emulation(1938): eglSurfaceAttrib not implemented 06-10 00:36:39.556: D/AndroidRuntime(1938): Shutting down VM 06-10 00:36:39.556: W/dalvikvm(1938): threadid=1: thread exiting with uncaught exception (group=0xb3df9288) 06-10 00:36:39.616: E/AndroidRuntime(1938): FATAL EXCEPTION: main 06-10 00:36:39.616: E/AndroidRuntime(1938): android.os.NetworkOnMainThreadException 06-10 00:36:39.616: E/AndroidRuntime(1938): at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1117) 06-10 00:36:39.616: E/AndroidRuntime(1938): at libcore.io.BlockGuardOs.connect(BlockGuardOs.java:84) 06-10 00:36:39.616: E/AndroidRuntime(1938): at libcore.io.IoBridge.connectErrno(IoBridge.java:127) 06-10 00:36:39.616: E/AndroidRuntime(1938): at libcore.io.IoBridge.connect(IoBridge.java:112) 06-10 00:36:39.616: E/AndroidRuntime(1938): at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:192) 06-10 00:36:39.616: E/AndroidRuntime(1938): at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:459) 06-10 00:36:39.616: E/AndroidRuntime(1938): at java.net.Socket.connect(Socket.java:842) 06-10 00:36:39.616: E/AndroidRuntime(1938): at org.apache.commons.net.SocketClient.connect(SocketClient.java:182) 06-10 00:36:39.616: E/AndroidRuntime(1938): at org.apache.commons.net.SocketClient.connect(SocketClient.java:203) 06-10 00:36:39.616: E/AndroidRuntime(1938): at org.apache.commons.net.SocketClient.connect(SocketClient.java:296) 06-10 00:36:39.616: E/AndroidRuntime(1938): at com.example.android2switch.MainActivity$1.onClick(MainActivity.java:45) 06-10 00:36:39.616: E/AndroidRuntime(1938): at android.view.View.performClick(View.java:4084) 06-10 00:36:39.616: E/AndroidRuntime(1938): at android.view.View$PerformClick.run(View.java:16966) 06-10 00:36:39.616: E/AndroidRuntime(1938): at android.os.Handler.handleCallback(Handler.java:615) 06-10 00:36:39.616: E/AndroidRuntime(1938): at android.os.Handler.dispatchMessage(Handler.java:92) 06-10 00:36:39.616: E/AndroidRuntime(1938): at android.os.Looper.loop(Looper.java:137) 06-10 00:36:39.616: E/AndroidRuntime(1938): at android.app.ActivityThread.main(ActivityThread.java:4745) 06-10 00:36:39.616: E/AndroidRuntime(1938): at java.lang.reflect.Method.invokeNative(Native Method) 06-10 00:36:39.616: E/AndroidRuntime(1938): at java.lang.reflect.Method.invoke(Method.java:511) 06-10 00:36:39.616: E/AndroidRuntime(1938): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786) 06-10 00:36:39.616: E/AndroidRuntime(1938): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 06-10 00:36:39.616: E/AndroidRuntime(1938): at dalvik.system.NativeStart.main(Native Method) 尝试使用java-client-2.1.0时收到此错误:

AsyncBucket

过了一会儿我发现了。 Couchbase完全忽略了这种情况,因此没有来自图书馆的适当反馈,Netty的内部人员没有帮助。

1 个答案:

答案 0 :(得分:1)

当不止一次地使用CB的项目时,你会得到这个错误。例如,

com.couchbase.client.deps.io.netty.util.IllegalReferenceCountException: refCnt: 0, decrement: 1

这是我能够提出处理“未找到文档”方案的唯一方法。

要解决此问题,请使用val getObs = asyncBucket.get("blah") val emptyObs = getObs.isEmpty.doOnEach(...).subscribe() val docObs = getObs.doOnEach(...).subscribe()

cache()

缓存观察器将使用Couchbase的项目,然后多个订户可以安全地从缓存中消耗。

如果您使用val getObs = asyncBucket.get("blah").cache() ,修复方法是相同的。

rxscala

没有缓存会失败。