mahout-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hudson (JIRA)" <j...@apache.org>
Subject [jira] Commented: (MAHOUT-582) Add check for empty files passed to FileDataModel constructor in order to generate a better error message.
Date Tue, 11 Jan 2011 22:41:49 GMT

    [ https://issues.apache.org/jira/browse/MAHOUT-582?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12980396#action_12980396
] 

Hudson commented on MAHOUT-582:
-------------------------------

Integrated in Mahout-Quality #551 (See [https://hudson.apache.org/hudson/job/Mahout-Quality/551/])
    

> Add check for empty files passed to FileDataModel constructor in order to generate a
better error message.
> ----------------------------------------------------------------------------------------------------------
>
>                 Key: MAHOUT-582
>                 URL: https://issues.apache.org/jira/browse/MAHOUT-582
>             Project: Mahout
>          Issue Type: Improvement
>    Affects Versions: 0.5
>         Environment: Environment neutral.
>            Reporter: Donald Bleyl
>            Assignee: Sean Owen
>            Priority: Minor
>             Fix For: 0.5
>
>         Attachments: emptyfile.patch
>
>   Original Estimate: 0.08h
>  Remaining Estimate: 0.08h
>
> The FileDataModel constructor checks for a null arg for dataFile, and a few other conditions,
but not for an empty file.  If an empty file is passed in, it triggers a NullPointerException
when the first line is evaluated.
> For an empty file, an NPE is raised when firstLine.length() is called:
>     FileLineIterator iterator = new FileLineIterator(dataFile, false);
>     String firstLine = iterator.peek();
>     while ((firstLine.length() == 0) || (firstLine.charAt(0) == COMMENT_CHAR)) {
> Proposed fix is to add a check for a zero-length file:
>     Preconditions.checkArgument(dataFile != null, "dataFile is null");
>     if (!dataFile.exists() || dataFile.isDirectory()) {
>       throw new FileNotFoundException(dataFile.toString());
>     }
>     Preconditions.checkArgument(dataFile.length() > 0L, "dataFile is empty");
> A unit test has been included in the patch.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message