Java 类java.nio.channels.UnresolvedAddressException 实例源码

项目:trpc    文件:AsyncTrpcClient.java   
@Override
@SuppressWarnings("unchecked")
public <X extends TAsyncClient> X getClient(final Class<X> clazz) {
    return (X) super.clients.computeIfAbsent(ClassNameUtils.getOuterClassName(clazz), (className) -> {
        TProtocolFactory protocolFactory = (TProtocolFactory) tTransport -> {
            TProtocol protocol = new TBinaryProtocol(tTransport);
            return new TMultiplexedProtocol(protocol, className);
        };
        try {
            return clazz.getConstructor(TProtocolFactory.class, TAsyncClientManager.class, TNonblockingTransport.class)
                    .newInstance(protocolFactory, this.clientManager, this.transport);
        } catch (Throwable e) {
            if (e instanceof UnresolvedAddressException) {
                this.isOpen = false;
            }
            return null;
        }
    });
}
项目:cordova-websocket-clientcert    文件:WebSocketClient.java   
@Override
public void onError(Exception ex) {
    StringWriter stringWriter = new StringWriter();
    JsonWriter writer = new JsonWriter(stringWriter);

    try {
        writer.beginObject();
        writer.name("event").value("onError");

        if (ex instanceof UnresolvedAddressException) {
            writer.name("errorCode").value("ERR_NAME_NOT_RESOLVED");
            writer.name("errorMessage").value("Unable to resolve address. Please check the url and your network connection");
        } else {
            writer.name("errorCode").value("ERR_NAME_UNKNOWN");
            writer.name("errorMessage").value("Unknown error was thrown");
        }

        writer.endObject();
    } catch (IOException e) {
        e.printStackTrace();
    }

    this.callback(PluginResult.Status.OK, stringWriter.toString());
}
项目:DarwinSPL    文件:DwAnalysesClient.java   
protected String sendMessageToHyVarRec(String message, URI uri) throws UnresolvedAddressException, ExecutionException, InterruptedException, TimeoutException {
    HttpClient hyvarrecClient = new HttpClient();
    try {
        hyvarrecClient.start();
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        return null;
    }
    URI hyvarrecUri = uri;
    Request hyvarrecRequest = hyvarrecClient.POST(hyvarrecUri);
    hyvarrecRequest.header(HttpHeader.CONTENT_TYPE, "application/json");
    hyvarrecRequest.content(new StringContentProvider(message), "application/json");
    ContentResponse hyvarrecResponse;
    String hyvarrecAnswerString = "";
    hyvarrecResponse = hyvarrecRequest.send();
    hyvarrecAnswerString = hyvarrecResponse.getContentAsString();

    // Only for Debug
    System.err.println("HyVarRec Answer: "+hyvarrecAnswerString);

    return hyvarrecAnswerString;
}
项目:SilverKing    文件:AsyncBase.java   
public T newOutgoingConnection(InetSocketAddress dest, ConnectionListener listener) throws IOException {
    SocketChannel   channel;

    channel = SocketChannel.open();
    if (dest.isUnresolved()) {
           Log.warning("Unresolved InetSocketAddress: "+ dest);
           throw new ConnectException("Unresolved InetSocketAddress"+ dest.toString());
    }
    LWTThreadUtil.setBlocked();
    try {
        channel.socket().connect(dest, defSocketConnectTimeout);
        //channel.connect(dest);
    } catch (UnresolvedAddressException uae) {
        Log.logErrorWarning(uae);
        Log.warning(dest);
        throw new ConnectException(dest.toString());
    } finally {
        LWTThreadUtil.setNonBlocked();
    }
    return addConnection(channel, listener);
}
项目:javify    文件:SocketChannelImpl.java   
public boolean connect (SocketAddress remote, int timeout) throws IOException
{
  if (!isOpen())
    throw new ClosedChannelException();

  if (isConnected())
    throw new AlreadyConnectedException();

  if (connectionPending)
    throw new ConnectionPendingException();

  if (!(remote instanceof InetSocketAddress))
    throw new UnsupportedAddressTypeException();

  connectAddress = (InetSocketAddress) remote;

  if (connectAddress.isUnresolved())
    throw new UnresolvedAddressException();

  connected = channel.connect(connectAddress, timeout);
  connectionPending = !connected;
  return connected;
}
项目:jvm-stm    文件:SocketChannelImpl.java   
public boolean connect (SocketAddress remote, int timeout) throws IOException
{
  if (!isOpen())
    throw new ClosedChannelException();

  if (isConnected())
    throw new AlreadyConnectedException();

  if (connectionPending)
    throw new ConnectionPendingException();

  if (!(remote instanceof InetSocketAddress))
    throw new UnsupportedAddressTypeException();

  connectAddress = (InetSocketAddress) remote;

  if (connectAddress.isUnresolved())
    throw new UnresolvedAddressException();

  connected = channel.connect(connectAddress, timeout);
  connectionPending = !connected;
  return connected;
}
项目:whiskey    文件:Socket.java   
public ConnectFuture connect() {
    connectFuture = new ConnectFuture();

    runLoop.execute(new Runnable() {
        public void run() {
            try {
                channel = SocketChannel.open();
                channel.configureBlocking(false);
                channel.connect(new InetSocketAddress(origin.getHost(), origin.getPort()));
                reregister();
            } catch (IOException | UnresolvedAddressException e) {
                connectFuture.fail(e);
                closed = true;
            }
        }
    });

    return connectFuture;
}
项目:Netlet    文件:AbstractClientTest.java   
@Test
public void testUnresolvedException() throws IOException, InterruptedException
{
  final DefaultEventLoop eventLoop = DefaultEventLoop.createEventLoop("test");
  final CountDownLatch handled = new CountDownLatch(1);
  final ClientImpl client = new ClientImpl()
  {
    @Override
    public void handleException(Exception cce, EventLoop el)
    {
      assertSame(el, eventLoop);
      assertTrue(cce instanceof RuntimeException);
      assertTrue(cce.getCause() instanceof UnresolvedAddressException);
      super.handleException(cce, el);
      handled.countDown();
    }
  };
  verifyUnresolvedException(client, eventLoop, handled);
}
项目:Netlet    文件:AbstractLengthPrependerClientTest.java   
@Test
public void testUnresolvedException() throws IOException, InterruptedException
{
  final DefaultEventLoop eventLoop = DefaultEventLoop.createEventLoop("test");
  final CountDownLatch handled = new CountDownLatch(1);
  final AbstractLengthPrependerClient ci = new AbstractLengthPrependerClient()
  {
    @Override
    public void onMessage(byte[] buffer, int offset, int size)
    {
      fail();
    }

    @Override
    public void handleException(Exception cce, EventLoop el)
    {
      assertSame(el, eventLoop);
      assertTrue(cce instanceof RuntimeException);
      assertTrue(cce.getCause() instanceof UnresolvedAddressException);
      super.handleException(cce, el);
      handled.countDown();
    }
  };
  verifyUnresolvedException(ci, eventLoop, handled);
}
项目:xenqtt    文件:SyncMqttClientIT.java   
@Test
public void testConstructor_InvalidHost() throws Exception {

    Throwable thrown = null;
    try {
        client = new SyncMqttClient("tcp://foo:1883", listener, 5, config);
        fail("expected exception");
    } catch (MqttInvocationException e) {
        thrown = e.getRootCause();
        assertEquals(UnresolvedAddressException.class, thrown.getClass());
    }

    verify(listener, timeout(5000)).disconnected(any(SyncMqttClient.class), same(thrown), eq(false));
    verify(reconnectionStrategy).clone();

    verifyNoMoreInteractions(listener, reconnectionStrategy);
}
项目:xenqtt    文件:AsyncMqttClientIT.java   
@Test
public void testConstructor_InvalidHost() throws Exception {

    Throwable thrown = null;
    try {
        client = new AsyncMqttClient("tcp://foo:1883", listener, 5, config);
        fail("expected exception");
    } catch (MqttInvocationException e) {
        thrown = e.getRootCause();
        assertEquals(UnresolvedAddressException.class, thrown.getClass());
    }

    verify(listener, timeout(5000)).disconnected(any(AsyncMqttClient.class), same(thrown), eq(false));
    verify(reconnectionStrategy).clone();

    verifyNoMoreInteractions(listener, reconnectionStrategy);
}
项目:In-the-Box-Fork    文件:DatagramChannelTest.java   
/**
 * Test method for 'DatagramChannelImpl.connect(SocketAddress)'
 *
 * @throws IOException
 */
