[Mono-bugs] [Bug 75790][Nor] New - InvalidCastException from cloned
synchronized Hashtable that doesn't come from original hashtable.
bugzilla-daemon at bugzilla.ximian.com
bugzilla-daemon at bugzilla.ximian.com
Fri Aug 12 01:25:18 EDT 2005
Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.
Changed by nev at delap.com.
http://bugzilla.ximian.com/show_bug.cgi?id=75790
--- shadow/75790 2005-08-12 01:25:18.000000000 -0400
+++ shadow/75790.tmp.31446 2005-08-12 01:25:18.000000000 -0400
@@ -0,0 +1,62 @@
+Bug#: 75790
+Product: Mono: Class Libraries
+Version: 1.1
+OS:
+OS Details: Linux-2.6.8-2-k7-i686-with-debian-3.1
+Status: NEW
+Resolution:
+Severity:
+Priority: Normal
+Component: System
+AssignedTo: mono-bugs at ximian.com
+ReportedBy: Nev at Delap.com
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: InvalidCastException from cloned synchronized Hashtable that doesn't come from original hashtable.
+
+{
+ // This works... (Ordinary hashtable, GetEnumerator on the hashtable)
+ Hashtable hashtable = new Hashtable();
+ hashtable["a"] = 1;
+ IEnumerator enumerator = hashtable.GetEnumerator();
+ enumerator.Reset();
+ enumerator.MoveNext();
+ DictionaryEntry dictionaryEntry = (DictionaryEntry)enumerator.Current;
+}
+{
+ // This works... (Synchronized hashtable, GetEnumerator on the
+hashtable)
+ Hashtable hashtable = Hashtable.Synchronized(new Hashtable());
+ hashtable["a"] = 1;
+ IEnumerator enumerator = hashtable.GetEnumerator();
+ enumerator.Reset();
+ enumerator.MoveNext();
+ DictionaryEntry dictionaryEntry = (DictionaryEntry)enumerator.Current;
+}
+{
+#if Mono
+ try
+ {
+ // This doesn't work... (Synchronized hashtable, GetEnumerator on
+clone of hashtable)
+ Hashtable hashtable = Hashtable.Synchronized(new Hashtable());
+ hashtable["a"] = 1;
+ IEnumerator enumerator2 = (hashtable.Clone() as
+ICollection).GetEnumerator();
+ enumerator2.Reset();
+ enumerator2.MoveNext();
+ DictionaryEntry dictionaryEntry2 = (DictionaryEntry)
+enumerator2.Current; // << Throws.
+ Assert.Fail("When this fails it means they've fixed " +
+ "this bug - http://bugzilla.ximian.com/show_bug.cgi?
+id=???");
+ }
+ catch (InvalidCastException)
+ {
+ Console.WriteLine("Please Note: Mono is (still) broken. See:
+http://bugzilla.ximian.com/show_bug.cgi?id=???");
+ }
+#endif
+}
More information about the mono-bugs
mailing list