Skip to content

Commit 6e70d08

Browse files
authored
Fix #1462: deprecate JsonFactory.createParser(URL) (#1464)
1 parent 588cc76 commit 6e70d08

File tree

3 files changed

+18
-12
lines changed

3 files changed

+18
-12
lines changed

release-notes/VERSION-2.x

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ a pure JSON library.
1414
=== Releases ===
1515
------------------------------------------------------------------------
1616

17+
#1462: Deprecate `URL`-taking factory method of `JsonFactory`
18+
1719
2.20.0-rc1 (04-Aug-2025)
1820

1921
#1438: `ParserBase.close()` does not clear `_currToken`

src/main/java/com/fasterxml/jackson/core/JsonFactory.java

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1221,23 +1221,18 @@ public JsonParser createParser(File f) throws IOException, JsonParseException {
12211221
}
12221222

12231223
/**
1224-
* Method for constructing JSON parser instance to parse
1225-
* contents of resource reference by given URL.
1226-
*<p>
1227-
* Encoding is auto-detected from contents according to JSON
1228-
* specification recommended mechanism. Json specification
1229-
* supports only UTF-8, UTF-16 and UTF-32 as valid encodings,
1230-
* so auto-detection implemented only for this charsets.
1231-
* For other charsets use {@link #createParser(java.io.Reader)}.
1232-
*<p>
1233-
* Underlying input stream (needed for reading contents)
1234-
* will be <b>owned</b> (and managed, i.e. closed as need be) by
1235-
* the parser, since caller has no access to it.
1224+
* Deprecated variant of {@link #createParser(InputStream)}
1225+
* no longer recommended to be used due to implementation
1226+
* problems like {@href "https://github.com/FasterXML/jackson-core/issues/803"}.
12361227
*
12371228
* @param url URL pointing to resource that contains JSON content to parse
12381229
*
12391230
* @since 2.1
1231+
*
1232+
* @deprecated Since 2.20 use other variants (like {@link #createParser(InputStream)})
1233+
* instead.
12401234
*/
1235+
@Deprecated // since 2.20
12411236
@Override
12421237
public JsonParser createParser(URL url) throws IOException, JsonParseException {
12431238
// true, since we create InputStream from URL

src/main/java/com/fasterxml/jackson/core/TokenStreamFactory.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,15 @@ public abstract JsonParser createParser(char[] content, int offset, int len)
198198
public abstract JsonParser createParser(InputStream in) throws IOException;
199199
public abstract JsonParser createParser(Reader r) throws IOException;
200200
public abstract JsonParser createParser(String content) throws IOException;
201+
202+
/**
203+
* Deprecated factory method: no longer recommended to be used due to implementation
204+
* problems like {@href "https://github.com/FasterXML/jackson-core/issues/803"}.
205+
*
206+
* @deprecated since 2.20 caller needs to construct {@link InputStream} (or {@link Reader})
207+
* from {@link URL} directly and pass that.
208+
*/
209+
@Deprecated
201210
public abstract JsonParser createParser(URL url) throws IOException;
202211

203212
/**

0 commit comments

Comments
 (0)