[
https://issues.apache.org/jira/browse/FLINK-2827?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14965432#comment-14965432
]
ASF GitHub Bot commented on FLINK-2827:
---------------------------------------
Github user ssaumitra commented on a diff in the pull request:
https://github.com/apache/flink/pull/1276#discussion_r42527314
--- Diff:
flink-staging/flink-streaming/flink-streaming-connectors/flink-connector-twitter/src/main/java/org/apache/flink/streaming/connectors/twitter/TwitterSource.java
---
@@ -133,13 +134,21 @@ protected OAuth1 authenticate() {
private Properties loadAuthenticationProperties() {
Properties properties = new Properties();
+ InputStream input = null;
try {
- InputStream input = new FileInputStream(authPath);
+ input = new FileInputStream(authPath);
properties.load(input);
- input.close();
} catch (Exception e) {
throw new RuntimeException("Cannot open .properties
file: " + authPath, e);
}
+ finally {
+ try {
--- End diff --
This try..catch does not look beautiful. But `input.close()` mandates it.
Also `close()` will not be called if `FileInputStream` is not open.
> Potential resource leak in TwitterSource#loadAuthenticationProperties()
> -----------------------------------------------------------------------
>
> Key: FLINK-2827
> URL: https://issues.apache.org/jira/browse/FLINK-2827
> Project: Flink
> Issue Type: Bug
> Affects Versions: 0.10
> Reporter: Ted Yu
> Assignee: Saumitra Shahapure
> Priority: Minor
> Labels: starter
>
> Here is related code:
> {code}
> Properties properties = new Properties();
> try {
> InputStream input = new FileInputStream(authPath);
> properties.load(input);
> input.close();
> } catch (Exception e) {
> throw new RuntimeException("Cannot open .properties
> file: " + authPath, e);
> }
> {code}
> If there is exception coming out of properties.load() call, input would be
> left open.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)