@TestTargetNew(
    level = TestLevel.PARTIAL_COMPLETE,
    notes = "Verifies UnresolvedAddressException.",
    method = "connect",
    args = {java.net.SocketAddress.class}
)
public void testConnect_Unresolved() throws IOException {
    assertFalse(this.channel1.isConnected());
    InetSocketAddress unresolved = new InetSocketAddress(
            "unresolved address", 1080);
    try {
        this.channel1.connect(unresolved);
        fail("Should throw an UnresolvedAddressException here.");
    } catch (UnresolvedAddressException e) {
        // OK.
    }
}
项目:In-the-Box-Fork    文件:UnresolvedAddressExceptionTest.java   
/**
 * @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 = "UnresolvedAddressException",
        args = {}
    )
})
public void testSerializationSelf() throws Exception {

    SerializationTest.verifySelf(new UnresolvedAddressException());
}
项目:In-the-Box-Fork    文件:UnresolvedAddressExceptionTest.java   
/**
 * @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 = "UnresolvedAddressException",
        args = {}
    )
})
public void testSerializationCompatibility() throws Exception {

    SerializationTest.verifyGolden(this, new UnresolvedAddressException());
}
项目:questdb    文件:ClientConfig.java   
public SocketChannel openSocketChannel() throws JournalNetworkException {
    if (getNodeCount() == 0) {
        if (isMultiCastEnabled()) {
            addNode(pollServerAddress());
        } else {
            throw new JournalNetworkException("No server nodes");
        }
    }

    List<ServerNode> nodes = getServerNodes();

    for (int i = 0, k = nodes.size(); i < k; i++) {
        ServerNode node = nodes.get(i);
        try {
            return openSocketChannel0(node);
        } catch (UnresolvedAddressException | IOException e) {
            LOG.info().$("Node ").$(node).$(" is unavailable [").$(e.getMessage()).$(']').$();
        }
    }

    throw new JournalNetworkException("Could not connect to any node");
}
项目:JamVM-PH    文件:SocketChannelImpl.java   
public boolean connect (SocketAddress remote, int timeout) throws IOException
{
  if (!isOpen())
    throw new ClosedChannelException();

  if (isConnected())
    throw new AlreadyConnectedException();

  if (connectionPending)
    throw new ConnectionPendingException();

  if (!(remote instanceof InetSocketAddress))
    throw new UnsupportedAddressTypeException();

  connectAddress = (InetSocketAddress) remote;

  if (connectAddress.isUnresolved())
    throw new UnresolvedAddressException();

  connected = channel.connect(connectAddress, timeout);
  connectionPending = !connected;
  return connected;
}
项目:rest4j    文件:TestHttpNettyClient.java   
@Test(enabled = false)
public void testBadAddress() throws InterruptedException, IOException, TimeoutException
{
  HttpNettyClient client = new HttpNettyClient(_factory, _scheduler, 1, 30000, 10000, 500,1024*1024*2);

  RestRequest r = new RestRequestBuilder(URI.create("http://this.host.does.not.exist.ctriposs.com")).build();
  FutureCallback<RestResponse> cb = new FutureCallback<RestResponse>();
  TransportCallback<RestResponse> callback = new TransportCallbackAdapter<RestResponse>(cb);
  client.restRequest(r, new RequestContext(), new HashMap<String,String>(), callback);
  try
  {
    cb.get(30, TimeUnit.SECONDS);
    Assert.fail("Get was supposed to fail");
  }
  catch (ExecutionException e)
  {
    verifyCauseChain(e, RemoteInvocationException.class, UnresolvedAddressException.class);
  }
}
项目:kafka-spark-consumer    文件:KafkaUtils.java   
public static ConsumerRecords<byte[], byte[]> fetchMessages(
  KafkaConfig config, KafkaConsumer<byte[], byte[]> consumer, Partition partition,
  long offset) {
  String topic = (String) config._stateConf.get(Config.KAFKA_TOPIC);
  int partitionId = partition.partition;
  TopicPartition  topicAndPartition = new TopicPartition (topic, partitionId);
  consumer.seek(topicAndPartition, offset);
  ConsumerRecords<byte[], byte[]> records;
  try {
    records = consumer.poll(config._fillFreqMs / 2);
  } catch(OffsetOutOfRangeException oore) {
    throw new OutOfRangeException(oore.getMessage());
  } catch (Exception e) {
    if (e instanceof ConnectException
      || e instanceof SocketTimeoutException || e instanceof IOException
      || e instanceof UnresolvedAddressException) {

      LOG.warn("Network error when fetching messages:", e);
      throw new FailedFetchException(e);
    } else {
      throw new RuntimeException(e);
    }
  }
  return records;
}
项目:classpath    文件:SocketChannelImpl.java   
public boolean connect (SocketAddress remote, int timeout) throws IOException
{
  if (!isOpen())
    throw new ClosedChannelException();

  if (isConnected())
    throw new AlreadyConnectedException();

  if (connectionPending)
    throw new ConnectionPendingException();

  if (!(remote instanceof InetSocketAddress))
    throw new UnsupportedAddressTypeException();

  connectAddress = (InetSocketAddress) remote;

  if (connectAddress.isUnresolved())
    throw new UnresolvedAddressException();

  connected = channel.connect(connectAddress, timeout);
  connectionPending = !connected;
  return connected;
}
项目:neoscada    文件:AutoConnectClient.java   
protected void lookup ()
{
    fireState ( State.LOOKUP );

    // performing lookup
    final InetSocketAddress address = new InetSocketAddress ( this.address.getHostString (), this.address.getPort () );
    if ( address.isUnresolved () )
    {
        final UnresolvedAddressException e = new UnresolvedAddressException ();
        handleDisconnected ( e );
    }

    synchronized ( this )
    {
        if ( this.executor == null )
        {
            // we got disposed, do nothing
            return;
        }
        this.executor.execute ( new Runnable () {

            @Override
            public void run ()
            {
                createClient ( address );
            }
        } );
    }
}
项目:defense-solutions-proofs-of-concept    文件:UnresolvedHostnameErrorEventImpl.java   
public UnresolvedHostnameErrorEventImpl
(
    Session session, 
    String rawEventData, 
    String hostName, 
    UnresolvedAddressException exception
)
{
    this.session = session;
    this.rawEventData = rawEventData;
    this.hostName = hostName;
    this.exception = exception;
}
项目:rb-bi    文件:KafkaUtils.java   
public static ByteBufferMessageSet fetchMessages(KafkaConfig config, SimpleConsumer consumer, Partition partition, long offset) throws TopicOffsetOutOfRangeException, RuntimeException {
    ByteBufferMessageSet msgs = null;
    String topic = config.topic;
    int partitionId = partition.partition;
    FetchRequestBuilder builder = new FetchRequestBuilder();
    FetchRequest fetchRequest = builder.addFetch(topic, partitionId, offset, config.fetchSizeBytes).
            clientId(config.clientId).maxWait(config.fetchMaxWait).build();
    FetchResponse fetchResponse;
    try {
        fetchResponse = consumer.fetch(fetchRequest);
    } catch (Exception e) {
        if (e instanceof ConnectException ||
                e instanceof SocketTimeoutException ||
                e instanceof IOException ||
                e instanceof UnresolvedAddressException
                ) {
            LOG.warn("Network error when fetching messages:", e);
            throw new FailedFetchException(e);
        } else {
            throw new RuntimeException(e);
        }
    }
    if (fetchResponse.hasError()) {
        KafkaError error = KafkaError.getError(fetchResponse.errorCode(topic, partitionId));
        if (error.equals(KafkaError.OFFSET_OUT_OF_RANGE) && config.useStartOffsetTimeIfOffsetOutOfRange) {
            String msg = "Got fetch request with offset out of range: [" + offset + "]";
            LOG.warn(msg);
            throw new TopicOffsetOutOfRangeException(msg);
        } else {
            String message = "Error fetching data from [" + partition + "] for topic [" + topic + "]: [" + error + "]";
            LOG.error(message);
            throw new FailedFetchException(message);
        }
    } else {
        msgs = fetchResponse.messageSet(topic, partitionId);
    }
    return msgs;
}
项目:DarwinSPL    文件:DwAnalysesClient.java   
/**
 * 
 * @param uriString
 * @param contextModel
 * @param contextValidityModel
 * @param featureModel
 * @param constraintModel
 * @param oldConfiguration
 * @param preferenceModel
 * @param contextValues
 * @param date
 * @return A List of Constraints leading to an invalidity. Null if model is valid.
 */
