Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-699

In Avatica, synchronize access to Calendar

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.3.0-incubating
    • Component/s: avatica
    • Labels:
      None

      Description

      The Calendar class is not thread-safe. Some JDBC methods accept Calendar objects from the client. We must synchronize on this Calendar in case the client is using the Calendar elsewhere.

      Avatica also creates Calendar objects internally. Access to those calendars does not need to be synchronized, but they are often passed into methods that accept client Calendars, and will get synchronized anyway.

        Activity

        Hide
        vladimirsitnikov Vladimir Sitnikov added a comment -

        Why do you think it is a good idea to synchronize on the Calendar?

        There is no point in synchronizing over the Calendar if the client does not do the same thing.
        I suppose it makes sense just state that we discourage using calendar concurrently with Calcite.

        Show
        vladimirsitnikov Vladimir Sitnikov added a comment - Why do you think it is a good idea to synchronize on the Calendar? There is no point in synchronizing over the Calendar if the client does not do the same thing. I suppose it makes sense just state that we discourage using calendar concurrently with Calcite.
        Hide
        julianhyde Julian Hyde added a comment -

        Yes, you're right. JDBC behavior is clearly undefined if a client mutates any object while it is being used by a JDBC method. The same would apply to a byte[] object passed to PreparedStatement.setBytes(int, byte[]).

        I'll remove the synchronized blocks. We don't need to explicitly document it, because it is implicit in the JDBC API.

        Show
        julianhyde Julian Hyde added a comment - Yes, you're right. JDBC behavior is clearly undefined if a client mutates any object while it is being used by a JDBC method. The same would apply to a byte[] object passed to PreparedStatement.setBytes(int, byte[]). I'll remove the synchronized blocks. We don't need to explicitly document it, because it is implicit in the JDBC API.
        Show
        julianhyde Julian Hyde added a comment - Fixed in http://git-wip-us.apache.org/repos/asf/incubator-calcite/commit/a357e910 .
        Hide
        julianhyde Julian Hyde added a comment -

        Resolved in release 1.3.0-incubating (2015-05-30).

        Show
        julianhyde Julian Hyde added a comment - Resolved in release 1.3.0-incubating (2015-05-30).

          People

          • Assignee:
            julianhyde Julian Hyde
            Reporter:
            julianhyde Julian Hyde
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development