Skip to content

Updating to Jackson 2.7+ Fails #4073

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
rwinch opened this issue Sep 26, 2016 · 1 comment
Closed

Updating to Jackson 2.7+ Fails #4073

rwinch opened this issue Sep 26, 2016 · 1 comment
Assignees
Labels
in: build An issue in the build in: core An issue in spring-security-core type: bug A general bug
Milestone

Comments

@rwinch
Copy link
Member

rwinch commented Sep 26, 2016

Using Jackson 2.7+ with Spring Security's Jackson Support fails when trying to deserialize authorities. For example, after updating to Jackson 2.8.3 and adding the following added to SimpleGratnedAuthorityMixinTests

@Test
@SuppressWarnings("unchecked")
public void deserializeGrantedAuthoritiesTest() throws IOException {
    Set<GrantedAuthority> authorities = mapper.readValue(AUTHORITIES_SET_JSON, Set.class);
    assertThat(authorities).isNotNull();
    assertThat(authorities).extracting("authority").containsOnly("ROLE_USER");
}

fails with the following:

java.lang.IllegalStateException: No default constructor for [collection type; class java.util.Collections$UnmodifiableSet, contains [simple type, class java.lang.Object]]
    at com.fasterxml.jackson.databind.deser.std.StdValueInstantiator.createUsingDefault(StdValueInstantiator.java:240)
    at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:249)
    at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:26)
    at com.fasterxml.jackson.databind.jsontype.impl.AsArrayTypeDeserializer._deserialize(AsArrayTypeDeserializer.java:110)
    at com.fasterxml.jackson.databind.jsontype.impl.AsArrayTypeDeserializer.deserializeTypedFromArray(AsArrayTypeDeserializer.java:50)
    at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserializeWithType(CollectionDeserializer.java:310)
    at com.fasterxml.jackson.databind.deser.impl.TypeWrappedDeserializer.deserialize(TypeWrappedDeserializer.java:42)
    at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3788)
    at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2779)
    at org.springframework.security.jackson2.SimpleGrantedAuthorityMixinTests.deserializeGrantedAuthoritiesTest(SimpleGrantedAuthorityMixinTests.java:68)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

Caused by FasterXML/jackson-databind#1392

@rwinch rwinch added this to the 4.2.0 M2 milestone Sep 26, 2016
rwinch pushed a commit to rwinch/spring-security that referenced this issue Sep 26, 2016
@rwinch
Copy link
Member Author

rwinch commented Sep 26, 2016

cc @jeetmp3 Any ideas what is causing this? I created a branch for you to try at https://github.com/rwinch/spring-security/tree/gh-4073-update-jackson283-fails

@rwinch rwinch closed this as completed in 48ff518 Oct 13, 2016
@rwinch rwinch self-assigned this Oct 13, 2016
@rwinch rwinch added in: build An issue in the build in: core An issue in spring-security-core type: bug A general bug labels Oct 13, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: build An issue in the build in: core An issue in spring-security-core type: bug A general bug
Projects
None yet
Development

No branches or pull requests

1 participant