public List<String> explainAnomaly(String uriString, HyContextModel contextModel, HyValidityModel contextValidityModel,
        HyFeatureModel featureModel, HyConstraintModel constraintModel, HyConfiguration oldConfiguration,
        DwProfile preferenceModel, HyContextValueModel contextValues, Date date, Date evolutionContextValueDate) throws TimeoutException, InterruptedException, ExecutionException, UnresolvedAddressException {

    String messageForHyVarRec = createHyVarRecMessage(contextModel, contextValidityModel, featureModel, constraintModel, oldConfiguration, preferenceModel, contextValues, date, evolutionContextValueDate);
    URI uri = createUriWithPath(uriString, VALIDATE_FM_URI);

    String hyvarrecAnswerString = sendMessageToHyVarRec(messageForHyVarRec, uri);

    HyVarRecExplainAnswer hyVarRecAnswer = gson.fromJson(hyvarrecAnswerString, HyVarRecExplainAnswer.class);
    // TODO do something with the answer

    if(hyVarRecAnswer.getResult().equals("sat")) {
        return null;
    }else if(hyVarRecAnswer.getResult().equals("unsat")) {
        List<String> parsedConstraints = translateIdsBackToNames(hyVarRecAnswer.getConstraints(), date, exporter);

        if(parsedConstraints == null) {
            parsedConstraints = hyVarRecAnswer.getConstraints();
        }

        return parsedConstraints;
    }

    return null;
}
项目:client-legacy    文件:SocketUploader.java   
private SocketChannel createChannel(String ip, int port) {
    try {
        SocketChannel sc = SocketChannel.open();
        SocketAddress socketAddress = new InetSocketAddress(ip, port);
        sc.connect(socketAddress);
        Main.myLog("[SocketUploader] Reloaded socket");
        return sc;
    } catch (IOException | UnresolvedAddressException e) {
        e.printStackTrace();
        Main.dialog.connectionError();
        Main.myErr(Arrays.toString(e.getStackTrace()).replace(",", "\n"));
        return null;
    }
}
项目:j2objc    文件:SocketChannelImpl.java   
static InetSocketAddress validateAddress(SocketAddress socketAddress) {
    if (socketAddress == null) {
        throw new IllegalArgumentException("socketAddress == null");
    }
    if (!(socketAddress instanceof InetSocketAddress)) {
        throw new UnsupportedAddressTypeException();
    }
    InetSocketAddress inetSocketAddress = (InetSocketAddress) socketAddress;
    if (inetSocketAddress.isUnresolved()) {
        throw new UnresolvedAddressException();
    }
    return inetSocketAddress;
}
项目:PhantomBot    文件:UnresolvedHostnameErrorEvent.java   
public UnresolvedHostnameErrorEvent(
        Session session,
        String rawEventData,
        String hostName,
        UnresolvedAddressException exception)
{
    super(rawEventData, session, ErrorType.UNRESOLVED_HOSTNAME);
    this.hostName = hostName;
    this.exception = exception;
}
项目:datacollector    文件:OAuth2ConfigBean.java   
private Response sendRequest(Invocation.Builder builder) throws IOException, StageException {
  Response response;
  try {
    response =
        builder.property(ClientProperties.REQUEST_ENTITY_PROCESSING, transferEncoding)
            .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED + "; charset=utf-8")
            .post(generateRequestEntity());
  } catch (ProcessingException ex) {
    if (ex.getCause() instanceof UnresolvedAddressException || ex.getCause() instanceof UnknownHostException) {
      throw new NotFoundException(ex.getCause());
    }
    throw ex;
  }
  return response;
}
项目:xenqtt    文件:AbstractMqttChannelTest.java   
@Test
public void testCtorInvalidHost() throws Exception {

    try {
        new TestChannel("foo", 123, clientHandler, selector, 10000);
        fail("Expected exception");
    } catch (UnresolvedAddressException e) {
        clientHandler.assertChannelOpenedCount(0);
        clientHandler.assertChannelClosedCount(1);
        clientHandler.assertLastChannelClosedCause(e);
    }
}
项目:In-the-Box-Fork    文件:SocketChannelImpl.java   
static InetSocketAddress validateAddress(SocketAddress socketAddress) {
    if (null == socketAddress) {
        throw new IllegalArgumentException();
    }
    if (!(socketAddress instanceof InetSocketAddress)) {
        throw new UnsupportedAddressTypeException();
    }
    InetSocketAddress inetSocketAddress = (InetSocketAddress) socketAddress;
    if (inetSocketAddress.isUnresolved()) {
        throw new UnresolvedAddressException();
    }
    return inetSocketAddress;
}
项目:In-the-Box-Fork    文件:UnresolvedAddressExceptionTest.java   
/**
 * @tests {@link java.nio.channels.UnresolvedAddressException#UnresolvedAddressException()}
 */
