org.apache.http.HttpConnection.close()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(10.5k)|赞(0)|评价(0)|浏览(139)

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

HttpConnection.close介绍

[英]Closes this connection gracefully. This method will attempt to flush the transmitter's internal buffer prior to closing the underlying socket. This method MUST NOT be called from a different thread to force shutdown of the connection. Use #shutdown instead.
[中]优雅地关闭此连接。此方法将尝试在关闭基础套接字之前刷新变送器的内部缓冲区。不能从其他线程调用此方法来强制关闭连接。改用#关机。

代码示例

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

public void closeExpiredConnections() {
  long now = System.currentTimeMillis();
  if (log.isDebugEnabled()) {
    log.debug("Checking for expired connections, now: "  + now);
  }
  
  Iterator<HttpConnection> connectionIter =
    connectionToTimes.keySet().iterator();
  
  while (connectionIter.hasNext()) {
    HttpConnection conn = connectionIter.next();
    TimeValues times = connectionToTimes.get(conn);
    if(times.timeExpires <= now) {
      if (log.isDebugEnabled()) {
        log.debug("Closing connection, expired @: "  + times.timeExpires);
      }
      connectionIter.remove();
      try {
        conn.close();
      } catch (IOException ex) {
        log.debug("I/O error closing connection", ex);
      }
    }
  }        
}

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

