diff --git a/src/share/classes/sun/security/krb5/internal/ktab/KeyTabInputStream.java b/src/share/classes/sun/security/krb5/internal/ktab/KeyTabInputStream.java index 900c3cc52d8539dcdb53c1702c587027d1be2d3c..c347c848f95b6cf211043c23d9ec87e5717bd96e 100644 --- a/src/share/classes/sun/security/krb5/internal/ktab/KeyTabInputStream.java +++ b/src/share/classes/sun/security/krb5/internal/ktab/KeyTabInputStream.java @@ -1,5 +1,5 @@ /* - * Portions Copyright 2000-2005 Sun Microsystems, Inc. All Rights Reserved. + * Portions Copyright 2000-2010 Sun Microsystems, Inc. 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 @@ -49,7 +49,7 @@ import java.io.InputStream; public class KeyTabInputStream extends KrbDataInputStream implements KeyTabConstants { boolean DEBUG = Krb5.DEBUG; - static int index; + int index; public KeyTabInputStream(InputStream is) { super(is); diff --git a/test/sun/security/krb5/ktab/KeyTabIndex.java b/test/sun/security/krb5/ktab/KeyTabIndex.java new file mode 100644 index 0000000000000000000000000000000000000000..b349f7c1334b5e256312a069e2093e12c440ede6 --- /dev/null +++ b/test/sun/security/krb5/ktab/KeyTabIndex.java @@ -0,0 +1,52 @@ +/* + * Copyright 2010 Sun Microsystems, Inc. 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ +/* + * @test + * @bug 6919610 + * @summary KeyTabInputStream uses static field for per-instance value + */ +import sun.security.krb5.PrincipalName; +import sun.security.krb5.internal.ktab.KeyTab; + +public class KeyTabIndex { + public static void main(String[] args) throws Exception { + KeyTab kt = KeyTab.create("ktab"); + // Two entries with very different length, so that it's easy to + // observice the abnormal change of "index" field. + kt.addEntry(new PrincipalName( + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa@A"), + "x".toCharArray(), 1); + kt.addEntry(new PrincipalName("a@A"), "x".toCharArray(), 1); + kt.save(); + Runnable t = new Runnable() { + @Override + public void run() { + KeyTab.getInstance("ktab").getClass(); + } + }; + KeyTab.refresh(); + for (int i=0; i<10; i++) { + new Thread(t).start(); + } + } +}