java.net.SocketException.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(6.7k)|赞(0)|评价(0)|浏览(91)

本文整理了Java中java.net.SocketException.<init>()方法的一些代码示例,展示了SocketException.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。SocketException.<init>()方法的具体详情如下:
包路径:java.net.SocketException
类名称:SocketException
方法名:<init>

SocketException.<init>介绍

[英]Constructs a new instance.
[中]构造一个新实例。

代码示例

代码示例来源:origin: prestodb/presto

@Override
public Socket createSocket(String host, int port, InetAddress localAddress, int localPort)
    throws IOException
{
  throw new SocketException("not supported");
}

代码示例来源:origin: prestodb/presto

@Override
  public Socket createSocket(InetAddress address, int port, InetAddress localAddress, int localPort)
      throws IOException
  {
    throw new SocketException("not supported");
  }
}

代码示例来源:origin: prestodb/presto

@Override
  public Socket createSocket(InetAddress address, int port, InetAddress localAddress, int localPort)
      throws IOException
  {
    throw new SocketException("not supported");
  }
}

代码示例来源:origin: prestodb/presto

@Override
public Socket createSocket(String host, int port, InetAddress localAddress, int localPort)
    throws IOException
{
  throw new SocketException("not supported");
}

代码示例来源:origin: alibaba/canal

public void write(byte[]... buf) throws IOException {
  OutputStream output = this.output;
  if (output != null) {
    for (byte[] bs : buf) {
      output.write(bs);
    }
  } else {
    throw new SocketException("Socket already closed.");
  }
}

代码示例来源:origin: gocd/gocd

public int download(String url, FetchHandler handler) throws IOException {
    timesCalled += 1;
    if (timesCalled <= count) {
      throw new SocketException("Connection Reset");
    } else {
      return SC_OK;
    }
  }
}

代码示例来源:origin: apache/incubator-druid

@Override
 public int read(byte b[], int off, int len) throws IOException
 {
  if (readCount++ % NUM_READ_COUNTS_BEFORE_ERROR == 0) {
   if (numConnectionResets++ < maxConnectionResets) {
    // Simulate connection reset
    throw new SocketException("Test Connection reset");
   }
  }
  return delegate.read(b, off, len);
 }
}

代码示例来源:origin: apache/incubator-druid

@Override
public int read() throws IOException
{
 if (readCount++ % NUM_READ_COUNTS_BEFORE_ERROR == 0) {
  if (numConnectionResets++ < maxConnectionResets) {
   // Simulate connection reset
   throw new SocketException("Test Connection reset");
  }
 }
 return delegate.read();
}

代码示例来源:origin: square/okhttp

/** Returns the next proxy to try. May be PROXY.NO_PROXY but never null. */
private Proxy nextProxy() throws IOException {
 if (!hasNextProxy()) {
  throw new SocketException("No route to " + address.url().host()
    + "; exhausted proxy configurations: " + proxies);
 }
 Proxy result = proxies.get(nextProxyIndex++);
 resetNextInetSocketAddress(result);
 return result;
}

代码示例来源:origin: apache/zookeeper

@Override
public Socket accept() throws IOException {
  if (isClosed()) {
    throw new SocketException("Socket is closed");
  }
  if (!isBound()) {
    throw new SocketException("Socket is not bound yet");
  }
  final PrependableSocket prependableSocket = new PrependableSocket(null);
  implAccept(prependableSocket);
  return new UnifiedSocket(x509Util, allowInsecureConnection, prependableSocket);
}

代码示例来源:origin: apache/incubator-druid

@Override
 public int read(byte b[], int off, int len) throws IOException
 {
  if (throwError) {
   throwError = false;
   errorCount++;
   if (errorCount % 2 == 0) {
    throw new IOException("test retry");
   } else {
    delegate.close();
    throw new SocketException("Test Connection reset");
   }
  } else {
   throwError = errorCount < MAX_ERROR;
   return delegate.read(b, off, len);
  }
 }
}