conn.close();
} catch (IOException ex) {
  log.debug("I/O error closing connection", ex);

代码示例来源:origin: com.hynnet/httpclient

public void closeExpiredConnections() {
  final long now = System.currentTimeMillis();
  if (log.isDebugEnabled()) {
    log.debug("Checking for expired connections, now: "  + now);
  }
  for (final Entry<HttpConnection, TimeValues> entry : connectionToTimes.entrySet()) {
    final HttpConnection conn = entry.getKey();
    final TimeValues times = entry.getValue();
    if(times.timeExpires <= now) {
      if (log.isDebugEnabled()) {
        log.debug("Closing connection, expired @: "  + times.timeExpires);
      }
      try {
        conn.close();
      } catch (final IOException ex) {
        log.debug("I/O error closing connection", ex);
      }
    }
  }
}

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.apache.httpcomponents.httpclient

public void closeExpiredConnections() {
  final long now = System.currentTimeMillis();
  if (log.isDebugEnabled()) {
    log.debug("Checking for expired connections, now: "  + now);
  }
  for (final Entry<HttpConnection, TimeValues> entry : connectionToTimes.entrySet()) {
    final HttpConnection conn = entry.getKey();
    final TimeValues times = entry.getValue();
    if(times.timeExpires <= now) {
      if (log.isDebugEnabled()) {
        log.debug("Closing connection, expired @: "  + times.timeExpires);
      }
      try {
        conn.close();
      } catch (final IOException ex) {
        log.debug("I/O error closing connection", ex);
      }
    }
  }
}

代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded

public void closeExpiredConnections() {
  final long now = System.currentTimeMillis();
  if (log.isDebugEnabled()) {
    log.debug("Checking for expired connections, now: "  + now);
  }
  for (final Entry<HttpConnection, TimeValues> entry : connectionToTimes.entrySet()) {
    final HttpConnection conn = entry.getKey();
    final TimeValues times = entry.getValue();
    if(times.timeExpires <= now) {
      if (log.isDebugEnabled()) {
        log.debug("Closing connection, expired @: "  + times.timeExpires);
      }
      try {
        conn.close();
      } catch (final IOException ex) {
        log.debug("I/O error closing connection", ex);
      }
    }
  }
}

代码示例来源:origin: Nextdoor/bender

public void closeExpiredConnections() {
  final long now = System.currentTimeMillis();
  if (log.isDebugEnabled()) {
    log.debug("Checking for expired connections, now: "  + now);
  }
  for (final Entry<HttpConnection, TimeValues> entry : connectionToTimes.entrySet()) {
    final HttpConnection conn = entry.getKey();
    final TimeValues times = entry.getValue();
    if(times.timeExpires <= now) {
      if (log.isDebugEnabled()) {
        log.debug("Closing connection, expired @: "  + times.timeExpires);
      }
      try {
        conn.close();
      } catch (final IOException ex) {
        log.debug("I/O error closing connection", ex);
      }
    }
  }
}

代码示例来源:origin: MobiVM/robovm

public void closeExpiredConnections() {
  long now = System.currentTimeMillis();
  if (log.isDebugEnabled()) {
    log.debug("Checking for expired connections, now: "  + now);
  }
  
  Iterator<HttpConnection> connectionIter =
    connectionToTimes.keySet().iterator();
  
  while (connectionIter.hasNext()) {
    HttpConnection conn = connectionIter.next();
    TimeValues times = connectionToTimes.get(conn);
    if(times.timeExpires <= now) {
      if (log.isDebugEnabled()) {
        log.debug("Closing connection, expired @: "  + times.timeExpires);
      }
      connectionIter.remove();
      try {
        conn.close();
      } catch (IOException ex) {
        log.debug("I/O error closing connection", ex);
      }
    }
  }        
}

代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded

/**
 * Closes connections that have been idle for at least the given amount of time.
 *
 * @param idleTime the minimum idle time, in milliseconds, for connections to be closed
 */
public void closeIdleConnections(final long idleTime) {
  // the latest time for which connections will be closed
  final long idleTimeout = System.currentTimeMillis() - idleTime;
  if (log.isDebugEnabled()) {
    log.debug("Checking for connections, idle timeout: "  + idleTimeout);
  }
  for (final Entry<HttpConnection, TimeValues> entry : connectionToTimes.entrySet()) {
    final HttpConnection conn = entry.getKey();
    final TimeValues times = entry.getValue();
    final long connectionTime = times.timeAdded;
    if (connectionTime <= idleTimeout) {
      if (log.isDebugEnabled()) {
        log.debug("Closing idle connection, connection time: "  + connectionTime);
      }
      try {
        conn.close();
      } catch (final IOException ex) {
        log.debug("I/O error closing connection", ex);
      }
    }
  }
}

代码示例来源:origin: FlexoVM/flexovm

public void closeExpiredConnections() {
  long now = System.currentTimeMillis();
  if (log.isDebugEnabled()) {
    log.debug("Checking for expired connections, now: "  + now);
  }
  
  Iterator<HttpConnection> connectionIter =
    connectionToTimes.keySet().iterator();
  
  while (connectionIter.hasNext()) {
    HttpConnection conn = connectionIter.next();
    TimeValues times = connectionToTimes.get(conn);
    if(times.timeExpires <= now) {
      if (log.isDebugEnabled()) {
        log.debug("Closing connection, expired @: "  + times.timeExpires);
      }
      connectionIter.remove();
      try {
        conn.close();
      } catch (IOException ex) {
        log.debug("I/O error closing connection", ex);
      }
    }
  }        
}

代码示例来源:origin: com.mobidevelop.robovm/robovm-rt

public void closeExpiredConnections() {
  long now = System.currentTimeMillis();
  if (log.isDebugEnabled()) {
    log.debug("Checking for expired connections, now: "  + now);
  }
  
  Iterator<HttpConnection> connectionIter =
    connectionToTimes.keySet().iterator();
  
  while (connectionIter.hasNext()) {
    HttpConnection conn = connectionIter.next();
    TimeValues times = connectionToTimes.get(conn);
    if(times.timeExpires <= now) {
      if (log.isDebugEnabled()) {
        log.debug("Closing connection, expired @: "  + times.timeExpires);
      }
      connectionIter.remove();
      try {
        conn.close();
      } catch (IOException ex) {
        log.debug("I/O error closing connection", ex);
      }
    }
  }        
}

代码示例来源:origin: com.gluonhq/robovm-rt

public void closeExpiredConnections() {
  long now = System.currentTimeMillis();
  if (log.isDebugEnabled()) {
    log.debug("Checking for expired connections, now: "  + now);
  }
  
  Iterator<HttpConnection> connectionIter =
    connectionToTimes.keySet().iterator();
  
  while (connectionIter.hasNext()) {
    HttpConnection conn = connectionIter.next();
    TimeValues times = connectionToTimes.get(conn);
    if(times.timeExpires <= now) {
      if (log.isDebugEnabled()) {
        log.debug("Closing connection, expired @: "  + times.timeExpires);
      }
      connectionIter.remove();
      try {
        conn.close();
      } catch (IOException ex) {
        log.debug("I/O error closing connection", ex);
      }
    }
  }        
}

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.apache.httpcomponents.httpclient

/**
 * Closes connections that have been idle for at least the given amount of time.
 *
 * @param idleTime the minimum idle time, in milliseconds, for connections to be closed
 */
public void closeIdleConnections(final long idleTime) {
  // the latest time for which connections will be closed
  final long idleTimeout = System.currentTimeMillis() - idleTime;
  if (log.isDebugEnabled()) {
    log.debug("Checking for connections, idle timeout: "  + idleTimeout);
  }
  for (final Entry<HttpConnection, TimeValues> entry : connectionToTimes.entrySet()) {
    final HttpConnection conn = entry.getKey();
    final TimeValues times = entry.getValue();
    final long connectionTime = times.timeAdded;
    if (connectionTime <= idleTimeout) {
      if (log.isDebugEnabled()) {
        log.debug("Closing idle connection, connection time: "  + connectionTime);
      }
      try {
        conn.close();
      } catch (final IOException ex) {
        log.debug("I/O error closing connection", ex);
      }
    }
  }
}

代码示例来源:origin: Nextdoor/bender

/**
 * Closes connections that have been idle for at least the given amount of time.
 *
 * @param idleTime the minimum idle time, in milliseconds, for connections to be closed
 */
public void closeIdleConnections(final long idleTime) {
  // the latest time for which connections will be closed
  final long idleTimeout = System.currentTimeMillis() - idleTime;
  if (log.isDebugEnabled()) {
    log.debug("Checking for connections, idle timeout: "  + idleTimeout);
  }
  for (final Entry<HttpConnection, TimeValues> entry : connectionToTimes.entrySet()) {
    final HttpConnection conn = entry.getKey();
    final TimeValues times = entry.getValue();
    final long connectionTime = times.timeAdded;
    if (connectionTime <= idleTimeout) {
      if (log.isDebugEnabled()) {
        log.debug("Closing idle connection, connection time: "  + connectionTime);
      }
      try {
        conn.close();
      } catch (final IOException ex) {
        log.debug("I/O error closing connection", ex);
      }
    }
  }
}

代码示例来源:origin: com.hynnet/httpclient

/**
 * Closes connections that have been idle for at least the given amount of time.
 *
 * @param idleTime the minimum idle time, in milliseconds, for connections to be closed
 */
public void closeIdleConnections(final long idleTime) {
  // the latest time for which connections will be closed
  final long idleTimeout = System.currentTimeMillis() - idleTime;
  if (log.isDebugEnabled()) {
    log.debug("Checking for connections, idle timeout: "  + idleTimeout);
  }
  for (final Entry<HttpConnection, TimeValues> entry : connectionToTimes.entrySet()) {
    final HttpConnection conn = entry.getKey();
    final TimeValues times = entry.getValue();
    final long connectionTime = times.timeAdded;
    if (connectionTime <= idleTimeout) {
      if (log.isDebugEnabled()) {
        log.debug("Closing idle connection, connection time: "  + connectionTime);
      }
      try {
        conn.close();
      } catch (final IOException ex) {
        log.debug("I/O error closing connection", ex);
      }
    }
  }
}

代码示例来源:origin: com.gluonhq/robovm-rt

conn.close();
} catch (IOException ex) {
  log.debug("I/O error closing connection", ex);

代码示例来源:origin: MobiVM/robovm

conn.close();
} catch (IOException ex) {
  log.debug("I/O error closing connection", ex);

代码示例来源:origin: com.mobidevelop.robovm/robovm-rt

conn.close();
} catch (IOException ex) {
  log.debug("I/O error closing connection", ex);

代码示例来源:origin: FlexoVM/flexovm

conn.close();
} catch (IOException ex) {
  log.debug("I/O error closing connection", ex);

代码示例来源:origin: net.java.dev.jets3t/jets3t

ExecutionContext.HTTP_CONNECTION);
try {
  conn.close();
} catch (Exception e) {

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.jets3t

ExecutionContext.HTTP_CONNECTION);
try {
  conn.close();
} catch (Exception e) {

相关文章

微信公众号

最新文章

更多