Return-Path: X-Original-To: apmail-lucene-commits-archive@www.apache.org Delivered-To: apmail-lucene-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C6F0BE6C0 for ; Wed, 16 Jan 2013 08:22:27 +0000 (UTC) Received: (qmail 23645 invoked by uid 500); 16 Jan 2013 08:22:27 -0000 Mailing-List: contact commits-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@lucene.apache.org Delivered-To: mailing list commits@lucene.apache.org Received: (qmail 23584 invoked by uid 99); 16 Jan 2013 08:22:24 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 16 Jan 2013 08:22:24 +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; Wed, 16 Jan 2013 08:22:23 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 8CE3123889E1; Wed, 16 Jan 2013 08:22:03 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1433849 - in /lucene/dev/trunk/solr: CHANGES.txt contrib/dataimporthandler/src/java/org/apache/solr/handler/dataimport/FileDataSource.java Date: Wed, 16 Jan 2013 08:22:03 -0000 To: commits@lucene.apache.org From: dweiss@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130116082203.8CE3123889E1@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: dweiss Date: Wed Jan 16 08:22:03 2013 New Revision: 1433849 URL: http://svn.apache.org/viewvc?rev=1433849&view=rev Log: SOLR-4288: Improve logging for FileDataSource (basePath, relative resources). Modified: lucene/dev/trunk/solr/CHANGES.txt lucene/dev/trunk/solr/contrib/dataimporthandler/src/java/org/apache/solr/handler/dataimport/FileDataSource.java Modified: lucene/dev/trunk/solr/CHANGES.txt URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/CHANGES.txt?rev=1433849&r1=1433848&r2=1433849&view=diff ============================================================================== --- lucene/dev/trunk/solr/CHANGES.txt (original) +++ lucene/dev/trunk/solr/CHANGES.txt Wed Jan 16 08:22:03 2013 @@ -299,6 +299,9 @@ Optimizations Bug Fixes ---------------------- +* SOLR-4288: Improve logging for FileDataSource (basePath, relative + resources). (Dawid Weiss) + * SOLR-4007: Morfologik dictionaries not available in Solr field type due to class loader lookup problems. (Lance Norskog, Dawid Weiss) Modified: lucene/dev/trunk/solr/contrib/dataimporthandler/src/java/org/apache/solr/handler/dataimport/FileDataSource.java URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/contrib/dataimporthandler/src/java/org/apache/solr/handler/dataimport/FileDataSource.java?rev=1433849&r1=1433848&r2=1433849&view=diff ============================================================================== --- lucene/dev/trunk/solr/contrib/dataimporthandler/src/java/org/apache/solr/handler/dataimport/FileDataSource.java (original) +++ lucene/dev/trunk/solr/contrib/dataimporthandler/src/java/org/apache/solr/handler/dataimport/FileDataSource.java Wed Jan 16 08:22:03 2013 @@ -92,22 +92,35 @@ public class FileDataSource extends Data static File getFile(String basePath, String query) { try { - File file0 = new File(query); - File file = file0; + File file = new File(query); - if (!file.isAbsolute()) - file = new File(basePath + query); + // If it's not an absolute path, try relative from basePath. + if (!file.isAbsolute()) { + // Resolve and correct basePath. + File basePathFile; + if (basePath == null) { + basePathFile = new File(".").getAbsoluteFile(); + LOG.warn("FileDataSource.basePath is empty. " + + "Resolving to: " + basePathFile.getAbsolutePath()); + } else { + basePathFile = new File(basePath); + if (!basePathFile.isAbsolute()) { + basePathFile = basePathFile.getAbsoluteFile(); + LOG.warn("FileDataSource.basePath is not absolute. Resolving to: " + + basePathFile.getAbsolutePath()); + } + } + + file = new File(basePathFile, query).getAbsoluteFile(); + } if (file.isFile() && file.canRead()) { - LOG.debug("Accessing File: " + file.toString()); + LOG.debug("Accessing File: " + file.getAbsolutePath()); return file; - } else if (file != file0) - if (file0.isFile() && file0.canRead()) { - LOG.debug("Accessing File0: " + file0.toString()); - return file0; - } - - throw new FileNotFoundException("Could not find file: " + query); + } else { + throw new FileNotFoundException("Could not find file: " + query + + " (resolved to: " + file.getAbsolutePath()); + } } catch (FileNotFoundException e) { throw new RuntimeException(e); }