Source:
<code>private void receiveNextDatagramFromNetwork(DatagramPacket packet) throws IOException { DatagramSocket currentSocket = getSocket(); if (currentSocket == null) { return; } currentSocket.receive(packet); if (packet.getLength() == 0) { return; } InetSocketAddress peerAddress = new InetSocketAddress(packet.getAddress(), packet.getPort()); byte[] data = Arrays.copyOfRange(packet.getData(), packet.getOffset(), packet.getLength()); List<Record> records = Record.fromByteArray(data, peerAddress); LOGGER.debug("Received DTLS records using a byte datagram buffer", records.size(), inboundDatagramBufferSize); if (!running.get()) { LOGGER.debug("Execution shutdown while processing incoming records from peer: {}", peerAddress); return; } SerialExecutor serialExecutor = getSerialExecutor(peerAddress); if (serialExecutor == null) { LOGGER.debug("Execution cache is full while processing incoming records from peer: {}", peerAddress); return; } for (final Record record : records) { try { serialExecutor.execute(new Runnable() { @Override public void run() { if (running.get()) { <START> processRecord(record); <END> } } }); } catch (RejectedExecutionException e) { LOGGER.debug("Execution rejected while processing record [type: {}, peer: {}]", record.getType(), peerAddress, e); break; } catch (RuntimeException e) { LOGGER.info("Unexpected error occurred while processing record [type: {}, peer: {}]", record.getType(), peerAddress, e); terminateConnection(peerAddress, e, AlertLevel.FATAL, AlertDescription.INTERNAL_ERROR); break; } } }</code><technical_language>bad remove discard record create a new "task"</technical_language>

Target:
private void receiveNextDatagramFromNetwork(DatagramPacket packet) throws IOException { DatagramSocket currentSocket = getSocket(); if (currentSocket == null) { return; } currentSocket.receive(packet); if (packet.getLength() == 0) { return; } InetSocketAddress peerAddress = new InetSocketAddress(packet.getAddress(), packet.getPort()); byte[] data = Arrays.copyOfRange(packet.getData(), packet.getOffset(), packet.getLength()); List<Record> records = Record.fromByteArray(data, peerAddress); LOGGER.debug("Received DTLS records using a byte datagram buffer", records.size(), inboundDatagramBufferSize); if (records.isEmpty()) { return; } if (!running.get()) { LOGGER.debug("Execution shutdown while processing incoming records from peer: {}", peerAddress); return; } final Connection connection = connectionStore.get(peerAddress); if (connection == null && (records.size() != 1 || !records.get(0).isNewClientHello())) { LOGGER.debug("Discarding records from received without existing connection", records.size(), peerAddress); return; } SerialExecutor serialExecutor = getSerialExecutor(peerAddress); if (serialExecutor == null) { LOGGER.debug("Execution cache is full while processing incoming records from peer: {}", peerAddress); return; } for (final Record record : records) { try { serialExecutor.execute(new Runnable() { @Override public void run() { if (running.get()) { processRecord(record, connection); } } }); } catch (RejectedExecutionException e) { LOGGER.debug("Execution rejected while processing record [type: {}, peer: {}]", record.getType(), peerAddress, e); break; } catch (RuntimeException e) { if (connection != null) { LOGGER.info("Unexpected error occurred while processing record [type: {}, peer: {}]", record.getType(), peerAddress, e); terminateConnection(connection, e, AlertLevel.FATAL, AlertDescription.INTERNAL_ERROR); } break; } } }