wangzihaogithub / spring-boot-protocol

springboot功能扩充-netty动态协议,可以支持各种网络协议的动态切换(单端口支持多个网络协议).支持mmap,sendfile零拷贝,http请求批量聚合
https://zihaoapi.cn
Apache License 2.0
116 stars 62 forks source link

FastJsonDataCodec不支持fastjson2.0.51 #42

Open WenTao-Love opened 1 month ago

WenTao-Love commented 1 month ago

` @Override public byte[] encodeResponseData(Object data, RpcMethod rpcMethod) { if (data == null) { return EMPTY; }

    try (SerializeWriter out = new SerializeWriter()) {//这里报错
        JSONSerializer serializer = new JSONSerializer(out, serializeConfig);
        serializer.write(data);
        return out.toBytes(CHARSET_UTF8.name());
    } catch (Exception e) {
        throw new RpcEncodeException("encodeResponseData " + rpcMethod + " fastjson error " + e, e);
    }
}

@Override public byte[] encodeChunkResponseData(Object data) { if (data == null) { return EMPTY; }

    try (SerializeWriter out = new SerializeWriter()) {//报错
        JSONSerializer serializer = new JSONSerializer(out, serializeConfig);
        serializer.write(data);
        return out.toBytes(CHARSET_UTF8.name());
    } catch (Exception e) {
        throw new RpcEncodeException("encodeChunkResponseData " + data.getClass() + " fastjson error " + e, e);
    }
}

` 这里的com.alibaba.fastjson.serializer.SerializeWriter 是 The resource type SerializeWriter does not implement java.lang.AutoCloseable

wangzihaogithub commented 1 month ago

已解决。 下次发v2.3.21的时候带上这个更新,感觉单独为这个更新一个版本不值当