title: Jackson: ignore unknown enum values
body: <p>I'm trying to deserialize a JSON object obtained from a RESTful webservice.
  I have the following class:</p>
  
  <pre><code>public class ACE {
      private Persona trustee;
      private String accesstype;
      private final Set&lt;Right&gt; accessrights = EnumSet.noneOf(Right.class);
      private final Set&lt;Inheritance&gt; inherit_flags
              = EnumSet.noneOf(Inheritance.class);
      private String op;
  
      public static enum Right {
          traverse, list, dir_read_attr, dir_read_ext_attr, add_file, add_subdir,
          dir_write_attr, dir_write_ext_attr, delete_child, std_delete,
          std_read_dac, std_write_dac, std_write_owner,
  
          dir_gen_all, dir_gen_execute, dir_gen_read, dir_gen_write, modify;
      }
  
      public static enum Inheritance {
          object_inherit, container_inherit, no_prop_inherit, inherit_only,
          inherited_ace;
      }
  
      public ACE setAccessrights(Set&lt;Right&gt; rights) {
          accessrights.clear();
          accessrights.addAll(rights);
          return this;
      }
  ...
  </code></pre>
  
  <p>Now the webservices returns 'std_synchronize' in the set 'accessrights', which is a value that is not defined in the Right enum type.</p>
  
  <p>I'm getting the following exception:</p>
  
  <pre><code>    com.fasterxml.jackson.databind.JsonMappingException: N/A (through reference chain: gina.nas.ws.ACL["acl"]-&gt;gina.nas.ws.ACE["accessrights"])
              at com.fasterxml.jackson.databind.deser.SettableBeanProperty._throwAsIOE(SettableBeanProperty.java:421)
              at com.fasterxml.jackson.databind.deser.SettableBeanProperty._throwAsIOE(SettableBeanProperty.java:404)
              at com.fasterxml.jackson.databind.deser.impl.MethodProperty.set(MethodProperty.java:116)
              at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:98)
              at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:308)
              at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:121)
              at com.fasterxml.jackson.databind.deser.std.ObjectArrayDeserializer.deserialize(ObjectArrayDeserializer.java:147)
              at com.fasterxml.jackson.databind.deser.std.ObjectArrayDeserializer.deserialize(ObjectArrayDeserializer.java:18)
              at com.fasterxml.jackson.databind.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:375)
              at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:98)
              at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:308)
              at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:121)
              at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:2793)
              at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:1989)
              at gina.nas.ws.NasSession.getACL(NasSession.java:188)
              at gina.nas.NasAPI.getSecurity(NasAPI.java:451)
              at gina.nas.NasAPI.getSecurity(NasAPI.java:244)
          at gina.nas.NasHelper.setStructureUOACL(NasHelper.java:622)
          at gina.nas.NasHelper.setStructureUOACL(NasHelper.java:263)
          at gina.nas.NasHelper.setStructureUOACL(NasHelper.java:280)
          at gina.nas.NasHelper.setStructureUOACL(NasHelper.java:299)
          at gina.nas.NasHelper.setStructureUOACL(NasHelper.java:317)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
          at java.lang.reflect.Method.invoke(Unknown Source)
          at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:126)
          ... 13 more
  Caused by: java.lang.NullPointerException
          at java.util.EnumSet.typeCheck(Unknown Source)
          at java.util.RegularEnumSet.add(Unknown Source)
          at java.util.RegularEnumSet.add(Unknown Source)
          at java.util.AbstractCollection.addAll(Unknown Source)
          at java.util.RegularEnumSet.addAll(Unknown Source)
          at gina.nas.ws.ACE.setAccessrights(ACE.java:51)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
          at java.lang.reflect.Method.invoke(Unknown Source)
          at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:97)
          ... 38 more
  </code></pre>
  
  <p>I have set the following flag in the ObjectMapper:</p>
  
  <pre><code>mapper.configure(
          DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_AS_NULL, true);
  </code></pre>
  
  <p>but the problem seems to arise when jackson tries to add null to the set.</p>
  
  <p>Is there a way to simply ignore unknown values?</p>