/** * Sends the specified element to the server. * * @param element the element to send. * @throws NotConnectedException * @throws InterruptedException */ protected void sendStreamElement(Element element) throws NotConnectedException, InterruptedException { throwNotConnectedExceptionIfDoneAndResumptionNotPossible(); try { queue.put(element); } catch (InterruptedException e) { // put() may throw an InterruptedException for two reasons: // 1. If the queue was shut down // 2. If the thread was interrupted // so we have to check which is the case throwNotConnectedExceptionIfDoneAndResumptionNotPossible(); // If the method above did not throw, then the sending thread was interrupted throw e; } }
@Override protected void throwNotConnectedExceptionIfAppropriate() throws NotConnectedException { if (packetWriter == null) { throw new NotConnectedException(); } packetWriter.throwNotConnectedExceptionIfDoneAndResumptionNotPossible(); }