Return-Path: X-Original-To: apmail-commons-issues-archive@minotaur.apache.org Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 9E4D611313 for ; Wed, 30 Jul 2014 23:21:44 +0000 (UTC) Received: (qmail 1663 invoked by uid 500); 30 Jul 2014 23:21:44 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 1570 invoked by uid 500); 30 Jul 2014 23:21:44 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 1550 invoked by uid 99); 30 Jul 2014 23:21:44 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 30 Jul 2014 23:21:44 +0000 Date: Wed, 30 Jul 2014 23:21:44 +0000 (UTC) From: "Sebb (JIRA)" To: issues@commons.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Resolved] (IO-453) Regression in FileUtils.readFileToString from 2.0.1 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/IO-453?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Sebb resolved IO-453. --------------------- Resolution: Fixed Fix Version/s: 2.5 URL: http://svn.apache.org/r1614791 Log: NET-453 - Regression in FileUtils.readFileToString from 2.0.1 Modified: commons/proper/io/trunk/src/changes/changes.xml commons/proper/io/trunk/src/main/java/org/apache/commons/io/FileUtils.java > Regression in FileUtils.readFileToString from 2.0.1 > --------------------------------------------------- > > Key: IO-453 > URL: https://issues.apache.org/jira/browse/IO-453 > Project: Commons IO > Issue Type: Bug > Components: Utilities > Affects Versions: 2.1, 2.2, 2.3, 2.4 > Reporter: Steven Christou > Fix For: 2.5 > > Attachments: IO-453.diff > > > FileUtils.readFileToString has changed it's behavior to make a call from {{IOUtils.toByteArray(in)}} to {{IOUtils.toByteArray(in, file.length())}} in {{FileUtils.readFileToString}}. This is a regression because if the file.length = 0, then it will return 0. According to the javadocs for [File#length|http://docs.oracle.com/javase/6/docs/api/java/io/File.html#length()], it is possible to return 0 if it is a System dependent entities, so even though the File.length might return 0, the stream is still open and > Steps to reproduce (Ubuntu): > 1. Execute {{nohup sleep 10000 &}} in a terminal, and get the process id of the sleep command ({{ps -ef | grep sleep}}). > 2. Call {{FileUtils.readFileToString(new File("/proc/$PID/environ"));}} where $PID is the process ID from step 1. > You will notice that in 2.0.1 it returns several elements, however in 2.1 it will return nothing. > See [~ndeloof]'s comment in https://github.com/apache/commons-io/commit/53a40a6d9dcaaa616b404255406edc30fe2d524c. -- This message was sent by Atlassian JIRA (v6.2#6252)