Uploaded image for project: 'QuickFIX/J'
  1. QuickFIX/J
  2. QFJ-680

UtcTimestampConverter.convert() threading issue

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Default
    • Resolution: Fixed
    • Affects Version/s: 1.5.2
    • Fix Version/s: 1.5.3
    • Component/s: Engine
    • Labels:
      None
    • Environment:
      n/a

      Description

      The root cause is actually very simple.

      1) Multiple threads call convert(String) for a new day [new = wasn't already in dateCache]
      2) Multiple threads get a handle to the same new GregorianCalendar instance for the new day
      3) Multiple threads concurrently call getTimeInMillis() for the same instance from step #2
      4) ArrayIndexOutOfBoundsException due to concurrent modification of internal GregorianCalendar state

      Example stack trace

      Caused by: java.lang.ArrayIndexOutOfBoundsException: 101
      at sun.util.calendar.BaseCalendar.getCalendarDateFromFixedDate(BaseCalendar.java:454)
      at java.util.GregorianCalendar.computeFields(GregorianCalendar.java:2333)
      at java.util.GregorianCalendar.computeTime(GregorianCalendar.java:2753)
      at java.util.Calendar.updateTime(Calendar.java:2606)
      at java.util.Calendar.getTimeInMillis(Calendar.java:1118)
      at quickfix.field.converter.UtcTimestampConverter.convert(UtcTimestampConverter.java:82)
      at quickfix.FieldMap.getField(FieldMap.java:432)
      at quickfix.fix44.MarketDataIncrementalRefresh$NoMDEntries.getExpireTime(MarketDataIncrementalRefresh.java:2001)

      There are many easy ways to fix this. I would even suggest just storing the millis in the dateCache

        Attachments

          Activity

            People

            • Assignee:
              chrjohn Christoph John
              Reporter:
              nb N Byrne
            • Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: