Return-Path: X-Original-To: apmail-commons-commits-archive@minotaur.apache.org Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3ABC5EE22 for ; Tue, 28 May 2013 15:23:31 +0000 (UTC) Received: (qmail 20157 invoked by uid 500); 28 May 2013 15:23:30 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 20076 invoked by uid 500); 28 May 2013 15:23:29 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 20051 invoked by uid 99); 28 May 2013 15:23:29 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 May 2013 15:23:29 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 May 2013 15:23:26 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 2040723889ED; Tue, 28 May 2013 15:23:06 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1486967 - /commons/proper/math/trunk/src/main/java/org/apache/commons/math3/random/SobolSequenceGenerator.java Date: Tue, 28 May 2013 15:23:06 -0000 To: commits@commons.apache.org From: tn@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130528152306.2040723889ED@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: tn Date: Tue May 28 15:23:05 2013 New Revision: 1486967 URL: http://svn.apache.org/r1486967 Log: Fix some findbugs warnings wrt input streams. Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/random/SobolSequenceGenerator.java Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/random/SobolSequenceGenerator.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/random/SobolSequenceGenerator.java?rev=1486967&r1=1486966&r2=1486967&view=diff ============================================================================== --- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/random/SobolSequenceGenerator.java (original) +++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/random/SobolSequenceGenerator.java Tue May 28 15:23:05 2013 @@ -20,6 +20,7 @@ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; +import java.nio.charset.Charset; import java.util.Arrays; import java.util.NoSuchElementException; import java.util.StringTokenizer; @@ -67,6 +68,9 @@ public class SobolSequenceGenerator impl /** The resource containing the direction numbers. */ private static final String RESOURCE_NAME = "/assets/org/apache/commons/math3/random/new-joe-kuo-6.1000"; + /** Character set for file input. */ + private static final String FILE_CHARSET = "US-ASCII"; + /** Space dimension. */ private final int dimension; @@ -110,6 +114,12 @@ public class SobolSequenceGenerator impl } catch (MathParseException e) { // the internal resource file could not be parsed -> should not happen throw new MathInternalError(); + } finally { + try { + is.close(); + } catch (IOException e) { // NOPMD + // ignore + } } } @@ -133,6 +143,8 @@ public class SobolSequenceGenerator impl * 2 1 0 1 * 3 2 1 1 3 * + *

+ * The input stream must be an ASCII text containing one valid direction vector per line. * * @param dimension the space dimension * @param is the stream to read the direction vectors from @@ -164,6 +176,9 @@ public class SobolSequenceGenerator impl /** * Load the direction vector for each dimension from the given stream. + *

+ * The input stream must be an ASCII text containing one + * valid direction vector per line. * * @param is the input stream to read the direction vector from * @return the last dimension that has been read from the input stream @@ -177,7 +192,8 @@ public class SobolSequenceGenerator impl direction[0][i] = 1l << (BITS - i); } - final BufferedReader reader = new BufferedReader(new InputStreamReader(is)); + final Charset charset = Charset.forName(FILE_CHARSET); + final BufferedReader reader = new BufferedReader(new InputStreamReader(is, charset)); int dim = -1; try {