From dae2e05f3cfe5826bd44b33883ce2c57098bfb8e Mon Sep 17 00:00:00 2001 From: Daan Hoogland Date: Tue, 7 Jul 2015 12:45:34 +0200 Subject: [PATCH] coverity 1291768: file input stream not severe unless repetitive (property file usually aren't) Signed-off-by: Daan Hoogland --- .../src/org/apache/cloudstack/mom/kafka/KafkaEventBus.java | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/plugins/event-bus/kafka/src/org/apache/cloudstack/mom/kafka/KafkaEventBus.java b/plugins/event-bus/kafka/src/org/apache/cloudstack/mom/kafka/KafkaEventBus.java index 20a0e4c9178..6d943dfaba3 100644 --- a/plugins/event-bus/kafka/src/org/apache/cloudstack/mom/kafka/KafkaEventBus.java +++ b/plugins/event-bus/kafka/src/org/apache/cloudstack/mom/kafka/KafkaEventBus.java @@ -59,9 +59,7 @@ public class KafkaEventBus extends ManagerBase implements EventBus { final Properties props = new Properties(); - try { - final FileInputStream is = new FileInputStream(PropertiesUtil.findConfigFile("kafka.producer.properties")); - + try (final FileInputStream is = new FileInputStream(PropertiesUtil.findConfigFile("kafka.producer.properties"));) { props.load(is); _topic = (String)props.remove("topic"); @@ -76,9 +74,6 @@ public class KafkaEventBus extends ManagerBase implements EventBus { if (!props.containsKey("value.serializer")) { props.put("value.serializer", DEFAULT_SERIALIZER); } - - - is.close(); } catch (Exception e) { throw new ConfigurationException("Could not read kafka properties"); }