Hi all,

I worked the last hours on fixing LOGCXX-425 and currently find myself
to be a bit lost.

https://issues.apache.org/jira/browse/LOGCXX-425

The problem is with test17 from cacheddateformattestcase and
CachedDateFormat::findMillisecondStart which only accepts found
milliseconds if they are at the end of the string or if everything
after the milliseconds is equal to some special comparison string.
Some debug output:

     [exec] formatted: 00:00:00,000 00:00:00,000
     [exec] formattedMillis: 000
     [exec] magicString: 654
     [exec] plusMagic: 00:00:00,654 00:00:00,654
     [exec] plusZero: 00:00:00,000 00:00:00,000
     [exec] i: 9
     [exec] formatted.length(): 25
     [exec] overlapping: 0
     [exec] possibleRetVal: 9
     [exec] 1: 1
     [exec] 2: 1
     [exec] 3: 1
     [exec] 4: 0
     [exec] 5: 0

The problem is with the checks 4 and 5, one of both needs to be true
but can't be with the supplied pattern because plusZero is assumed to
have the same content after the millis like plusMagic, which can never
be the case if two SSS are present in a pattern because each SSS is
always zeroed in plusZero.

If I remove this check the test fails because the timestamp gets
formatted properly with only one changed part of milliseconds, but the
former behavior relied on the fact that the removed comparison was
always wrong and expected a timestamp formatted with both SSS to the
same value because findMillisecondStart didn't provide the index of
the first millis to only change those.

If I stay with this check my own added test fails which assumes that
the first millis were successfully found.

To me this breaks down to the question which we want to be the proper
behavior or I simply don't understand the intention behind this test,
because two SSS look wrong to me. I don't understand why findMillisecondStart
should fail if two SSS are present if instead it could return the
index of the first millis, which is documented as such anyways. And if
it should fail we could simply test for the invalid pattern, now it
looks like the test was created to just correspond to the strange
behavior without any clear purpose to me.

I have committed my change with all my debug stuff in there so one of
you could have a second look and give some advice. Thanks!

Mit freundlichen Grüßen,

Thorsten Schöning

-- 
Thorsten Schöning       E-Mail:thorsten.schoen...@am-soft.de
AM-SoFT IT-Systeme      http://www.AM-SoFT.de/

Telefon...........05151-  9468- 55
Fax...............05151-  9468- 88
Mobil..............0178-8 9468- 04

AM-SoFT GmbH IT-Systeme, Brandenburger Str. 7c, 31789 Hameln
AG Hannover HRB 207 694 - Geschäftsführer: Andreas Muchow

Reply via email to