public void test_Constructor() {
    UnresolvedAddressException e = new UnresolvedAddressException();
    assertNull(e.getMessage());
    assertNull(e.getLocalizedMessage());
    assertNull(e.getCause());
}
项目:tajo    文件:NettyClientBase.java   
private ConnectException makeConnectException(InetSocketAddress address, ChannelFuture future) {
  if (future.cause() instanceof UnresolvedAddressException) {
    return new ConnectException("Can't resolve host name: " + address.toString());
  } else {
    return new ConnectTimeoutException(future.cause().getMessage());
  }
}
项目:questdb    文件:ClientConfig.java   
public SocketChannel openSocketChannel(ServerNode node) throws JournalNetworkException {
    try {
        return openSocketChannel0(node);
    } catch (UnresolvedAddressException | IOException e) {
        throw new JournalNetworkException(e);
    }
}
项目:louie    文件:AsyncIO.java   
private void openConnection(AsyncIOBundle bundle) throws IOException, AsyncIOCreationException {
    SocketChannel channel = SocketChannel.open();
    channel.configureBlocking(false);
    SelectionKey registered = channel.register(selector, SelectionKey.OP_CONNECT);
    try {
        channel.connect(new InetSocketAddress(bundle.getAddress(), bundle.getPort()));   
    } catch (UnresolvedAddressException ex) {
        bundle.setErrorMessage("Could not resolve host address.");
        channel.close();
        throw new AsyncIOCreationException();
    }
    registered.attach(bundle);
}
项目:cn1    文件:SocketChannelImpl.java   
static InetSocketAddress validateAddress(SocketAddress socketAddress) {
    if (null == socketAddress) {
        throw new IllegalArgumentException();
    }
    if (!(socketAddress instanceof InetSocketAddress)) {
        throw new UnsupportedAddressTypeException();
    }
    InetSocketAddress inetSocketAddress = (InetSocketAddress) socketAddress;
    if (inetSocketAddress.isUnresolved()) {
        throw new UnresolvedAddressException();
    }
    return inetSocketAddress;
}
项目:cn1    文件:DatagramChannelTest.java   
/**
 * Test method for 'DatagramChannelImpl.connect(SocketAddress)'
 * 
 * @throws IOException
 */
