mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-22 21:05:23 +00:00
better stream close handling in couchdb river
This commit is contained in:
parent
ed996c3e85
commit
f4a30fdc84
@ -361,6 +361,9 @@ public class CouchdbRiver extends AbstractRiverComponent implements River {
|
||||
final BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
if (closed) {
|
||||
return;
|
||||
}
|
||||
if (line.length() == 0) {
|
||||
logger.trace("[couchdb] heartbeat");
|
||||
continue;
|
||||
@ -376,6 +379,8 @@ public class CouchdbRiver extends AbstractRiverComponent implements River {
|
||||
is.close();
|
||||
} catch (IOException e1) {
|
||||
// ignore
|
||||
} finally {
|
||||
is = null;
|
||||
}
|
||||
}
|
||||
if (connection != null) {
|
||||
@ -383,6 +388,8 @@ public class CouchdbRiver extends AbstractRiverComponent implements River {
|
||||
connection.disconnect();
|
||||
} catch (Exception e1) {
|
||||
// ignore
|
||||
} finally {
|
||||
connection = null;
|
||||
}
|
||||
}
|
||||
if (closed) {
|
||||
@ -396,6 +403,25 @@ public class CouchdbRiver extends AbstractRiverComponent implements River {
|
||||
return;
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
if (is != null) {
|
||||
try {
|
||||
is.close();
|
||||
} catch (IOException e1) {
|
||||
// ignore
|
||||
} finally {
|
||||
is = null;
|
||||
}
|
||||
}
|
||||
if (connection != null) {
|
||||
try {
|
||||
connection.disconnect();
|
||||
} catch (Exception e1) {
|
||||
// ignore
|
||||
} finally {
|
||||
connection = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user