[bisq-network/bisq] Gracefully handle null data in refresh offer message and log error (PR #5788)

jmacxx notifications at github.com
Fri Oct 29 19:55:39 CEST 2021


User reported an unhandled exception popup in v1.7.5.

Just before the issue the client did get a disconnect: `b.n.p.n.Connection: proto is null because protoInputStream.read()=-1 (EOF). That is expected if client got stopped without proper shutdown.`

A offer refresh TTL message should not contain incomplete data, but is possible if the network connection is interrupted.  There are other examples of interrupted network messages already logged.



Fix is to catch and log the exception stack trace.  Just adds a try..catch block in `P2PDataStorage.refreshTTL`.
Fixes #5786

_If there is an alternative way to handle this, let me know.  @bisq-network/bisq-devs_ 


---


### Before

![crash_p2p_exception](https://user-images.githubusercontent.com/47253594/139478724-dc5cfc4b-deb4-4ae7-95c6-e80bca4dee77.png)

### After:

**[[NO POPUP SHOWN]]**

**and logfile contains a stack trace of the error:**

    WARN  b.n.p.n.Connection: proto is null because protoInputStream.read()=-1 (EOF). That is expected if client got stopped without proper shutdown. 
    java.lang.IllegalArgumentException: Cannot create P2PDataStorage.ByteArray with null byte[] array argument.
	    at bisq.network.p2p.storage.P2PDataStorage$ByteArray.verifyBytesNotEmpty(P2PDataStorage.java:1193)
	    at bisq.network.p2p.storage.P2PDataStorage$ByteArray.<init>(P2PDataStorage.java:1188)
	    at bisq.network.p2p.storage.P2PDataStorage.refreshTTL(P2PDataStorage.java:850)
	    at bisq.network.p2p.storage.P2PDataStorage.lambda$onMessage$22(P2PDataStorage.java:585)
	    at java.base/java.util.Optional.ifPresent(Optional.java:183)
	    at bisq.network.p2p.storage.P2PDataStorage.onMessage(P2PDataStorage.java:577)
	    at bisq.network.p2p.network.NetworkNode.lambda$onMessage$6(NetworkNode.java:392)
	    at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948)
	    at java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:658)
	    at bisq.network.p2p.network.NetworkNode.onMessage(NetworkNode.java:392)
	    at bisq.network.p2p.network.Connection.lambda$onBundleOfEnvelopes$11(Connection.java:470)
	    at java.base/java.util.concurrent.CopyOnWriteArrayList.forEach(CopyOnWriteArrayList.java:803)
	    at java.base/java.util.concurrent.CopyOnWriteArraySet.forEach(CopyOnWriteArraySet.java:425)
	    at bisq.network.p2p.network.Connection.lambda$onBundleOfEnvelopes$12(Connection.java:470)
	    at com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
	    at java.base/java.security.AccessController.doPrivileged(Native Method)
	    at com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
	    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
	    at com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
	    at com.sun.glass.ui.gtk.GtkApplication.lambda$runLoop$11(GtkApplication.java:277)
	    at java.base/java.lang.Thread.run(Thread.java:834)


You can view, comment on, or merge this pull request online at:

  https://github.com/bisq-network/bisq/pull/5788

-- Commit Summary --

  * <a href="https://github.com/bisq-network/bisq/pull/5788/commits/e65a992b2681906b7c134057206332afcfa6164c">Gracefully handle null data in refresh offer message and log error</a>

-- File Changes --

    M p2p/src/main/java/bisq/network/p2p/storage/P2PDataStorage.java (57)

-- Patch Links --

https://github.com/bisq-network/bisq/pull/5788.patch
https://github.com/bisq-network/bisq/pull/5788.diff

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/bisq-network/bisq/pull/5788
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bisq.network/pipermail/bisq-github/attachments/20211029/589d497d/attachment-0001.htm>


More information about the bisq-github mailing list