Skip to content

Commit e3c3941

Browse files
committed
Deprecate duplicated methods and fields in MBR/MBW
Signed-off-by: jansupol <jan.supol@oracle.com>
1 parent cacccd9 commit e3c3941

File tree

25 files changed

+83
-56
lines changed

25 files changed

+83
-56
lines changed

core-common/src/main/java/org/glassfish/jersey/message/internal/AbstractFormProvider.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2010, 2023 Oracle and/or its affiliates. All rights reserved.
33
*
44
* This program and the accompanying materials are made available under the
55
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -43,7 +43,7 @@ public abstract class AbstractFormProvider<T> extends AbstractMessageReaderWrite
4343
public <M extends MultivaluedMap<String, String>> M readFrom(M map,
4444
MediaType mediaType, boolean decode,
4545
InputStream entityStream) throws IOException {
46-
final String encoded = readFromAsString(entityStream, mediaType);
46+
final String encoded = ReaderWriter.readFromAsString(entityStream, mediaType);
4747

4848
final String charsetName = ReaderWriter.getCharset(mediaType).name();
4949

@@ -90,6 +90,6 @@ public <M extends MultivaluedMap<String, String>> void writeTo(
9090
}
9191
}
9292

93-
writeToAsString(sb.toString(), entityStream, mediaType);
93+
ReaderWriter.writeToAsString(sb.toString(), entityStream, mediaType);
9494
}
9595
}

