Odd length BCD unpack, does not seem to care if it is 0 and F padding

40 views
Skip to first unread message

ruby c

unread,
Jun 29, 2021, 1:12:30 PM6/29/21
to jPOS Users
Hi Team,

I have a field defined in BCD with right F pad using IFB_FLLNUM. Looks like when I pack stuff, it works fine. 

But when I unpack stuff, it doesnt seem to care if the padding character is F or 0.

Here is an example:
@Test
public void testRightFPadWith0Padding() throws Exception {
// 0 padding instead of F pad
byte[] raw = ISOUtil.hex2byte("11000000000030");
// Specify it to be right padded
IFB_FLLNUM packager = new IFB_FLLNUM(11, "Should be 00000000003", false);
ISOField field = new ISOField(1);
packager.unpack(field, raw, 0);
// Doesnt seem to care the padding character
assertEquals("00000000003", (String) field.getValue());
}

The packager doesnt seem to care if the padding character is 0 or f. I tried with the left pad as well and it is the same.

Is this by design? If I need the framework to strictly follow the field definition and fail to unpack on this, is there a way to do it?

Cheers
Eric

murtuza chhil

unread,
Jun 30, 2021, 9:38:50 AM6/30/21
to jPOS Users

Unfortunately there is no validation of the padding character.
If you step through the code you will come to a point where the following is called....

    @Override
    public String uninterpret(byte[] rawData, int offset, int length)
    {
        return ISOUtil.bcd2str (rawData, offset, length, leftPadded);
    }

 ISOUtil.bcd2str does not validate, it justs gets the appropriate part of the rawdata byte array.

If it's any consolation, when you pack the field the F gets written.

-chhil

Alejandro Revilla

unread,
Jun 30, 2021, 9:56:16 PM6/30/21
to jPOS Users
Do you think it's a good idea to raise an exception if padding is not an 'F' ?

I think this could break some code where people pads with a '0'.



--
--
jPOS is licensed under AGPL - free for community usage for your open-source project. Licenses are also available for commercial usage. Please support jPOS, contact: sa...@jpos.org
---
You received this message because you are subscribed to the Google Groups "jPOS Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jpos-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jpos-users/5cc39abd-e1d7-41a8-bccf-7b6c27538616n%40googlegroups.com.

chhil

unread,
Jul 1, 2021, 11:28:39 AM7/1/21
to jpos-...@googlegroups.com
It will create chaos as people generally don't care about the pad character as it's removed. 
If memory serves me right , there were some validating packagers , may be it could be added there, to use and overridden bcd2str. 

-chhil




You received this message because you are subscribed to a topic in the Google Groups "jPOS Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jpos-users/36p8seksH54/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jpos-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jpos-users/CAAgSK%3DnSVOn_gVB2Xse2jhEMA5nZZLJmkumG3FKynSBS7QY4UQ%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages