Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0052415Openbravo ERPA. Platformpublic2023-05-10 23:202023-05-29 10:13
0052415: Error importing text files: Input length = 1
It has been detected that when importing text files, depending on the operating system with which the file was generated, it can generate the following exception:

java.nio.charset.MalformedInputException: Input length = 1

Specifically, for now the error has been located when importing text files that are then processed reading line by line, since depending on the operating system that generated the file, it could use a different line break character than the default for UNIX systems (LF).

Creating BufferedReader from Files.newBufferedReader, when running the application it may throw the exception mentioned above. Example:

Files.newBufferedReader(Paths.get("a.txt"), StandardCharsets.UTF_8);

But if we replace the above with this, it works well:

new BufferedReader(new InputStreamReader(new FileInputStream("a.txt"),"utf-8"));

The different is that, the former uses CharsetDecoder default action (The default action for malformed-input and unmappable-character errors is to report them), while the latter uses the REPLACE action:


Tests have been done in this regard and it has been verified that using the replacement avoids the error and imports the file correctly (at least for the specific case of line breaks).

The use of the same case has been detected in the following files:
- src/org/openbravo/retail/discounts/bytotal/actionhandler/
- src/org/openbravo/retail/discounts/actionhandler/
- src/org/openbravo/pos2/process/
- src/org/openbravo/pos2/process/
- src/org/openbravo/reporting/tools/task/
- src/org/openbravo/reporting/tools/task/

So perhaps it would be necessary to check if it is necessary to apply any correction.
Replace this:


For this:

new BufferedReader(new InputStreamReader(new FileInputStream(file.getAbsolutePath())))
No tags attached.
related to defect 0052368 closed jlopez Modules [OPECOM] Cannot import prices : error Input lenght = 1 
Issue History
2023-05-10 23:20jlopezNew Issue
2023-05-10 23:20jlopezAssigned To => Triage Platform Base
2023-05-10 23:20jlopezModules => Core
2023-05-10 23:20jlopezTriggers an Emergency Pack => No
2023-05-10 23:21jlopezRelationship addedrelated to 0052368
2023-05-11 09:40aferrazAssigned ToTriage Platform Base => Triage Omni OMS
2023-05-25 10:54frank_gonzalezAssigned ToTriage Omni OMS => frank_gonzalez
2023-05-25 10:55frank_gonzalezStatusnew => acknowledged
2023-05-29 10:12hgbotNote Added: 0150367
2023-05-29 10:13hgbotNote Added: 0150368
2023-05-29 10:13hgbotNote Added: 0150369

2023-05-29 10:12   
Merge Request created: [^]
2023-05-29 10:13   
Merge Request created: [^]
2023-05-29 10:13   
Merge Request created: [^]