Skip to content

Commit f217685

Browse files
committed
Wrapping all methods of the EntityInputStream/InputStreamWrapper
Signed-off-by: Maxim Nesen <[email protected]>
1 parent 0f477df commit f217685

File tree

4 files changed

+114
-39
lines changed

4 files changed

+114
-39
lines changed

core-common/pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@
310310
</goals>
311311
</execution>
312312
<execution>
313-
<!-- Compile these files with jdk 8 and put them aside to be included in multirelase jar -->
313+
<!-- Compile these files with jdk 8 and put them aside to be included in multi-release jar -->
314314
<!-- Multi-release jar is built by jdk 11+, but these classes are buildable by jdk 8 only -->
315315
<id>compile-2-java8</id>
316316
<phase>process-resources</phase>
@@ -497,10 +497,10 @@
497497
<goal>copy-resources</goal>
498498
</goals>
499499
<configuration>
500-
<outputDirectory>${project.build.directory}/generated-sources/rsrc-gen/META-INF/versions/11/org/glassfish/jersey/internal/jsr166</outputDirectory>
500+
<outputDirectory>${project.build.directory}/generated-sources/rsrc-gen/META-INF/versions/11/org/glassfish/jersey</outputDirectory>
501501
<resources>
502502
<resource>
503-
<directory>${java11.sourceDirectory}/org/glassfish/jersey/internal/jsr166</directory>
503+
<directory>${java11.sourceDirectory}/org/glassfish/jersey</directory>
504504
</resource>
505505
</resources>
506506
</configuration>

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

Lines changed: 8 additions & 36 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, 2024 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
@@ -22,6 +22,7 @@
2222

2323
import javax.ws.rs.ProcessingException;
2424

25+
import org.glassfish.jersey.innate.io.InputStreamWrapper;
2526
import org.glassfish.jersey.internal.LocalizationMessages;
2627

2728
/**
@@ -33,7 +34,7 @@
3334
*
3435
* @author Marek Potociar
3536
*/
36-
public class EntityInputStream extends InputStream {
37+
public class EntityInputStream extends InputStreamWrapper {
3738

3839
private InputStream input;
3940
private boolean closed = false;
@@ -64,40 +65,6 @@ public EntityInputStream(InputStream input) {
6465
this.input = input;
6566
}
6667

67-
@Override
68-
public int read() throws IOException {
69-
return input.read();
70-
}
71-
72-
@Override
73-
public int read(byte[] b) throws IOException {
74-
return input.read(b);
75-
}
76-
77-
@Override
78-
public int read(byte[] b, int off, int len) throws IOException {
79-
return input.read(b, off, len);
80-
}
81-
82-
@Override
83-
public long skip(long n) throws IOException {
84-
return input.skip(n);
85-
}
86-
87-
@Override
88-
public int available() throws IOException {
89-
return input.available();
90-
}
91-
92-
@Override
93-
public void mark(int readLimit) {
94-
input.mark(readLimit);
95-
}
96-
97-
@Override
98-
public boolean markSupported() {
99-
return input.markSupported();
100-
}
10168

10269
/**
10370
* {@inheritDoc}
@@ -232,4 +199,9 @@ public final InputStream getWrappedStream() {
232199
public final void setWrappedStream(InputStream wrapped) {
233200
input = wrapped;
234201
}
202+
203+
@Override
204+
protected InputStream getWrapped() {
205+
return input;
206+
}
235207
}
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
/*
2+
* Copyright (c) 2024 Oracle and/or its affiliates. All rights reserved.
3+
*
4+
* This program and the accompanying materials are made available under the
5+
* terms of the Eclipse Public License v. 2.0, which is available at
6+
* http://www.eclipse.org/legal/epl-2.0.
7+
*
8+
* This Source Code may also be made available under the following Secondary
9+
* Licenses when the conditions for such availability set forth in the
10+
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
11+
* version 2 with the GNU Classpath Exception, which is available at
12+
* https://www.gnu.org/software/classpath/license.html.
13+
*
14+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15+
*/
16+
17+
package org.glassfish.jersey.innate.io;
18+
19+
import java.io.IOException;
20+
import java.io.InputStream;
21+
import java.io.OutputStream;
22+
23+
/**
24+
* Generic wrapper template for InputStream.
25+
*/
26+
public abstract class InputStreamWrapper extends InputStream {
27+
28+
/**
29+
* Return the wrapped stream
30+
* @return
31+
*/
32+
protected abstract InputStream getWrapped();
33+
34+
/**
35+
* Get wrapped stream that can throw {@link IOException}
36+
* @return the wrapped InputStream.
37+
* @throws IOException
38+
*/
39+
protected InputStream getWrappedIOE() throws IOException {
40+
return getWrapped();
41+
}
42+
43+
@Override
44+
public int read() throws IOException {
45+
return getWrappedIOE().read();
46+
}
47+
48+
@Override
49+
public int read(byte[] b) throws IOException {
50+
return getWrappedIOE().read(b);
51+
}
52+
53+
@Override
54+
public int read(byte[] b, int off, int len) throws IOException {
55+
return getWrappedIOE().read(b, off, len);
56+
}
57+
58+
@Override
59+
public byte[] readAllBytes() throws IOException {
60+
return getWrappedIOE().readAllBytes();
61+
}
62+
63+
@Override
64+
public int readNBytes(byte[] b, int off, int len) throws IOException {
65+
return getWrappedIOE().readNBytes(b, off, len);
66+
}
67+
68+
@Override
69+
public long transferTo(OutputStream out) throws IOException {
70+
return getWrappedIOE().transferTo(out);
71+
}
72+
73+
74+
@Override
75+
public long skip(long n) throws IOException {
76+
return getWrappedIOE().skip(n);
77+
}
78+
79+
@Override
80+
public int available() throws IOException {
81+
return getWrappedIOE().available();
82+
}
83+
84+
@Override
85+
public void close() throws IOException {
86+
getWrappedIOE().close();
87+
}
88+
89+
@Override
90+
public void mark(int readlimit) {
91+
getWrapped().mark(readlimit);
92+
}
93+
94+
@Override
95+
public void reset() throws IOException {
96+
getWrappedIOE().reset();
97+
}
98+
99+
@Override
100+
public boolean markSupported() {
101+
return getWrapped().markSupported();
102+
}
103+
}

core-common/src/main/java/org/glassfish/jersey/innate/io/InputStreamWrapper.java renamed to core-common/src/main/java8/org/glassfish/jersey/innate/io/InputStreamWrapper.java

File renamed without changes.

0 commit comments

Comments
 (0)