mirror of
https://github.com/tiennm99/zfoo.git
synced 2026-08-20 22:24:27 +00:00
fix[protocol]: null point
This commit is contained in:
@@ -430,12 +430,6 @@ public abstract class ByteBufUtils {
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
//---------------------------------以下方法会被字节码生成的代码调用--------------------------------------
|
||||
public static boolean writePacketFlag(ByteBuf byteBuf, Object packet) {
|
||||
boolean flag = packet == null;
|
||||
byteBuf.writeBoolean(!flag);
|
||||
return flag;
|
||||
}
|
||||
|
||||
public static void writePacketCollection(ByteBuf byteBuf, Collection<?> collection, IProtocolRegistration protocolRegistration) {
|
||||
if (collection == null) {
|
||||
byteBuf.writeByte(0);
|
||||
|
||||
@@ -183,6 +183,7 @@ public abstract class EnhanceUtils {
|
||||
|
||||
var builder = new StringBuilder();
|
||||
builder.append("{");
|
||||
builder.append("if ($2 == null) { $1.writeByte(0); return; }");
|
||||
builder.append(StringUtils.format("{} packet = ({})$2;", packetClazz.getName(), packetClazz.getName()));
|
||||
if (registration.isCompatible()) {
|
||||
builder.append("int beforeWriteIndex = $1.writerIndex();");
|
||||
|
||||
@@ -74,7 +74,7 @@ public class ProtocolRegistration implements IProtocolRegistration {
|
||||
public void write(ByteBuf byteBuf, Object packet) {
|
||||
if (packet == null) {
|
||||
// equals with ByteBufUtils.writeInt(byteBuf, 0);
|
||||
ByteBufUtils.writeByte(byteBuf, (byte) 0);
|
||||
byteBuf.writeByte(0);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user