diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2018-06-09 11:35:10 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2018-06-09 11:35:10 +1200 |
commit | 44cdc3449fccd22b21fec1c9a0febea807cc2489 (patch) | |
tree | 4807bb324ad9cde120e66168ddf8b020f80e3efd /src/org/traccar/RemoteAddressHandler.java | |
parent | ff1afd37323fa634315841cc84917700f969754b (diff) | |
download | trackermap-server-44cdc3449fccd22b21fec1c9a0febea807cc2489.tar.gz trackermap-server-44cdc3449fccd22b21fec1c9a0febea807cc2489.tar.bz2 trackermap-server-44cdc3449fccd22b21fec1c9a0febea807cc2489.zip |
Release incoming reference counted objects
Diffstat (limited to 'src/org/traccar/RemoteAddressHandler.java')
-rw-r--r-- | src/org/traccar/RemoteAddressHandler.java | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/org/traccar/RemoteAddressHandler.java b/src/org/traccar/RemoteAddressHandler.java index 5555413cf..aabc5715e 100644 --- a/src/org/traccar/RemoteAddressHandler.java +++ b/src/org/traccar/RemoteAddressHandler.java @@ -15,27 +15,28 @@ */ package org.traccar; -import io.netty.channel.Channel; import io.netty.channel.ChannelHandler; +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.ChannelInboundHandlerAdapter; import org.traccar.model.Position; import java.net.InetSocketAddress; -import java.net.SocketAddress; @ChannelHandler.Sharable -public class RemoteAddressHandler extends ExtendedObjectDecoder { +public class RemoteAddressHandler extends ChannelInboundHandlerAdapter { @Override - protected Object decode(Channel channel, SocketAddress remoteAddress, Object msg) throws Exception { + public void channelRead(ChannelHandlerContext ctx, Object msg) { - String hostAddress = ((InetSocketAddress) remoteAddress).getAddress().getHostAddress(); + InetSocketAddress remoteAddress = (InetSocketAddress) ctx.channel().remoteAddress(); + String hostAddress = remoteAddress != null ? remoteAddress.getAddress().getHostAddress() : null; if (msg instanceof Position) { Position position = (Position) msg; position.set(Position.KEY_IP, hostAddress); } - return msg; + ctx.fireChannelRead(msg); } } |