I have the following method:
public foo bar(String id) {
Lock localLock = lockUtil.lock(id);
try {
do something;
return foo;
} finally {
lock.unlock();
}
}
I need to override this method to take in another parameter.
public foo bar(String id, Integer index) {
Lock localLock = lockUtil.lock(id);
try {
do something with index;
} finally {
lock.unlock();
}
return bar(id);
}
My question is, how can do achieve this without obtaining the locks twice (in case the second method is called)? I don't want to change the signature of the original method, since that would mean making changes at 10 different places in the system. I'd appreciate any ideas. I can give more clarification regarding the question, if required. Thanks.