You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ofbiz.apache.org by "BJ Freeman (JIRA)" <ji...@apache.org> on 2009/10/20 20:51:59 UTC

[jira] Commented: (OFBIZ-3026) Datafile does not catch lack of delimiter if at end of line.

    [ https://issues.apache.org/jira/browse/OFBIZ-3026?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12767907#action_12767907 ] 

BJ Freeman commented on OFBIZ-3026:
-----------------------------------

I have run into problems with the supplier of files, I need
to bullet proof the datafile code to cover these problems.

The problem is the file I have has no data or delimiter to the last column.
nexttolastcolmn (delimiter) lastcolumn (eol)  = expected
data            no delimiter nodata (eol)= real data
If I add the delimiter then it works.
however this files are like  24 megs and up and not able to be edited
easily.


it seems the Record.createRecord is more for fixed files than for delimited.
this causes a an error in
            try {
                strVal = line.substring(modelField.position,
modelField.position + modelField.length);
            } catch (IndexOutOfBoundsException ioobe) {
                throw new DataFileException("Field " + modelField.name +
" from " + modelField.position +
                        " for " + modelField.length + " chars could not
be read from a line (" + lineNum + ") with only " +
                        line.length() + " chars.", ioobe);
            }
This is around line 515.

1) would this be the place to add code for the delimited
2) or would Record.createDelimitedRecord be a better place.
        if (line.endsWith(String.valueOf(delimiter))) {
            st = new StringTokenizer(line + " ", "" + delimiter, true);
            Debug.logInfo(" does end with a delimiter", module);
        }
        else {
            st = new StringTokenizer(line, "" + delimiter, true);
            Debug.logInfo(" does not end with a delimiter", module);
                  }
 about line 551

any thoughts.


> Datafile does not catch lack of delimiter if at end of line.
> ------------------------------------------------------------
>
>                 Key: OFBIZ-3026
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-3026
>             Project: OFBiz
>          Issue Type: Bug
>          Components: framework
>    Affects Versions: Release Branch 9.04, SVN trunk
>         Environment: 9.04 revision 823664
>            Reporter: BJ Freeman
>             Fix For: Release Branch 9.04
>
>
> datafile that does not have the last delimiter before the CRLF.
> 2009-10-10 20:33:19,265 (http-0.0.0.0-8443-2) [ModelDataFileReader.java:135:INFO ] -- getModelDataFile: #1 Loaded dataFile: Product
> 2009-10-10 20:33:19,265 (http-0.0.0.0-8443-2) [ModelDataFileReader.java:74 :INFO ] [ModelDataFileReader.getModelDataFileReader] : returning reader.
> 2009-10-10 20:33:19,265 (http-0.0.0.0-8443-2) [ModelDataFileReader.java:74 :INFO ] [ModelDataFileReader.getModelDataFileReader] : returning reader.
> 2009-10-10 20:33:19,265 (http-0.0.0.0-8443-2) [                       ?:?  :INFO ] 
> ---- exception report ----------------------------------------------------------
> Exception: org.ofbiz.datafile.DataFileException
> Message: Field map could not be read from a line (1) with only 234 chars. (null)
> ---- cause ---------------------------------------------------------------------
> Exception: java.util.NoSuchElementException
> Message: null
> ---- stack trace ---------------------------------------------------------------
> java.util.NoSuchElementException
> java.util.StringTokenizer.nextToken(Unknown Source)
> org.ofbiz.datafile.Record.createDelimitedRecord(Record.java:555)
> org.ofbiz.datafile.RecordIterator.getNextLine(RecordIterator.java:123)
> org.ofbiz.datafile.RecordIterator.setupStream(RecordIterator.java:79)
> org.ofbiz.datafile.RecordIterator.<init>(RecordIterator.java:61)
> org.ofbiz.datafile.DataFile.makeRecordIterator(DataFile.java:165)
> org.ofbiz.datafile.DataFile.readDataFile(DataFile.java:124)
> org.ofbiz.datafile.DataFile.readFile(DataFile.java:63)

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