8015731: Subject java.security.auth.subject to improvements
authorweijun
Thu, 13 Jun 2013 10:31:21 +0800
changeset 20806 d94588b7854d
parent 20805 ae41216325dd
child 20807 841e21c03f0f
8015731: Subject java.security.auth.subject to improvements Reviewed-by: skoivu, mullan
jdk/src/share/classes/javax/security/auth/Subject.java
--- a/jdk/src/share/classes/javax/security/auth/Subject.java	Thu Jun 13 10:21:06 2013 +0800
+++ b/jdk/src/share/classes/javax/security/auth/Subject.java	Thu Jun 13 10:31:21 2013 +0800
@@ -1297,8 +1297,14 @@
         {
             ObjectInputStream.GetField fields = ois.readFields();
             subject = (Subject) fields.get("this$0", null);
-            elements = (LinkedList<E>) fields.get("elements", null);
             which = fields.get("which", 0);
+
+            LinkedList<E> tmp = (LinkedList<E>) fields.get("elements", null);
+            if (tmp.getClass() != LinkedList.class) {
+                elements = new LinkedList<E>(tmp);
+            } else {
+                elements = tmp;
+            }
         }
     }