0

In our application we use Static Resources to store CSV files that contain record definitions. We have a CSV parser in Apex which usually works fine and correctly reads and upserts records when we need it.

Lately, we're having an issue wherein the parser fails to read the CSV. It simply does not read the newline characters, as if they are missing, so that seems that the CSV appears to the parser as a long single text line.

The problem seems to be related to the OS of the machine from which the Static Resources are deployed to server, as it has been observed only from Windows-deployed resources.

As we use a Jenkins CI setup (unfortunately) hosted on a Windows machine to handle our development flow, it would be great if anybody around knows any trick that could avoid us to have to deploy those Static Resources manually every time.

(The issue has been observed with both MavensMate/MetadataAPI and Jenkins/ANT)

Many thanks!

0

The problem was actually in our CSV parser, which is RegEx based.

To split lines we were using a character class RegEx '[\n\r\f]' which, considering the difference between Unix/OSX and Windows handling of newlines, when Static Resources are deployed with Windows OS (and each newline is a '\n\r' [CR-LF] combination) was causing each newline in the CSV to be caught as a double line-break, hence causing the CSV parser failure.

We solved the issue by changing the RegEx to '[\n\r\f]+' and so allowing Windows '\n\r' to be caught as a single "group".

I was obviously wrong in describing the issue above as causing the parser to see the CSV as a single long line, as the opposite was actually happening!

So... problem solved and question closed! It'd be still nice to receive any tip on how to handle this so that we have the same results regardless if deploying from Windows or other OSes - feel free to leave a comment in case you have any advice.

Cheers

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.