From c688921734998c645f45936f241e09c4440cac0e Mon Sep 17 00:00:00 2001 From: T H Panton Date: Fri, 2 Aug 2024 15:42:18 +0100 Subject: [PATCH] Fix debug related crashes --- src/main/java/pe/pi/sctp4j/sctp/SCTPMessage.java | 2 ++ src/main/java/pe/pi/sctp4j/sctp/SCTPStream.java | 5 +++-- src/main/java/pe/pi/sctp4j/sctp/dataChannel/DECP/DCOpen.java | 5 +++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/java/pe/pi/sctp4j/sctp/SCTPMessage.java b/src/main/java/pe/pi/sctp4j/sctp/SCTPMessage.java index e96d4fe..063e213 100644 --- a/src/main/java/pe/pi/sctp4j/sctp/SCTPMessage.java +++ b/src/main/java/pe/pi/sctp4j/sctp/SCTPMessage.java @@ -199,6 +199,8 @@ private void dcepMessageDeal(byte[] data) { } } catch (Exception x) { Log.error("Problem with DCOpen " + x.getMessage()); + if (Log.getLevel() >= Log.DEBUG) {x.printStackTrace();} + } } diff --git a/src/main/java/pe/pi/sctp4j/sctp/SCTPStream.java b/src/main/java/pe/pi/sctp4j/sctp/SCTPStream.java index 4769b24..ce998d6 100644 --- a/src/main/java/pe/pi/sctp4j/sctp/SCTPStream.java +++ b/src/main/java/pe/pi/sctp4j/sctp/SCTPStream.java @@ -73,6 +73,7 @@ public SCTPStreamListener getSCTPStreamListener() { return _sl; } + @Override public String toString() { return this.getClass().getSimpleName() + "[" + this._sno + "]" @@ -132,7 +133,7 @@ public void setLabel(String l) { } public Integer getNum() { - return new Integer(_sno); + return _sno; } public Chunk[] append(DataChunk dc) { @@ -158,7 +159,7 @@ public void setBehave(SCTPStreamBehaviour behave) { * @param chunk */ public void outbound(DataChunk chunk) { - chunk.setStreamId(_sno.intValue()); + chunk.setStreamId(_sno); // roll seqno here.... hopefully.... } diff --git a/src/main/java/pe/pi/sctp4j/sctp/dataChannel/DECP/DCOpen.java b/src/main/java/pe/pi/sctp4j/sctp/dataChannel/DECP/DCOpen.java index 542e22c..0cf5bd7 100644 --- a/src/main/java/pe/pi/sctp4j/sctp/dataChannel/DECP/DCOpen.java +++ b/src/main/java/pe/pi/sctp4j/sctp/dataChannel/DECP/DCOpen.java @@ -184,7 +184,8 @@ public boolean isAck() { } public SCTPStreamBehaviour mkStreamBehaviour() { - Log.debug("Making a behaviour for dcep stream " + new String(_label)); + String loglab = _label == null?"_null_":new String(_label); + Log.debug("Making a behaviour for dcep stream " + loglab); SCTPStreamBehaviour behave = null; switch (_chanType) { case RELIABLE: @@ -205,7 +206,7 @@ public SCTPStreamBehaviour mkStreamBehaviour() { break; } if (behave != null) { - Log.debug(new String(_label) + " behaviour is " + behave.getClass().getSimpleName()); + Log.debug(loglab + " behaviour is " + behave.getClass().getSimpleName()); } return behave;