Ask is moving to Stack Overflow and! Please use the "opendaylight" tag on either of these sites. This site is now in Read-Only mode

Revision history [back]

click to hide/show revision 1
initial version

Please confirm if the fix is fine..

Problem If a lot of REST calls are made asynchronously then some of them fail returing 401 error. For synchronous calls there is no problem.

I found the problem in In this class MessageDigest object is used as a static class variable.
So on in the hash method of when the diget method of MessageDigest object was called it returned different values for different threads( which should have been same for all threads.).
So what is feel is that sometimes the threads are changing the state of MessageDigest obj before the thread has performed its function in hash method, as the object is shared by all the threads.

I made the MessageDigest obj a local variable in hash method of Which resolved the problem and elimanated the 401, for each thread now has its own MessageDigest object.

private static String hash(byte[] salt, String message) {
if (message == null) {
log.warn("Password hash requested but empty or no password provided");
return message;
if (salt == null || salt.length == 0) {
log.warn("Password hash requested but empty or no salt provided");
return message;

MessageDigest messageDigest = null;
try {
messageDigest = MessageDigest.getInstance("SHA-384");
} catch (NoSuchAlgorithmException e) {
log.error("MessageDigest algorithm does not exist");
return null;
HexEncode.bytesToHexString(messageDigest.digest(concatenate(salt, message)));