[
https://issues.apache.org/jira/browse/OPENNLP-1149?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16216500#comment-16216500
]
ASF GitHub Bot commented on OPENNLP-1149:
-----------------------------------------
kojisekig closed pull request #280: OPENNLP-1149: remove unused member in
PlainTextByLineStream and chang…
URL: https://github.com/apache/opennlp/pull/280
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git
a/opennlp-tools/src/main/java/opennlp/tools/util/PlainTextByLineStream.java
b/opennlp-tools/src/main/java/opennlp/tools/util/PlainTextByLineStream.java
index 894243722..3ac4fbc1a 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/util/PlainTextByLineStream.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/util/PlainTextByLineStream.java
@@ -20,17 +20,15 @@
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
-import java.nio.channels.Channels;
-import java.nio.channels.FileChannel;
import java.nio.charset.Charset;
+import java.util.Objects;
/**
* Reads a plain text file and return each line as a <code>String</code>
object.
*/
public class PlainTextByLineStream implements ObjectStream<String> {
- private final FileChannel channel;
- private final String encoding;
+ private final Charset encoding;
private InputStreamFactory inputStreamFactory;
@@ -43,9 +41,9 @@ public PlainTextByLineStream(InputStreamFactory
inputStreamFactory,
public PlainTextByLineStream(InputStreamFactory inputStreamFactory,
Charset charset) throws IOException {
- this.inputStreamFactory = inputStreamFactory;
- this.channel = null;
- this.encoding = charset.name();
+ this.inputStreamFactory =
+ Objects.requireNonNull(inputStreamFactory, "inputStreamFactory must
not be null!");
+ this.encoding = charset;
reset();
}
@@ -56,22 +54,13 @@ public String read() throws IOException {
public void reset() throws IOException {
- if (inputStreamFactory != null) {
- in = new BufferedReader(new
InputStreamReader(inputStreamFactory.createInputStream(),
+ in = new BufferedReader(new
InputStreamReader(inputStreamFactory.createInputStream(),
encoding));
- } else if (channel == null) {
- in.reset();
- } else {
- channel.position(0);
- in = new BufferedReader(Channels.newReader(channel, encoding));
- }
}
public void close() throws IOException {
- if (in != null && channel == null) {
+ if (in != null) {
in.close();
- } else if (channel != null) {
- channel.close();
}
}
}
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> remove unused member in PlainTextByLineStream
> ---------------------------------------------
>
> Key: OPENNLP-1149
> URL: https://issues.apache.org/jira/browse/OPENNLP-1149
> Project: OpenNLP
> Issue Type: Improvement
> Affects Versions: 1.8.2
> Reporter: Koji Sekiguchi
> Priority: Trivial
> Fix For: 1.8.3
>
>
> PlainTextByLineStream has a private member variable "channel" but it is never
> set and hence, it is always null. It can be removed to simplify code.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)