Source:
public void run() { DatagramPacket packet = null; while (this.running) { try { IceSocketWrapper localSock; synchronized (sockLock) { if (!running) return; localSock = this.sock; } int receiveBufferSize = 1500; if (packet == null) { packet = new DatagramPacket( new byte[receiveBufferSize], receiveBufferSize); } else { byte[] packetData = packet.getData(); if ((packetData == null) || (packetData.length < receiveBufferSize)) { packet.setData( new byte[receiveBufferSize], 0, receiveBufferSize); } else { packet.setLength(receiveBufferSize); } } localSock.receive(packet); if(!running) return; logger.finest("received datagram"); logger.finest(String.format("packet - addr: %s port: %d", packet.getAddress(), packet.getPort())); if (packet.getPort() < 0) { packet.setPort(0); } RawMessage rawMessage = new RawMessage( packet.getData(), packet.getLength(), new TransportAddress( packet.getAddress(), packet.getPort(), listenAddress.getTransport()), listenAddress); messageQueue.add(rawMessage); } catch (SocketException ex) { if (running) { logger.log( Level.WARNING, "Connector died: " + listenAddress + " -> " + remoteAddress, ex); stop(); errorHandler.handleFatalError( this, "A socket exception was thrown" + " while trying to receive a message.", ex); } else { } } catch (ClosedChannelException cce) { logger.log(Level.WARNING, "A net access point has gone useless:", cce); stop(); errorHandler.handleFatalError( this, "ClosedChannelException occurred while listening" + " for messages!", cce); } catch (IOException ex) { logger.log(Level.WARNING, "A net access point has gone useless:", ex); errorHandler.handleError(ex.getMessage(), ex); } catch (Throwable ex) { logger.log(Level.WARNING, "A net access point has gone useless:", ex); stop(); errorHandler.handleFatalError( this, "Unknown error occurred while listening for messages!", ex); } } }

Target:
public void run() { DatagramPacket packet = null; while (this.running) { try { IceSocketWrapper localSock; synchronized (sockLock) { if (!running) return; localSock = this.sock; } int receiveBufferSize = 1500; if (packet == null) { packet = new DatagramPacket( new byte[receiveBufferSize], receiveBufferSize); } else { byte[] packetData = packet.getData(); if ((packetData == null) || (packetData.length < receiveBufferSize)) { packet.setData( new byte[receiveBufferSize], 0, receiveBufferSize); } else { packet.setLength(receiveBufferSize); } } localSock.receive(packet); if(!running) return; logger.finest(String.format("received datagram packet - addr: %s port: %d", packet.getAddress(), packet.getPort())); if (packet.getPort() < 0) { logger.warning("Out of range packet port, resetting to 0"); packet.setPort(0); } RawMessage rawMessage = new RawMessage( packet.getData(), packet.getLength(), new TransportAddress( packet.getAddress(), packet.getPort(), listenAddress.getTransport()), listenAddress); messageQueue.add(rawMessage); } catch (SocketException ex) { if (running) { logger.log( Level.WARNING, "Connector died: " + listenAddress + " -> " + remoteAddress, ex); stop(); errorHandler.handleFatalError( this, "A socket exception was thrown" + " while trying to receive a message.", ex); } else { } } catch (ClosedChannelException cce) { logger.log(Level.WARNING, "A net access point has gone useless:", cce); stop(); errorHandler.handleFatalError( this, "ClosedChannelException occurred while listening" + " for messages!", cce); } catch (IOException ex) { logger.log(Level.WARNING, "A net access point has gone useless:", ex); errorHandler.handleError(ex.getMessage(), ex); } catch (Throwable ex) { logger.log(Level.WARNING, "A net access point has gone useless:", ex); stop(); errorHandler.handleFatalError( this, "Unknown error occurred while listening for messages!", ex); } } }