mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-14 06:18:12 +00:00
stop SentenceReader when reading from InputStream and EOF is reached
Change-Id: If6ee824ca27df3fb5561c3afa0809bb624e82414
This commit is contained in:
1 parent
083c25aafd
commit
467a7d1cb1
2 files changed
+12
-2
No files matched your search
@@ -62,6 +62,10 @@ abstract class AbstractDataReader implements DataReader {
|
||||
return isRunning;
|
||||
}
|
||||
|
||||
protected void setRunning(boolean running) {
|
||||
isRunning = running;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read one line from the data source.
|
||||
*
|
||||
@@ -83,7 +87,9 @@ abstract class AbstractDataReader implements DataReader {
|
||||
try {
|
||||
String data = read();
|
||||
if (data == null) {
|
||||
Thread.sleep(SLEEP_TIME);
|
||||
if (isRunning()) {
|
||||
Thread.sleep(SLEEP_TIME);
|
||||
}
|
||||
} else if (SentenceValidator.isValid(data)) {
|
||||
monitor.refresh();
|
||||
Sentence s = factory.createParser(data);
|
||||
|
||||
@@ -52,6 +52,10 @@ class DefaultDataReader extends AbstractDataReader {
|
||||
*/
|
||||
@Override
|
||||
public String read() throws Exception {
|
||||
return input.readLine();
|
||||
final String result = input.readLine();
|
||||
if (result == null) {
|
||||
setRunning(false);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user