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 183EB74FA for ; Sat, 16 Jul 2011 14:38:25 +0000 (UTC) Received: (qmail 8766 invoked by uid 500); 16 Jul 2011 14:38:24 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 8490 invoked by uid 500); 16 Jul 2011 14:38:23 -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 8482 invoked by uid 99); 16 Jul 2011 14:38:23 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 16 Jul 2011 14:38:23 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 16 Jul 2011 14:38:21 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id DC55482C15 for ; Sat, 16 Jul 2011 14:37:59 +0000 (UTC) Date: Sat, 16 Jul 2011 14:37:59 +0000 (UTC) From: "Sergio Bossa (JIRA)" To: issues@commons.apache.org Message-ID: <904552808.19976.1310827079899.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Created] (IO-279) Tailer erroneously consider file as new MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org Tailer erroneously consider file as new --------------------------------------- Key: IO-279 URL: https://issues.apache.org/jira/browse/IO-279 Project: Commons IO Issue Type: Bug Affects Versions: 2.0.1 Reporter: Sergio Bossa Tailer sometimes erroneously consider the tailed file as new, forcing a repositioning at the start of the file: I'm still unable to reproduce this in a test case, because it only happens to me with huge log files during Apache Tomcat startup. This is the piece of code causing the problem: // See if the file needs to be read again if (length > position) { // The file has more content than it did last time last = System.currentTimeMillis(); position = readLines(reader); } else if (FileUtils.isFileNewer(file, last)) { /* This can happen if the file is truncated or overwritten * with the exact same length of information. In cases like * this, the file position needs to be reset */ position = 0; reader.seek(position); // cannot be null here // Now we can read new lines last = System.currentTimeMillis(); position = readLines(reader); } What probably happens is that the new file content is about to be written on disk, the date is already updated but content is still not flushed, so actual length is untouched and there you go. In other words, I think there should be some better method to verify the condition above, rather than relying only on dates: keeping and comparing the hash code of the latest line may be a solution, but may hurt performances ... other ideas? -- This message is automatically generated by JIRA. For more information on JIRA, see: http://www.atlassian.com/software/jira