解码异常信息中增加原始报文
parent
a317dc51ec
commit
c869bd2280
2
pom.xml
2
pom.xml
|
@ -62,7 +62,7 @@
|
|||
<dependency>
|
||||
<groupId>io.netty</groupId>
|
||||
<artifactId>netty-handler</artifactId>
|
||||
<version>4.1.65.Final</version>
|
||||
<version>4.1.66.Final</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
|
|
@ -2,6 +2,7 @@ package io.github.yezhihao.netmc.codec;
|
|||
|
||||
import io.github.yezhihao.netmc.session.Session;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.ByteBufUtil;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInboundHandlerAdapter;
|
||||
|
@ -31,7 +32,7 @@ public class MessageDecoderWrapper extends ChannelInboundHandlerAdapter {
|
|||
ctx.fireChannelRead(message);
|
||||
buf.skipBytes(buf.readableBytes());
|
||||
} catch (Exception e) {
|
||||
throw new DecoderException(e);
|
||||
throw new DecoderException(ByteBufUtil.hexDump(buf), e);
|
||||
} finally {
|
||||
buf.release();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
package io.github.yezhihao.netmc.util;
|
||||
|
||||
import java.util.AbstractCollection;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* @author yezhihao
|
||||
* home https://gitee.com/yezhihao/jt808-server
|
||||
*/
|
||||
public final class AdapterCollection<S, T> extends AbstractCollection<T> {
|
||||
|
||||
private final Collection<S> src;
|
||||
private final Iterator<T> iterator;
|
||||
|
||||
public AdapterCollection(Collection<S> src, Function<S, T> function) {
|
||||
this.src = src;
|
||||
this.iterator = new Iterator<T>() {
|
||||
|
||||
private final Function<S, T> f = function;
|
||||
private final Iterator<S> it = src.iterator();
|
||||
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
return it.hasNext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public T next() {
|
||||
return f.apply(it.next());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
it.remove();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<T> iterator() {
|
||||
return iterator;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return src.size();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue