Skip to content

Commit

Permalink
Fix #1917
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Jan 29, 2018
1 parent b18ecb3 commit e8546e9
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 64 deletions.
1 change: 1 addition & 0 deletions release-notes/VERSION
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ Versions: 3.x (for earlier see VERSION-2.x)
#1889: Merge `ContextualSerializer` into `JsonSerializer`, `ContextualDeserializer`
into `JsonDeserializer`
#1916: Change `MapperFeature.USE_GETTERS_AS_SETTERS)` default to `false`
#1917: Remove `canSerialize` and `canDeserialize` methods from `ObjectMapper`
- Remove `MappingJsonFactory`
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import java.text.DateFormat;
import java.text.ParseException;
import java.util.*;
import java.util.concurrent.atomic.AtomicReference;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.ObjectIdGenerator;
Expand Down Expand Up @@ -535,26 +534,6 @@ public final JsonNodeFactory getNodeFactory() {
/**********************************************************
*/

/**
* Method for checking whether we could find a deserializer
* for given type.
*/
public boolean hasValueDeserializerFor(JavaType type, AtomicReference<Throwable> cause) {
try {
return _cache.hasValueDeserializerFor(this, _factory, type);
} catch (JsonMappingException e) {
if (cause != null) {
cause.set(e);
}
} catch (RuntimeException e) {
if (cause == null) { // earlier behavior
throw e;
}
cause.set(e);
}
return false;
}

/**
* Method for finding a value deserializer, and creating a contextual
* version if necessary, for value reached via specified property.
Expand Down
39 changes: 0 additions & 39 deletions src/main/java/com/fasterxml/jackson/databind/ObjectMapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import java.text.DateFormat;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicReference;

import com.fasterxml.jackson.annotation.*;
import com.fasterxml.jackson.core.*;
Expand Down Expand Up @@ -2571,46 +2570,8 @@ public <T extends JsonNode> T valueToTree(Object fromValue)
throw new IllegalArgumentException(e.getMessage(), e);
}
return (T) result;
}

/*
/**********************************************************
/* Public API, accessors
/**********************************************************
*/

/**
* Method that can be called to check whether mapper thinks
* it could deserialize an Object of given type.
* Check is done by checking whether a registered deserializer can
* be found or built for the type; if not (either by no mapping being
* found, or through an <code>Exception</code> being thrown, false
* is returned.
*<p>
* <b>NOTE</b>: in case an exception is thrown during course of trying
* co construct matching deserializer, it will be effectively swallowed.
* If you want access to that exception, call
* {@link #canDeserialize(JavaType, AtomicReference)} instead.
*
* @return True if mapper can find a serializer for instances of
* given class (potentially serializable), false otherwise (not
* serializable)
*/
public boolean canDeserialize(JavaType type)
{
return createDeserializationContext().hasValueDeserializerFor(type, null);
}

/**
* Method similar to {@link #canDeserialize(JavaType)} but that can return
* actual {@link Throwable} that was thrown when trying to construct
* serializer: this may be useful in figuring out what the actual problem is.
*/
public boolean canDeserialize(JavaType type, AtomicReference<Throwable> cause)
{
return createDeserializationContext().hasValueDeserializerFor(type, cause);
}

/*
/**********************************************************
/* Public API, deserialization,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,24 +172,25 @@ public KeyDeserializer findKeyDeserializer(DeserializationContext ctxt,
return kd;
}

// as per [databind#1917], not needed any more:
/**
* Method called to find out whether provider would be able to find
* a deserializer for given type, using a root reference (i.e. not
* through fields or membership in an array or collection)
*/
public boolean hasValueDeserializerFor(DeserializationContext ctxt,
DeserializerFactory factory, JavaType type)
throws JsonMappingException
{
/* Note: mostly copied from findValueDeserializer, except for
* handling of unknown types
*/
// Note: mostly copied from findValueDeserializer, except for
// handling of unknown types
JsonDeserializer<Object> deser = _findCachedDeserializer(type);
if (deser == null) {
deser = _createAndCacheValueDeserializer(ctxt, factory, type);
}
return (deser != null);
}
*/


/*
/**********************************************************
Expand Down

0 comments on commit e8546e9

Please sign in to comment.