本文整理了Java中feign.Util.ensureClosed()
方法的一些代码示例,展示了Util.ensureClosed()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.ensureClosed()
方法的具体详情如下:
包路径:feign.Util
类名称:Util
方法名:ensureClosed
暂无
代码示例来源:origin: com.netflix.feign/feign-core
@Override
public void close() {
Util.ensureClosed(body);
}
代码示例来源:origin: com.netflix.feign/feign-core
/**
* Adapted from {@code com.google.common.io.CharStreams.toString()}.
*/
public static String toString(Reader reader) throws IOException {
if (reader == null) {
return null;
}
try {
StringBuilder to = new StringBuilder();
CharBuffer buf = CharBuffer.allocate(BUF_SIZE);
while (reader.read(buf) != -1) {
buf.flip();
to.append(buf);
buf.clear();
}
return to.toString();
} finally {
ensureClosed(reader);
}
}
代码示例来源:origin: com.netflix.feign/feign-core
/**
* Adapted from {@code com.google.common.io.ByteStreams.toByteArray()}.
*/
public static byte[] toByteArray(InputStream in) throws IOException {
checkNotNull(in, "in");
try {
ByteArrayOutputStream out = new ByteArrayOutputStream();
copy(in, out);
return out.toByteArray();
} finally {
ensureClosed(in);
}
}
代码示例来源:origin: io.github.openfeign/feign-gson
@Override
public Object decode(Response response, Type type) throws IOException {
if (response.status() == 404)
return Util.emptyValueOf(type);
if (response.body() == null)
return null;
Reader reader = response.body().asReader();
try {
return gson.fromJson(reader, type);
} catch (JsonIOException e) {
if (e.getCause() != null && e.getCause() instanceof IOException) {
throw IOException.class.cast(e.getCause());
}
throw e;
} finally {
ensureClosed(reader);
}
}
}
代码示例来源:origin: OpenFeign/feign-vertx
} finally {
if (shouldClose) {
ensureClosed(response.body());
代码示例来源:origin: com.netflix.feign/feign-core
} finally {
if (shouldClose) {
ensureClosed(response.body());
内容来源于网络,如有侵权,请联系作者删除!