Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AspOpenList: use recordLength to avoid offset issues from the new fields in v75 #145

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions src/main/java/com/ibm/as400/access/list/AspOpenList.java
Original file line number Diff line number Diff line change
Expand Up @@ -425,9 +425,10 @@ protected Object[] formatOutputData(byte[] data, int recordsReturned, int record
CharConverter conv = new CharConverter(system_.getCcsid(), system_);

AspListItem[] aspList = new AspListItem[recordsReturned];
int offset = 0;
int recordOffset = 0;
for (int i = 0; i < recordsReturned; ++i)
{
int offset = recordOffset;
int aspNumber = BinaryConverter.byteArrayToInt(data, offset);
offset += 4;
if (format_ == 1) {
Expand Down Expand Up @@ -622,6 +623,7 @@ protected Object[] formatOutputData(byte[] data, int recordsReturned, int record

aspList[i] = new AspListItem( aspNumber, useIdentification, jobName, jobUserName, jobNumber, threadIdentifier, threadStatus);
}
recordOffset += recordLength;
}

return aspList;
Expand All @@ -632,11 +634,18 @@ protected Object[] formatOutputData(byte[] data, int recordsReturned, int record
**/
protected int getBestGuessReceiverSize(int number)
{
int vrm = 0;
try {
vrm = system_.getVRM();
} catch (AS400SecurityException | IOException e) {
// assume older version
}

switch (format_)
{
case 1: return 64 * number;
case 2: return 148 * number;
case 3: return 94 * number;
case 2: return (vrm >= 0x00070400 ? 154 : 148) * number;
case 3: return (vrm >= 0x00070500 ? 124 : 94) * number;
case 4: return 13 * number;
case 5: return 46 * number;
case 6: return 52 * number;
Expand Down