8293232: Fix race condition in pkcs11 SessionManager

Reviewed-by: valeriep
This commit is contained in:
Zdenek Zambersky 2022-09-07 20:50:41 +00:00 committed by Valerie Peng
parent 1080c4e4ae
commit 1e031e6a58

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -207,7 +207,12 @@ final class SessionManager {
// will be added to correct pool on release, nothing to do now
return;
}
opSessions.release(session);
// Objects could have been added to this session by other thread between
// check in Session.removeObject method and objSessions.remove call
// higher. Therefore releaseSession method, which performs additional
// check for objects, is used here to avoid placing this session
// in wrong pool due to race condition.
releaseSession(session);
}
private Session openSession() throws PKCS11Exception {