java.lang.ClassCastException: scala.collection.mutable.FlatHashTable$NullSentinel$ cannot be cast to java.lang.String at $anonfun$1.apply(:9)

Scala JIRA | James Iry | 4 years ago
  1. 0

    [SI-6908] FlatHashTable and things that depend on it like mutable.HashSet cannot store nulls - Scala

    scala-lang.org | 1 year ago
    java.lang.ClassCastException: scala.collection.mutable.FlatHashTable$NullSentinel$ cannot be cast to java.lang.String at $anonfun$1.apply(:9)
  2. 0

    mutable.HashSet or anything that depends on FlatHashTable for its implementation cannot have null values. But allowing it to support null is easy and would extend the functionality nicely scala> val h = new scala.collection.mutable.HashSet[String] h: scala.collection.mutable.HashSet[String] = Set() scala> h.contains(null) java.lang.IllegalArgumentException: Flat hash tables cannot contain null elements. at scala.collection.mutable.FlatHashTable$HashUtils$class.elemHashCode(FlatHashTable.scala:348) at scala.collection.mutable.HashSet.elemHashCode(HashSet.scala:41) at scala.collection.mutable.FlatHashTable$class.containsEntry(FlatHashTable.scala:109) at scala.collection.mutable.HashSet.containsEntry(HashSet.scala:41) at scala.collection.mutable.HashSet.contains(HashSet.scala:57) ... You might think "oh, let's just make contains smart about null" but look at this scala> val xs = null :: Nil xs: List[Null] = List(null) scala> xs.distinct java.lang.IllegalArgumentException: Flat hash tables cannot contain null elements. ...etc now, making contains not explode on null would prevent that stack trace...but the resulting set would be empty even though the original list was not. I contend that doesn't make sense and that the only thing that does make sense is to make FlatHashTable allow nulls just as List does.

    Scala JIRA | 4 years ago | James Iry
    java.lang.ClassCastException: scala.collection.mutable.FlatHashTable$NullSentinel$ cannot be cast to java.lang.String at $anonfun$1.apply(:9)
  3. 0

    Null Handling in scala.collection.mutable.FlatHashTable

    GitHub | 3 years ago | cheeseng
    java.lang.ClassCastException: scala.collection.mutable.FlatHashTable$NullSentinel$ cannot be cast to java.lang.String at $anonfun$1.apply(:9)
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Convert Scala List to List with another type

    Stack Overflow | 5 years ago | Noel
    java.lang.ClassCastException: java.lang.String cannot be cast to usda.rd.broadband.model.DatabaseTables$TelephoneCompany at $anonfun$foo$1.apply(<console>:11)
  6. 0

    Camel - Users - Camel Kafka - java.lang.ClassCastException: java.lang.String cannot be cast to [B

    nabble.com | 1 year ago
    java.lang.ClassCastException: java.lang.String cannot be cast to [B > at kafka.serializer.DefaultEncoder.toBytes(Encoder.scala:34) > [kafka_2.10-0.8.1.jar:] > at > kafka.producer.async.DefaultEventHandler$$anonfun$serialize$1.apply(DefaultEventHandler.scala:128) > [kafka_2.10-0.8.1.jar:] > at > kafka.producer.async.DefaultEventHandler$$anonfun$serialize$1.apply(DefaultEventHandler.scala:125) > [kafka_2.10-0.8.1.jar:] > at > scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244) at > scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244) at > scala.collection.IndexedSeqOptimized$class.foreach(IndexedSeqOptimized.scala:33)

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.ClassCastException

      scala.collection.mutable.FlatHashTable$NullSentinel$ cannot be cast to java.lang.String at $anonfun$1.apply(:9)

      at scala.collection.Iterator$class.exists()
    2. Scala
      Iterator$class.exists
      1. scala.collection.Iterator$class.exists(Iterator.scala:769)
      1 frame