mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-23 13:26:02 +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"));
|
final BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
|
||||||
String line;
|
String line;
|
||||||
while ((line = reader.readLine()) != null) {
|
while ((line = reader.readLine()) != null) {
|
||||||
|
if (closed) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (line.length() == 0) {
|
if (line.length() == 0) {
|
||||||
logger.trace("[couchdb] heartbeat");
|
logger.trace("[couchdb] heartbeat");
|
||||||
continue;
|
continue;
|
||||||
@ -376,6 +379,8 @@ public class CouchdbRiver extends AbstractRiverComponent implements River {
|
|||||||
is.close();
|
is.close();
|
||||||
} catch (IOException e1) {
|
} catch (IOException e1) {
|
||||||
// ignore
|
// ignore
|
||||||
|
} finally {
|
||||||
|
is = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (connection != null) {
|
if (connection != null) {
|
||||||
@ -383,6 +388,8 @@ public class CouchdbRiver extends AbstractRiverComponent implements River {
|
|||||||
connection.disconnect();
|
connection.disconnect();
|
||||||
} catch (Exception e1) {
|
} catch (Exception e1) {
|
||||||
// ignore
|
// ignore
|
||||||
|
} finally {
|
||||||
|
connection = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (closed) {
|
if (closed) {
|
||||||
@ -396,6 +403,25 @@ public class CouchdbRiver extends AbstractRiverComponent implements River {
|
|||||||
return;
|
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