Skip to content

Commit 28e37c7

Browse files
committed
Fixes #1425: prevent StrinIndexOutOfBoundsException from JsonPointer.head()
1 parent 1be3020 commit 28e37c7

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.fasterxml.jackson.core.jsonptr;
2+
3+
import org.junit.jupiter.api.Test;
4+
5+
import com.fasterxml.jackson.core.JUnit5TestBase;
6+
import com.fasterxml.jackson.core.JsonPointer;
7+
8+
import static org.junit.jupiter.api.Assertions.assertEquals;
9+
10+
public class JsonPointer1425Test extends JUnit5TestBase
11+
{
12+
13+
// [core#1425]
14+
@Test
15+
public void test1425() {
16+
JsonPointer ptr = JsonPointer.compile("/a/b/0/qwerty");
17+
JsonPointer head = ptr.head();
18+
assertEquals("/a/b/0", head.toString());
19+
head = head.head(); // Exception happens here
20+
assertEquals("/a/b", head.toString());
21+
head = head.head();
22+
assertEquals("/a", head.toString());
23+
head = head.head();
24+
assertEquals("", head.toString());
25+
}
26+
}

0 commit comments

Comments
 (0)