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

                 Key: DERBY-4792
                 URL: https://issues.apache.org/jira/browse/DERBY-4792
             Project: Derby
          Issue Type: Bug
          Components: JDBC
    Affects Versions: 10.5.1.1
         Environment: OS: Windows XP
            Reporter: Wendy Feng


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

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to