use of java.nio.channels.UnsupportedAddressTypeException in project j2objc by google.
the class DatagramChannelImpl method bind.
/** @hide Until ready for a public API change */
@Override
public synchronized DatagramChannel bind(SocketAddress local) throws IOException {
checkOpen();
if (isBound) {
throw new AlreadyBoundException();
}
if (local == null) {
local = new InetSocketAddress(Inet4Address.ANY, 0);
} else if (!(local instanceof InetSocketAddress)) {
throw new UnsupportedAddressTypeException();
}
InetSocketAddress localAddress = (InetSocketAddress) local;
NetworkBridge.bind(fd, localAddress.getAddress(), localAddress.getPort());
onBind(true);
return this;
}
use of java.nio.channels.UnsupportedAddressTypeException in project netty by netty.
the class AbstractAddressResolver method resolve.
@Override
public final Future<T> resolve(SocketAddress address) {
if (!isSupported(checkNotNull(address, "address"))) {
// Address type not supported by the resolver
return executor().newFailedFuture(new UnsupportedAddressTypeException());
}
if (isResolved(address)) {
// Resolved already; no need to perform a lookup
@SuppressWarnings("unchecked") final T cast = (T) address;
return executor.newSucceededFuture(cast);
}
try {
@SuppressWarnings("unchecked") final T cast = (T) address;
final Promise<T> promise = executor().newPromise();
doResolve(cast, promise);
return promise;
} catch (Exception e) {
return executor().newFailedFuture(e);
}
}
use of java.nio.channels.UnsupportedAddressTypeException in project netty by netty.
the class AbstractAddressResolver method resolveAll.
@Override
public final Future<List<T>> resolveAll(SocketAddress address, Promise<List<T>> promise) {
checkNotNull(address, "address");
checkNotNull(promise, "promise");
if (!isSupported(address)) {
// Address type not supported by the resolver
return promise.setFailure(new UnsupportedAddressTypeException());
}
if (isResolved(address)) {
// Resolved already; no need to perform a lookup
@SuppressWarnings("unchecked") final T cast = (T) address;
return promise.setSuccess(Collections.singletonList(cast));
}
try {
@SuppressWarnings("unchecked") final T cast = (T) address;
doResolveAll(cast, promise);
return promise;
} catch (Exception e) {
return promise.setFailure(e);
}
}
use of java.nio.channels.UnsupportedAddressTypeException in project netty by netty.
the class AbstractAddressResolver method resolve.
@Override
public final Future<T> resolve(SocketAddress address, Promise<T> promise) {
checkNotNull(address, "address");
checkNotNull(promise, "promise");
if (!isSupported(address)) {
// Address type not supported by the resolver
return promise.setFailure(new UnsupportedAddressTypeException());
}
if (isResolved(address)) {
// Resolved already; no need to perform a lookup
@SuppressWarnings("unchecked") final T cast = (T) address;
return promise.setSuccess(cast);
}
try {
@SuppressWarnings("unchecked") final T cast = (T) address;
doResolve(cast, promise);
return promise;
} catch (Exception e) {
return promise.setFailure(e);
}
}
use of java.nio.channels.UnsupportedAddressTypeException in project robovm by robovm.
the class UnsupportedAddressTypeExceptionTest method test_Constructor.
/**
* @tests {@link java.nio.channels.UnsupportedAddressTypeException#UnsupportedAddressTypeException()}
*/
public void test_Constructor() {
UnsupportedAddressTypeException e = new UnsupportedAddressTypeException();
assertNull(e.getMessage());
assertNull(e.getLocalizedMessage());
assertNull(e.getCause());
}
Aggregations