Skip to content

fix 'socket closed' problem #7

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

luoquan
Copy link

@luoquan luoquan commented Nov 1, 2016

response提前关闭了,会导致下载文件时报socket closed异常

Copy link

@xiaoheike xiaoheike left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个代码更改是正确合理的。
不过我觉得 Reader rulesReader 也是不需要手动关闭的。
根据StackOverFlow 上的回答:http://stackoverflow.com/questions/3628899/do-i-need-to-close-inputstream-after-i-close-the-reader
并且parse源代码里边其实已经将流关闭了,所以rulesReader不显式关闭也是可以的。

public class SolrSynonymParser extends Parser {
    // 省略代码
    public void parse(Reader in) throws IOException, ParseException {
        LineNumberReader br = new LineNumberReader(in);
        try {
            this.addInternal(br);
        } catch (IllegalArgumentException var8) {
            ParseException ex = new ParseException("Invalid synonym rule at line " + br.getLineNumber(), 0);
            ex.initCause(var8);
            throw ex;
        } finally {
            // 由于java io 使用装饰模式,所以流会在这里被关闭
            br.close();
        }
    }
	// 省略代码
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants