feign.Util.ensureClosed()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(1.7k)|赞(0)|评价(0)|浏览(117)

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

Util.ensureClosed介绍

暂无

代码示例

代码示例来源:origin: com.netflix.feign/feign-core

  1. @Override
  2. public void close() {
  3. Util.ensureClosed(body);
  4. }

代码示例来源:origin: com.netflix.feign/feign-core

  1. /**
  2. * Adapted from {@code com.google.common.io.CharStreams.toString()}.
  3. */
  4. public static String toString(Reader reader) throws IOException {
  5. if (reader == null) {
  6. return null;
  7. }
  8. try {
  9. StringBuilder to = new StringBuilder();
  10. CharBuffer buf = CharBuffer.allocate(BUF_SIZE);
  11. while (reader.read(buf) != -1) {
  12. buf.flip();
  13. to.append(buf);
  14. buf.clear();
  15. }
  16. return to.toString();
  17. } finally {
  18. ensureClosed(reader);
  19. }
  20. }

代码示例来源:origin: com.netflix.feign/feign-core

  1. /**
  2. * Adapted from {@code com.google.common.io.ByteStreams.toByteArray()}.
  3. */
  4. public static byte[] toByteArray(InputStream in) throws IOException {
  5. checkNotNull(in, "in");
  6. try {
  7. ByteArrayOutputStream out = new ByteArrayOutputStream();
  8. copy(in, out);
  9. return out.toByteArray();
  10. } finally {
  11. ensureClosed(in);
  12. }
  13. }

代码示例来源:origin: io.github.openfeign/feign-gson

  1. @Override
  2. public Object decode(Response response, Type type) throws IOException {
  3. if (response.status() == 404)
  4. return Util.emptyValueOf(type);
  5. if (response.body() == null)
  6. return null;
  7. Reader reader = response.body().asReader();
  8. try {
  9. return gson.fromJson(reader, type);
  10. } catch (JsonIOException e) {
  11. if (e.getCause() != null && e.getCause() instanceof IOException) {
  12. throw IOException.class.cast(e.getCause());
  13. }
  14. throw e;
  15. } finally {
  16. ensureClosed(reader);
  17. }
  18. }
  19. }

代码示例来源:origin: OpenFeign/feign-vertx

  1. } finally {
  2. if (shouldClose) {
  3. ensureClosed(response.body());

代码示例来源:origin: com.netflix.feign/feign-core

  1. } finally {
  2. if (shouldClose) {
  3. ensureClosed(response.body());

相关文章