Description
Any method which overrides a synchronized method should itself be synchronized. Else, relying on thread-safety through the base class most likely leads to concurrency problems.
Type
Bug
Snippet
public class MissingSynchronizedModifierOnInheritedMethod {
public static class Base {
public synchronized void method() {
// impl
}
}
public static class DerivedNoncompliant extends Base {
@Override
public void method() { // Noncompliant
// impl
}
}
public static class DerivedCompliant extends Base {
@Override
public synchronized void method() { // Compliant
// impl
}
}
}
Note
Also covered by Eclipse JDT.