/**
  * Method called to get hold of a deserializer to use for deserializing keys for {@link
  * java.util.Map}.
  *
  * @throws JsonMappingException if there are fatal problems with accessing suitable key
  *     deserializer; including that of not finding any serializer
  */
 public KeyDeserializer findKeyDeserializer(
     DeserializationContext ctxt, DeserializerFactory factory, JavaType type)
     throws JsonMappingException {
   KeyDeserializer kd = factory.createKeyDeserializer(ctxt, type);
   if (kd == null) { // if none found, need to use a placeholder that'll fail
     return _handleUnknownKeyDeserializer(type);
   }
   // First: need to resolve?
   if (kd instanceof ResolvableDeserializer) {
     ((ResolvableDeserializer) kd).resolve(ctxt);
   }
   return kd;
 }
  /**
   * Method that handles actual construction (via factory) and caching (both intermediate and
   * eventual)
   */
  protected JsonDeserializer<Object> _createAndCache2(
      DeserializationContext ctxt, DeserializerFactory factory, JavaType type)
      throws JsonMappingException {
    JsonDeserializer<Object> deser;
    try {
      deser = _createDeserializer(ctxt, factory, type);
    } catch (IllegalArgumentException iae) {
      /* We better only expose checked exceptions, since those
       * are what caller is expected to handle
       */
      throw new JsonMappingException(iae.getMessage(), null, iae);
    }
    if (deser == null) {
      return null;
    }
    /* cache resulting deserializer? always true for "plain" BeanDeserializer
     * (but can be re-defined for sub-classes by using @JsonCachable!)
     */
    // 08-Jun-2010, tatu: Related to [JACKSON-296], need to avoid caching MapSerializers... so:
    boolean isResolvable = (deser instanceof ResolvableDeserializer);
    boolean addToCache = deser.isCachable();

    /* we will temporarily hold on to all created deserializers (to
     * handle cyclic references, and possibly reuse non-cached
     * deserializers (list, map))
     */
    /* 07-Jun-2010, tatu: Danger: [JACKSON-296] was caused by accidental
     *   resolution of a reference -- couple of ways to prevent this;
     *   either not add Lists or Maps, or clear references eagerly.
     *   Let's actually do both; since both seem reasonable.
     */
    /* Need to resolve? Mostly done for bean deserializers; required for
     * resolving cyclic references.
     */
    if (isResolvable) {
      _incompleteDeserializers.put(type, deser);
      ((ResolvableDeserializer) deser).resolve(ctxt);
      _incompleteDeserializers.remove(type);
    }
    if (addToCache) {
      _cachedDeserializers.put(type, deser);
    }
    return deser;
  }