Project

General

Profile

Bug #10627

Numeric FILL-IN: Format Index Miscalculation

Added by Vladimir Tsichevski 10 months ago. Updated 10 months ago.

Status:
New
Priority:
Normal
Assignee:
Vladimir Tsichevski
Target version:
-
Start date:
Due date:
% Done:

0%

billable:
No
vendor_id:
GCD
case_num:
version_reported:
16184
version_resolved:
reviewer:
production:
No
env_name:
topics:

History

#1 Updated by Vladimir Tsichevski 10 months ago

Consider the following example as an illustration:

SESSION:NUMERIC-FORMAT = "American".

DEFINE VARIABLE d AS DECIMAL NO-UNDO.
DEFINE FRAME f d WITH SIZE 50 BY 3.
ENABLE ALL WITH FRAME f.
d:SCREEN-VALUE = "123456.58".
APPLY '?' TO d.
WAIT-FOR CLOSE OF CURRENT-WINDOW.

In this example, a numeric FILL-IN is created, and a value is set using the SCREEN-VALUE attribute. The value is then reset to undefined by applying the question mark (?) character.

In OpenEdge (OE), the FILL-IN displays ? after the reset. In FWD, the reset fails, and the displayed value remains 123,456.58.

Root Cause

The issue stems from an incorrect format index calculation in the NumberFormat$NumberBufGui.input(char) method (NumberFormat.java, line 3825):

formatSymbol = digitsLeft.charAt(digitsLeft.length() - 1 - digitPos);

Here, digitPos is the offset in the digitsLeft string. Subtracting 1 causes an off-by-one error. The correct line is:

formatSymbol = digitsLeft.charAt(digitsLeft.length() - digitPos);
This miscalculation leads to:
  • A StringIndexOutOfBoundsException when the caret is at the first digit (resulting in a -1 index), which is silently ignored.
  • Incorrect format characters being used for other digits, affecting subsequent calculations.

This issue was introduced in revision 11288 on October 28, 2018.

Also available in: Atom PDF