Skip to content

Commit 0974f6d

Browse files
author
magiclu550
committed
[commit] #1071 fix stop with npe
1 parent 2cbe030 commit 0974f6d

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

JPLS/src/main/java/cn/jsmod2/core/protocol/BinaryStream.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,9 @@ protected byte[] dataJsonEncode(String message) throws Exception{
115115
public <T> List<T> dataListDecode(byte[] data, Class<T> clz){
116116
try {
117117
String json = getDefaultJson(data);
118+
if(json == null){
119+
return null;
120+
}
118121
String[] props = splitJson(json);
119122
json = props[0];
120123
List<T> list = JSON.parseArray(json,clz);
@@ -128,6 +131,9 @@ private String getDefaultJson(byte[] data) throws Exception{
128131
byte[] packetBytes = Base64.decodeBase64(data);
129132
packetBytes = Arrays.copyOf(packetBytes, Utils.getLen(packetBytes));
130133
String json = new String(packetBytes,properties.getProperty("decode"));
134+
if(json.equals("null")){
135+
return null;
136+
}
131137
json = json.substring(json.indexOf("-")+1);
132138
if(json.contains("~")) {
133139
json = json.substring(0, json.indexOf("~"));
@@ -139,6 +145,7 @@ private String getDefaultJson(byte[] data) throws Exception{
139145
public <T> T dataObjectDecode(byte[] data,Class<T> clz){
140146
try{
141147
String json = getDefaultJson(data);
148+
if(json == null)return null;
142149

143150
//{main-object}|cn.jsmod2.player-xxx:xxx|cn.jsmod2.team-class:xxx
144151
String[] props = splitJson(json);

JPLS/src/main/java/cn/jsmod2/core/protocol/Response.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ public List getProtocolArray(boolean getArray){
5151
//转化为base64解密后的,之后再加密 getBytes
5252
try {
5353
String message = new String(Base64.getDecoder().decode(future.get()), properties.getProperty(FileSystem.SERVER_DECODE));
54+
if(message.equals("null")){
55+
return null;
56+
}
5457
String[] protocols = message.split("@!");
5558
if(!getArray) {
5659
for (String protocol : protocols) {

0 commit comments

Comments
 (0)