Uploaded image for project: 'Derby'
  1. Derby
  2. DERBY-4792

Synchronized setter method but non-synchronized similarly-name getter method in ClientBaseDataSource

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 10.5.1.1
    • None
    • JDBC
    • OS: Windows XP
    • Normal

    Description

      I found some synchronized setter methods and unsynchronized similarly-named getter methods in class ClientBaseDataSource as follow:

      public abstract class ClientBaseDataSource implements Serializable, Referenceable {
      ...
      synchronized public void setTraceLevel(int traceLevel)

      { this.traceLevel = traceLevel; }

      public int getTraceLevel()

      { return this.traceLevel; }

      ..
      }

      Consequence:
      traceLevel is not declared volatile, the Java Memory Model doesn't guarantee up-to-date field value visible to threads in the absent of synchronization. So if the getTraceLevel() method is called, it could read stale or inconsistent values, which could cause serious problems.

      Quick-fix solution:
      synchronize getTraceLevel() method

      Attachments

        Activity

          People

            Unassigned Unassigned
            cashcrop Wendy Feng
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:

              Time Tracking

                Estimated:
                Original Estimate - 3h
                3h
                Remaining:
                Remaining Estimate - 3h
                3h
                Logged:
                Time Spent - Not Specified
                Not Specified