Trap with System Properties

Recently I had developed a file upload module in a Portlet application. The module was tested and working perfectly in Windows.When the application was delpoyed in an AIX server, this fuctionality stopped working.
The fix was simple , though it took hours to debug.

To get the header of the multipart content I had code like this,
final int headerIndex= requestContent.indexOf(System. getProperty("line.separator") +System.getProperty("line.separator"));

Using this index I was trying to get the conetent and do the manipulation.

The server where the application was deployed "line.separator" was not set and System. getProperty("line.separator") was returning EMPTY STRING !!!.

This caused my logic to break in the server. So finally I had to put a empty string check (IF condition) for for the property ,line.separator and hard code as '\r\n' as i have no cotrol over the server setting.

This article is a good one for such traps while porting from Windows to AIX, http://www.ibm.com/developerworks/aix/library/au-aix-javatraps/index.html

No comments:

Post a Comment