Source:
protected Object decode( Channel channel, SocketAddress remoteAddress, Object msg) throws Exception { HttpRequest request = (HttpRequest) msg; JsonObject root = Json.createReader( new StringReader(request.getContent().toString(StandardCharsets.US_ASCII))).readObject(); if (!root.containsKey("_type") || !root.getString("_type").equals("location")) { sendResponse(channel, HttpResponseStatus.BAD_REQUEST); return null; } Position position = new Position(); position.setProtocol(getProtocolName()); position.setValid(true); position.setLatitude(root.getJsonNumber("lat").doubleValue()); position.setLongitude(root.getJsonNumber("lon").doubleValue()); if (root.containsKey("vel")) { position.setSpeed(UnitsConverter.knotsFromCps(root.getInt("vel"))); } if (root.containsKey("alt")) { position.setAltitude(root.getInt("alt")); } if (root.containsKey("cog")) { position.setCourse(root.getInt("cog")); } if (root.containsKey("acc")) { position.setAccuracy(root.getInt("acc")); } if (root.containsKey("t")) { position.set("t", root.getString("t")); } if (root.containsKey("p")) { position.set("pb", root.getInt("p")); } if (root.containsKey("batt")) { position.set(Position.KEY_BATTERY, root.getInt("batt")); } position.setTime(new Date(root.getJsonNumber("tst").longValue() * 1000)); Boolean haveTopic = root.containsKey("topic"); Boolean haveTid = root.containsKey("tid"); String uniqueId = null; if (haveTopic) { uniqueId = root.getString("topic"); if (haveTid) { position.set("tid", root.getString("tid")); } } else { uniqueId = root.getString("tid"); } DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, uniqueId); if (deviceSession == null) { sendResponse(channel, HttpResponseStatus.BAD_REQUEST); return null; } position.setDeviceId(deviceSession.getDeviceId()); sendResponse(channel, HttpResponseStatus.OK); return position; }

Target:
protected Object decode( Channel channel, SocketAddress remoteAddress, Object msg) throws Exception { HttpRequest request = (HttpRequest) msg; JsonObject root = Json.createReader( new StringReader(request.getContent().toString(StandardCharsets.US_ASCII))).readObject(); if (!root.containsKey("_type") || !root.getString("_type").equals("location")) { sendResponse(channel, HttpResponseStatus.BAD_REQUEST); return null; } Position position = new Position(); position.setProtocol(getProtocolName()); position.setValid(true); position.setLatitude(root.getJsonNumber("lat").doubleValue()); position.setLongitude(root.getJsonNumber("lon").doubleValue()); if (root.containsKey("vel")) { position.setSpeed(UnitsConverter.knotsFromCps(root.getInt("vel"))); } if (root.containsKey("alt")) { position.setAltitude(root.getInt("alt")); } if (root.containsKey("cog")) { position.setCourse(root.getInt("cog")); } if (root.containsKey("acc")) { position.setAccuracy(root.getInt("acc")); } if (root.containsKey("t")) { position.set("t", root.getString("t")); } if (root.containsKey("batt")) { position.set(Position.KEY_BATTERY, root.getInt("batt")); } position.setTime(new Date(root.getJsonNumber("tst").longValue() * 1000)); String uniqueId; if (root.containsKey("topic")) { uniqueId = root.getString("topic"); if (root.containsKey("tid")) { position.set("tid", root.getString("tid")); } } else { uniqueId = root.getString("tid"); } DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, uniqueId); if (deviceSession == null) { sendResponse(channel, HttpResponseStatus.BAD_REQUEST); return null; } position.setDeviceId(deviceSession.getDeviceId()); sendResponse(channel, HttpResponseStatus.OK); return position; }