/** * @tests serialization/deserialization compatibility. */ @TestTargets({ @TestTargetNew( level = TestLevel.COMPLETE, notes = "Verifies serialization/deserialization compatibility.", method = "!SerializationSelf", args = {} ), @TestTargetNew( level = TestLevel.PARTIAL_COMPLETE, notes = "Verifies serialization/deserialization compatibility.", method = "NotYetBoundException", args = {} ) }) public void testSerializationSelf() throws Exception { SerializationTest.verifySelf(new NotYetBoundException()); }
/** * @tests serialization/deserialization compatibility with RI. */ @TestTargets({ @TestTargetNew( level = TestLevel.COMPLETE, notes = "Verifies serialization/deserialization compatibility.", method = "!SerializationGolden", args = {} ), @TestTargetNew( level = TestLevel.PARTIAL_COMPLETE, notes = "Verifies serialization/deserialization compatibility.", method = "NotYetBoundException", args = {} ) }) public void testSerializationCompatibility() throws Exception { SerializationTest.verifyGolden(this, new NotYetBoundException()); }
@Override public Set<Association> associations() throws ClosedChannelException, NotYetBoundException { synchronized (stateLock) { if (!isOpen()) throw new ClosedChannelException(); if (!isBound()) throw new NotYetBoundException(); return Collections.unmodifiableSet(associationMap.keySet()); } }
public SocketChannel accept () throws IOException { if (!isOpen()) throw new ClosedChannelException(); if (!serverSocket.isBound()) throw new NotYetBoundException(); boolean completed = false; try { begin(); VMChannel client = channel.accept(); if (client == null) return null; else { completed = true; return new SocketChannelImpl(provider(), client, false); } } finally { end (completed); } }
@Override public SocketChannel accept() throws IOException { if (!isOpen()) { throw new ClosedChannelException(); } if (!socket.isBound()) { throw new NotYetBoundException(); } // Create an empty socket channel. This will be populated by ServerSocketAdapter.implAccept. SocketChannelImpl result = new SocketChannelImpl(provider(), false); try { begin(); synchronized (acceptLock) { try { socket.implAccept(result); } catch (SocketTimeoutException e) { if (shouldThrowSocketTimeoutExceptionFromAccept(e)) { throw e; } // Otherwise, this is a non-blocking socket and there's nothing ready, so we'll // fall through and return null. } } } finally { end(result.isConnected()); } return result.isConnected() ? result : null; }
/** * @tests {@link java.nio.channels.NotYetBoundException#NotYetBoundException()} */ public void test_Constructor() { NotYetBoundException e = new NotYetBoundException(); assertNull(e.getMessage()); assertNull(e.getLocalizedMessage()); assertNull(e.getCause()); }
public void testAccept_Block_NotYetBound() throws IOException { assertTrue(this.serverChannel.isOpen()); assertTrue(this.serverChannel.isBlocking()); try { this.serverChannel.accept(); fail("Should throw NotYetBoundException"); } catch (NotYetBoundException e) { // correct } }
public void testAccept_NonBlock_NotYetBound() throws IOException { assertTrue(this.serverChannel.isOpen()); this.serverChannel.configureBlocking(false); try { this.serverChannel.accept(); fail("Should throw NotYetBoundException"); } catch (NotYetBoundException e) { // correct } }
@Override public SocketChannel accept() throws IOException { if (!isOpen()) { throw new ClosedChannelException(); } if (!isBound) { throw new NotYetBoundException(); } // TODO: pass in the SelectorProvider used to create this ServerSocketChannelImpl? // Create an empty socket channel. This will be populated by ServerSocketAdapter.accept. SocketChannelImpl result = new SocketChannelImpl(SelectorProvider.provider(), false); Socket resultSocket = result.socket(); try { begin(); synchronized (acceptLock) { synchronized (blockingLock()) { boolean isBlocking = isBlocking(); if (!isBlocking) { int[] tryResult = new int[1]; boolean success = Platform.getNetworkSystem().select( new FileDescriptor[] { fd }, new FileDescriptor[0], 1, 0, 0, tryResult); if (!success || 0 == tryResult[0]) { // no pending connections, returns immediately. return null; } } // do accept. do { try { socket.accept(resultSocket, result); // select successfully, break out immediately. break; } catch (SocketTimeoutException e) { // continue to accept if the channel is in blocking mode. } } while (isBlocking); } } } finally { end(resultSocket.isConnected()); } return result; }
public SocketChannel accept() throws IOException { if (!isOpen()) { throw new ClosedChannelException(); } if (!isBound) { throw new NotYetBoundException(); } SocketChannel sockChannel = new SocketChannelImpl(SelectorProvider.provider(), false); Socket socketGot = sockChannel.socket(); try { begin(); synchronized (acceptLock) { boolean isBlocking = isBlocking(); if (!isBlocking) { // for non blocking mode, use select to see whether // there are any pending connections. int[] tryResult = new int[1]; boolean success = Platform.getNetworkSystem().select( new FileDescriptor[] { this.fd }, new FileDescriptor[0], 1, 0, 0, tryResult); if (!success || 0 == tryResult[0]) { // no pending connections, returns immediately. return null; } } // do accept. do { try { ((ServerSocketAdapter) socket).accept(socketGot, (SocketChannelImpl) sockChannel); // select successfully, break out immediately. break; } catch (SocketTimeoutException e) { // continue to accept if the channel is in blocking // mode. } } while (isBlocking); } } finally { end(socketGot.isConnected()); } return sockChannel; }
/** * @tests serialization/deserialization compatibility. */ public void testSerializationSelf() throws Exception { SerializationTest.verifySelf(new NotYetBoundException()); }
/** * @tests serialization/deserialization compatibility with RI. */ public void testSerializationCompatibility() throws Exception { SerializationTest.verifyGolden(this, new NotYetBoundException()); }
public SocketChannel accept() throws IOException { if (!isOpen()) { throw new ClosedChannelException(); } if (!isBound) { throw new NotYetBoundException(); } SocketChannel sockChannel = SocketChannel.open(); Socket socketGot = sockChannel.socket(); try { begin(); synchronized (acceptLock) { synchronized (blockingLock()) { boolean isBlocking = isBlocking(); if (!isBlocking) { // for non blocking mode, use select to see whether // there are any pending connections. int[] tryResult = Platform.getNetworkSystem().select( new FileDescriptor[] { this.fd }, new FileDescriptor[0], 0); if (0 == tryResult.length || 0 == tryResult[0]) { // no pending connections, returns immediately. return null; } } // do accept. do { try { ((ServerSocketAdapter) socket).accept(socketGot, (SocketChannelImpl) sockChannel); // select successfully, break out immediately. break; } catch (SocketTimeoutException e) { // continue to accept if the channel is in blocking // mode. } } while (isBlocking); } } } finally { end(socketGot.isConnected()); } return sockChannel; }