-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Wrap possible NullPointerException (#125)
- Loading branch information
1 parent
56ce944
commit 97f88da
Showing
7 changed files
with
85 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
...ns/src/test/java/com/fasterxml/jackson/datatype/eclipsecollections/Fuzz124_64629Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.fasterxml.jackson.datatype.eclipsecollections; | ||
|
||
import static org.junit.Assert.assertTrue; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
import org.eclipse.collections.api.map.primitive.MutableCharCharMap; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.fasterxml.jackson.databind.exc.MismatchedInputException; | ||
|
||
/** | ||
* Unit tests for verifying the fixes for OSS-Fuzz issues | ||
* work as expected | ||
* (see [datatypes-collections#124]). | ||
*/ | ||
public class Fuzz124_64629Test extends ModuleTestBase | ||
{ | ||
private final ObjectMapper MAPPER = mapperWithModule(); | ||
|
||
@Test | ||
public void testOSSFuzzIssue64629() throws Exception | ||
{ | ||
// Invalid token {"x?":[x?]: where ? is not ascii characters | ||
final char[] invalid = {123, 34, 824, 34, 58, 91, 120, 7, 93}; | ||
|
||
MismatchedInputException e = Assert.assertThrows( | ||
MismatchedInputException.class, | ||
() -> MAPPER.readValue(new String(invalid), MutableCharCharMap.class)); | ||
assertTrue(e.getMessage().contains("Cannot convert a JSON Null into a char element of map")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
guava/src/test/java/com/fasterxml/jackson/datatype/guava/fuzz/Fuzz124_64610Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.fasterxml.jackson.datatype.guava.fuzz; | ||
|
||
import static org.junit.Assert.assertTrue; | ||
|
||
import org.junit.Assert; | ||
|
||
import com.fasterxml.jackson.core.type.TypeReference; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.fasterxml.jackson.databind.exc.MismatchedInputException; | ||
import com.fasterxml.jackson.datatype.guava.ModuleTestBase; | ||
|
||
import com.google.common.collect.ImmutableSortedMultiset; | ||
|
||
/** | ||
* Unit tests for verifying the fixes for OSS-Fuzz issues | ||
* work as expected | ||
* (see [datatypes-collections#124]). | ||
*/ | ||
public class Fuzz124_64610Test extends ModuleTestBase | ||
{ | ||
private final ObjectMapper MAPPER = mapperWithModule(); | ||
|
||
public void testOSSFuzzIssue64610() throws Exception | ||
{ | ||
final TypeReference<?> ref = new TypeReference<ImmutableSortedMultiset<String>>() {}; | ||
MismatchedInputException e = Assert.assertThrows( | ||
MismatchedInputException.class, | ||
() -> MAPPER.readValue("[null]", ref)); | ||
assertTrue(e.getMessage().contains("Guava `ImmutableCollection`s cannot contain `null`s")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters