diff --git a/jdk/src/share/classes/sun/security/pkcs11/Session.java b/jdk/src/share/classes/sun/security/pkcs11/Session.java index 308b7542e7d..99d6da78682 100644 --- a/jdk/src/share/classes/sun/security/pkcs11/Session.java +++ b/jdk/src/share/classes/sun/security/pkcs11/Session.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2011, 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 @@ -87,7 +87,7 @@ final class Session implements Comparable { } long id() { - if (token.isPresent(this) == false) { + if (token.isPresent(this.id) == false) { throw new ProviderException("Token has been removed"); } lastAccess = System.currentTimeMillis(); @@ -167,7 +167,9 @@ final class SessionRef extends PhantomReference void dispose() { refList.remove(this); try { - token.p11.C_CloseSession(id); + if (token.isPresent(id)) { + token.p11.C_CloseSession(id); + } } catch (PKCS11Exception e1) { // ignore } catch (ProviderException e2) { diff --git a/jdk/src/share/classes/sun/security/pkcs11/Token.java b/jdk/src/share/classes/sun/security/pkcs11/Token.java index dcb3e61979e..f19f8b7ca20 100644 --- a/jdk/src/share/classes/sun/security/pkcs11/Token.java +++ b/jdk/src/share/classes/sun/security/pkcs11/Token.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2011, 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 @@ -217,7 +217,7 @@ class Token implements Serializable { // return whether a token is present (i.e. token not removed) // returns cached value if current, otherwise performs new check - boolean isPresent(Session session) { + boolean isPresent(long sessionID) { if (removable == false) { return true; } @@ -238,7 +238,7 @@ class Token implements Serializable { // the token should return an error CK_SESSION_INFO sessInfo = provider.p11.C_GetSessionInfo - (session.idInternal()); + (sessionID); ok = true; } } catch (PKCS11Exception e) {