Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The code may throw an exception before the tc is closed,you should use try-catch-finally or try-with-resource to close resource #4594

QiAnXinCodeSafe opened this issue Dec 29, 2020 · 0 comments


Copy link

@QiAnXinCodeSafe QiAnXinCodeSafe commented Dec 29, 2020

try {
tc = new FileOutputStream(tf).getChannel();
sc = new FileInputStream(sf).getChannel();
sc.transferTo(0, sc.size(), tc);
} finally {
if (null != sc) {
if (null != tc) {

sc.close() may be throw an exception

conn.getOutputStream().write(b, 0, b.length);

InputStream in = getResourceAsStream(loader, resource);

@Maijh97 Maijh97 self-assigned this Dec 30, 2020
Maijh97 added a commit to Maijh97/nacos that referenced this issue Dec 30, 2020
wjm0729 added a commit to wjm0729/nacos that referenced this issue Dec 31, 2020

* 'develop' of
  优化 FileTypeEnum 取值逻辑, 避免使用异常当作逻辑分支 (alibaba#4607)
  for alibaba#4594,alibaba#4594 Fix IO close problem. (alibaba#4606)
  console-ui config排序优化 (alibaba#4599)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

2 participants