代码示例来源:origin: prestodb/presto

/** Returns the next proxy to try. May be PROXY.NO_PROXY but never null. */
private Proxy nextProxy() throws IOException {
 if (!hasNextProxy()) {
  throw new SocketException("No route to " + address.url().host()
    + "; exhausted proxy configurations: " + proxies);
 }
 Proxy result = proxies.get(nextProxyIndex++);
 resetNextInetSocketAddress(result);
 return result;
}

代码示例来源:origin: square/okhttp

throw new SocketException("No route to " + socketHost + ":" + socketPort
  + "; port is out of range");

代码示例来源:origin: com.squareup.okhttp3/okhttp

/** Returns the next proxy to try. May be PROXY.NO_PROXY but never null. */
private Proxy nextProxy() throws IOException {
 if (!hasNextProxy()) {
  throw new SocketException("No route to " + address.url().host()
    + "; exhausted proxy configurations: " + proxies);
 }
 Proxy result = proxies.get(nextProxyIndex++);
 resetNextInetSocketAddress(result);
 return result;
}

代码示例来源:origin: apache/ignite

/** {@inheritDoc} */
@Override protected void writeToSocket(Socket sock, OutputStream out, TcpDiscoveryAbstractMessage msg,
  long timeout) throws IOException, IgniteCheckedException {
  if (blockAll || block && sock.getPort() == 47500)
    throw new SocketException("Test discovery exception");
  super.writeToSocket(sock, out, msg, timeout);
}

代码示例来源:origin: spring-projects/spring-framework

@Test
public void resolveMethodBestMatch() {
  SocketException exception = new SocketException();
  assertEquals("handleSocketException", this.resolver.resolveMethod(exception).getName());
}

代码示例来源:origin: apache/zookeeper

@Override
  protected void processPacket(QuorumPacket qp) throws Exception {
    if (stopPing && qp.getType() == Leader.PING) {
      LOG.info("Follower skipped ping");
      throw new SocketException("Socket time out while sending the ping response");
    } else {
      super.processPacket(qp);
    }
  }
};

代码示例来源:origin: spring-projects/spring-framework

@Test
public void resolveMethodBestMatch() {
  ExceptionHandlerMethodResolver resolver = new ExceptionHandlerMethodResolver(ExceptionController.class);
  SocketException exception = new SocketException();
  assertEquals("handleSocketException", resolver.resolveMethod(exception).getName());
}

代码示例来源:origin: spring-projects/spring-framework

@Test  // SPR-16132
public void followUpRequestAfterFailure() {
  MockRestServiceServer server = MockRestServiceServer.bindTo(this.restTemplate).build();
  server.expect(requestTo("/some-service/some-endpoint"))
      .andRespond(request -> { throw new SocketException("pseudo network error"); });
  server.expect(requestTo("/reporting-service/report-error"))
      .andExpect(method(POST)).andRespond(withSuccess());
  try {
    this.restTemplate.getForEntity("/some-service/some-endpoint", String.class);
  }
  catch (Exception ex) {
    this.restTemplate.postForEntity("/reporting-service/report-error", ex.toString(), String.class);
  }
  server.verify();
}

代码示例来源:origin: spring-projects/spring-framework

@Test  // SPR-16132
public void sequentialRequestsWithFirstFailing() throws Exception {
  this.manager.expectRequest(once(), requestTo("/foo")).
      andExpect(method(GET)).andRespond(request -> { throw new SocketException("pseudo network error"); });
  this.manager.expectRequest(once(), requestTo("/handle-error")).
      andExpect(method(POST)).andRespond(withSuccess());
  try {
    this.manager.validateRequest(createRequest(GET, "/foo"));
    fail("Expected SocketException");
  }
  catch (SocketException ex) {
    // expected
  }
  this.manager.validateRequest(createRequest(POST, "/handle-error"));
  this.manager.verify();
}

相关文章