core-common/src/main/java/org/glassfish/jersey/message/internal/AbstractMessageReaderWriterProvider.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,14 @@ public static void writeTo(Reader in, Writer out) throws IOException {
8181
* Get the character set from a media type.
8282
* <p>
8383
* The character set is obtained from the media type parameter "charset".
84-
* If the parameter is not present the {@link #UTF8} charset is utilized.
84+
* If the parameter is not present the {@link StandardCharsets#UTF_8} charset is utilized.
8585
*
8686
* @param m the media type.
8787
* @return the character set.
88+
*
89+
* @deprecated use {@code ReaderWriter.getCharset(m)} instead
8890
*/
91+
@Deprecated
8992
public static Charset getCharset(MediaType m) {
9093
return ReaderWriter.getCharset(m);
9194
}
@@ -99,7 +102,10 @@ public static Charset getCharset(MediaType m) {
99102
* @return the string.
100103
*
101104
* @throws IOException if there is an error reading from the input stream.
105+
*
106+
* @deprecated use {@code ReaderWriter.readFromAsString(in, type)} instead
102107
*/
108+
@Deprecated
103109
public static String readFromAsString(InputStream in, MediaType type) throws IOException {
104110
return ReaderWriter.readFromAsString(in, type);
105111
}
@@ -112,7 +118,10 @@ public static String readFromAsString(InputStream in, MediaType type) throws IOE
112118
* @param type the media type that determines the character set defining
113119
* how to decode bytes to characters.
114120
* @throws IOException in case of a write failure.
121+
*
122+
* @deprecated use {@code ReaderWriter.writeToAsString(s, out, type)} instead
115123
*/
124+
@Deprecated
116125
public static void writeToAsString(String s, OutputStream out, MediaType type) throws IOException {
117126
ReaderWriter.writeToAsString(s, out, type);
118127
}

core-common/src/main/java/org/glassfish/jersey/message/internal/BasicTypesMessageProvider.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2012, 2023 Oracle and/or its affiliates. All rights reserved.
33
*
44
* This program and the accompanying materials are made available under the
55
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -144,7 +144,7 @@ public Object readFrom(
144144
MediaType mediaType,
145145
MultivaluedMap<String, String> httpHeaders,
146146
InputStream entityStream) throws IOException, WebApplicationException {
147-
final String entityString = readFromAsString(entityStream, mediaType);
147+
final String entityString = ReaderWriter.readFromAsString(entityStream, mediaType);
148148
if (entityString.isEmpty()) {
149149
throw new NoContentException(LocalizationMessages.ERROR_READING_ENTITY_MISSING());
150150
}
@@ -210,6 +210,6 @@ public void writeTo(
210210
MediaType mediaType,
211211
MultivaluedMap<String, Object> httpHeaders,
212212
OutputStream entityStream) throws IOException, WebApplicationException {
213-
writeToAsString(o.toString(), entityStream, mediaType);
213+
ReaderWriter.writeToAsString(o.toString(), entityStream, mediaType);
214214
}
215215
}

core-common/src/main/java/org/glassfish/jersey/message/internal/ByteArrayProvider.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2010, 2023 Oracle and/or its affiliates. All rights reserved.
33
*
44
* This program and the accompanying materials are made available under the
55
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -52,7 +52,7 @@ public byte[] readFrom(
5252
MultivaluedMap<String, String> httpHeaders,
5353
InputStream entityStream) throws IOException {
5454
ByteArrayOutputStream out = new ByteArrayOutputStream();
55-
writeTo(entityStream, out);
55+
ReaderWriter.writeTo(entityStream, out);
5656
return out.toByteArray();
5757
}
5858

core-common/src/main/java/org/glassfish/jersey/message/internal/DataSourceProvider.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2010, 2023 Oracle and/or its affiliates. All rights reserved.
33
*
44
* This program and the accompanying materials are made available under the
55
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -162,7 +162,7 @@ public void writeTo(
162162
final OutputStream entityStream) throws IOException {
163163
final InputStream in = t.getInputStream();
164164
try {
165-
writeTo(in, entityStream);
165+
ReaderWriter.writeTo(in, entityStream);
166166
} finally {
167167
in.close();
168168
}

core-common/src/main/java/org/glassfish/jersey/message/internal/EnumMessageProvider.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2021 Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2021, 2023 Oracle and/or its affiliates. All rights reserved.
33
*
44
* This program and the accompanying materials are made available under the
55
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -50,7 +50,7 @@ public Enum readFrom(
5050
MediaType mediaType,
5151
MultivaluedMap<String, String> httpHeaders,
5252
InputStream entityStream) throws IOException, WebApplicationException {
53-
final String value = readFromAsString(entityStream, mediaType);
53+
final String value = ReaderWriter.readFromAsString(entityStream, mediaType);
5454
return Enum.valueOf(type, value);
5555
}
5656

@@ -67,6 +67,6 @@ public void writeTo(
6767
MediaType mediaType,
6868
MultivaluedMap<String, Object> httpHeaders,
6969
OutputStream entityStream) throws IOException, WebApplicationException {
70-
writeToAsString(anEnum.name(), entityStream, mediaType);
70+
ReaderWriter.writeToAsString(anEnum.name(), entityStream, mediaType);
7171
}
7272
}

core-common/src/main/java/org/glassfish/jersey/message/internal/InputStreamProvider.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2010, 2023 Oracle and/or its affiliates. All rights reserved.
33
*
44
* This program and the accompanying materials are made available under the
55
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -79,7 +79,7 @@ public void writeTo(
7979
MultivaluedMap<String, Object> httpHeaders,
8080
OutputStream entityStream) throws IOException {
8181
try {
82-
writeTo(t, entityStream);
82+
ReaderWriter.writeTo(t, entityStream);
8383
} finally {
8484
t.close();
8585
}

core-common/src/main/java/org/glassfish/jersey/message/internal/ReaderProvider.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2010, 2023 Oracle and/or its affiliates. All rights reserved.
33
*
44
* This program and the accompanying materials are made available under the
55
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -66,7 +66,7 @@ public Reader readFrom(
6666
new ByteArrayInputStream(new byte[0]), MessageUtils.getCharset(mediaType)));
6767
}
6868

69-
return new BufferedReader(new InputStreamReader(entityStream, getCharset(mediaType)));
69+
return new BufferedReader(new InputStreamReader(entityStream, ReaderWriter.getCharset(mediaType)));
7070
}
7171

7272
@Override
@@ -86,8 +86,8 @@ public void writeTo(
8686
final OutputStream entityStream) throws IOException {
8787
try {
8888
final OutputStreamWriter out = new OutputStreamWriter(entityStream,
89-
getCharset(mediaType));
90-
writeTo(t, out);
89+
ReaderWriter.getCharset(mediaType));
90+
ReaderWriter.writeTo(t, out);
9191
out.flush();
9292
} finally {
9393
t.close();

core-common/src/main/java/org/glassfish/jersey/message/internal/ReaderWriter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,14 @@ public static void writeTo(Reader in, Writer out) throws IOException {
119119
* Get the character set from a media type.
120120
* <p>
121121
* The character set is obtained from the media type parameter "charset".
122-
* If the parameter is not present the {@link #UTF8} charset is utilized.
122+
* If the parameter is not present the {@link StandardCharsets#UTF_8} charset is utilized.
123123
*
124124
* @param m the media type.
125125
* @return the character set.
126126
*/
127127
public static Charset getCharset(MediaType m) {
128128
String name = (m == null) ? null : m.getParameters().get(MediaType.CHARSET_PARAMETER);
129-
return (name == null) ? UTF8 : Charset.forName(name);
129+
return (name == null) ? StandardCharsets.UTF_8 : Charset.forName(name);
130130
}
131131

132132
/**

core-common/src/main/java/org/glassfish/jersey/message/internal/StringMessageProvider.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2010, 2023 Oracle and/or its affiliates. All rights reserved.
33
*
44
* This program and the accompanying materials are made available under the
55
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -51,7 +51,7 @@ public String readFrom(
5151
MediaType mediaType,
5252
MultivaluedMap<String, String> httpHeaders,
5353
InputStream entityStream) throws IOException {
54-
return readFromAsString(entityStream, mediaType);
54+
return ReaderWriter.readFromAsString(entityStream, mediaType);
5555
}
5656

5757
@Override
@@ -73,6 +73,6 @@ public void writeTo(
7373
MediaType mediaType,
7474
MultivaluedMap<String, Object> httpHeaders,
7575
OutputStream entityStream) throws IOException {
76-
writeToAsString(t, entityStream, mediaType);
76+
ReaderWriter.writeToAsString(t, entityStream, mediaType);
7777
}
7878
}

0 commit comments

Comments
 (0)