jPOS
jPOS copied to clipboard
ISOStringFieldPackager throws an IndexOutOfBoundsException
Hello,
While Unpacking a DE with IFE_LLLCHAR today this exception was thrown
Exception in thread "main" org.jpos.iso.ISOException: org.jpos.iso.IFE_LLLCHAR: Problem unpacking field 61 (java.lang.IndexOutOfBoundsException) unpacking field=61, consumed=241
After some investigating, it turned out that the DE value was signaling that it has a length of a 100 but in reality it was only 26 bytes in length.
Since java.lang.IndexOutOfBoundsException does not tell us much, i think that it would be useful if ISOStringFieldPackager compared how many bytes are still array to how much it is expecting to extract and threw a more comprehensive error message like :
Trying to extract X bytes but the message contains only Y bytes
I will gladly work on this issue if the JPos project accepts PRs.
kind regards.
Anything that saves us debugging time with this kind of very common issues while configuring new endpoints is welcome, so please go ahead with the PR at your convenience.