File 1227-jinterface-Fix-a-NullPointerException-in-AbstractCon.patch of Package erlang

From 89b49a25a1a03281c1f7452b37184dfb4621d79f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9r=C3=B4me=20de=20Bretagne?=
 <jerome.debretagne@gmail.com>
Date: Sun, 16 May 2021 10:53:00 +0200
Subject: [PATCH] jinterface: Fix a NullPointerException in AbstractConnection

After a call to close(), the socket is set to null which could
lead to a NullPointerException in the receive_loop when handling
tick messages. End the receive_loop instead in this case.
---
 .../com/ericsson/otp/erlang/AbstractConnection.java        | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/lib/jinterface/java_src/com/ericsson/otp/erlang/AbstractConnection.java b/lib/jinterface/java_src/com/ericsson/otp/erlang/AbstractConnection.java
index fb7c6869b7..7ea5d52da7 100644
--- a/lib/jinterface/java_src/com/ericsson/otp/erlang/AbstractConnection.java
+++ b/lib/jinterface/java_src/com/ericsson/otp/erlang/AbstractConnection.java
@@ -565,6 +565,11 @@ public abstract class AbstractConnection extends Thread {
                     // received tick? send tock!
                     if (len == 0) {
                         synchronized (this) {
+                            if (socket == null) {
+                                // protect from a potential thin race when the
+                                // connection to the remote node is closed
+                                throw new IOException("socket was closed");
+                            }
                             OutputStream out = socket.getOutputStream();
                             out.write(tock);
                             out.flush();
-- 
2.26.2

openSUSE Build Service is sponsored by