From be9eacaeb0e5c1dfb1c68596e836477bff1bdc4b Mon Sep 17 00:00:00 2001 From: Robert Godfrey Date: Wed, 13 Aug 2014 12:49:35 +0000 Subject: QPID-5993 : [Java] Address issues identified by Findbugs git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1617716 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/main/java/org/apache/qpid/example/Hello.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'qpid/java/client/example') diff --git a/qpid/java/client/example/src/main/java/org/apache/qpid/example/Hello.java b/qpid/java/client/example/src/main/java/org/apache/qpid/example/Hello.java index 949ee4dac6..7e956698d1 100644 --- a/qpid/java/client/example/src/main/java/org/apache/qpid/example/Hello.java +++ b/qpid/java/client/example/src/main/java/org/apache/qpid/example/Hello.java @@ -21,10 +21,18 @@ package org.apache.qpid.example; -import javax.jms.*; +import java.io.InputStream; +import java.util.Properties; + +import javax.jms.Connection; +import javax.jms.ConnectionFactory; +import javax.jms.Destination; +import javax.jms.MessageConsumer; +import javax.jms.MessageProducer; +import javax.jms.Session; +import javax.jms.TextMessage; import javax.naming.Context; import javax.naming.InitialContext; -import java.util.Properties; public class Hello @@ -42,9 +50,10 @@ public class Hello private void runTest() { - try { + try (InputStream resourceAsStream = this.getClass().getResourceAsStream("hello.properties")) + { Properties properties = new Properties(); - properties.load(this.getClass().getResourceAsStream("hello.properties")); + properties.load(resourceAsStream); Context context = new InitialContext(properties); ConnectionFactory connectionFactory = (ConnectionFactory) context.lookup("qpidConnectionfactory"); -- cgit v1.2.1