public void testConnect_Unresolved() throws IOException {
    assertFalse(this.channel1.isConnected());
    InetSocketAddress unresolved = new InetSocketAddress(
            "unresolved address", 1080);
    try {
        this.channel1.connect(unresolved);
        fail("Should throw an UnresolvedAddressException here."); //$NON-NLS-1$
    } catch (UnresolvedAddressException e) {
        // OK.
    }
}
项目:cn1    文件:SocketChannelTest.java   
public void testCFII_Unresolved() throws IOException {
    statusNotConnected_NotPending();
    InetSocketAddress unresolved = new InetSocketAddress(
            "unresolved address", 1080);
    try {
        this.channel1.connect(unresolved);
        fail("Should throw an UnresolvedAddressException here.");
    } catch (UnresolvedAddressException e) {
        // OK.
    }
}
项目:cn1    文件:UnresolvedAddressExceptionTest.java   
/**
 * @tests {@link java.nio.channels.UnresolvedAddressException#UnresolvedAddressException()}
 */
public void test_Constructor() {
    UnresolvedAddressException e = new UnresolvedAddressException();
    assertNull(e.getMessage());
    assertNull(e.getLocalizedMessage());
    assertNull(e.getCause());
}
项目:andes    文件:AMQConnection.java   
protected boolean checkException(Throwable thrown)
{
    Throwable cause = thrown.getCause();

    if (cause == null)
    {
        cause = thrown;
    }

    return ((cause instanceof ConnectException) || (cause instanceof UnresolvedAddressException));
}
项目:andes    文件:AMQConnectionDelegate_8_0.java   
protected boolean checkException(Throwable thrown)
{
    Throwable cause = thrown.getCause();

    if (cause == null)
    {
        cause = thrown;
    }

    return ((cause instanceof ConnectException) || (cause instanceof UnresolvedAddressException));
}
项目:freeVM    文件:SocketChannelImpl.java   
static InetSocketAddress validateAddress(SocketAddress socketAddress) {
    if (null == socketAddress) {
        throw new IllegalArgumentException();
    }
    if (!(socketAddress instanceof InetSocketAddress)) {
        throw new UnsupportedAddressTypeException();
    }
    InetSocketAddress inetSocketAddress = (InetSocketAddress) socketAddress;
    if (inetSocketAddress.isUnresolved()) {
        throw new UnresolvedAddressException();
    }
    return inetSocketAddress;
}