File tree Expand file tree Collapse file tree 1 file changed +13
-9
lines changed
src/main/java/io/github/nstdio/http/ext Expand file tree Collapse file tree 1 file changed +13
-9
lines changed Original file line number Diff line number Diff line change @@ -105,42 +105,46 @@ public int available() throws IOException {
105105 }
106106
107107 @ Override
108- public void reset () throws IOException {
108+ public synchronized void reset () throws IOException {
109109 if (mark == null ) {
110110 throw new IOException ("nothing to reset" );
111111 }
112112
113113 buffers .push (mark .flip ());
114+ unsetMark ();
115+ }
116+
117+ private void unsetMark () {
114118 mark = null ;
115119 }
116120
117121 @ Override
118- public void mark (int readlimit ) {
122+ public synchronized void mark (int readlimit ) {
119123 if (readlimit <= 0 ) {
120- mark = null ;
124+ unsetMark () ;
121125 } else {
122126 mark = ByteBuffer .allocate (readlimit );
123127 }
124128 }
125129
126- private void mark0 (int b ) {
130+ private synchronized void mark0 (int b ) {
127131 ByteBuffer m ;
128132 if ((m = mark ) != null ) {
129133 if (m .hasRemaining ()) {
130134 m .put ((byte ) b );
131135 } else {
132- mark = null ;
136+ unsetMark () ;
133137 }
134138 }
135139 }
136140
137- private void mark0 (byte [] b , int off , int len ) {
141+ private synchronized void mark0 (byte [] b , int off , int len ) {
138142 ByteBuffer m ;
139143 if ((m = mark ) != null ) {
140144 if (len <= m .remaining ()) {
141145 m .put (b , off , len );
142146 } else {
143- mark = null ;
147+ unsetMark () ;
144148 }
145149 }
146150 }
@@ -171,7 +175,7 @@ public byte[] readNBytes(int len) throws IOException {
171175 @ Override
172176 public void close () {
173177 buffers .clear ();
174- mark = null ;
178+ unsetMark () ;
175179 closed = true ;
176180 }
177181
@@ -194,7 +198,7 @@ List<ByteBuffer> drainToList() {
194198
195199 var l = List .copyOf (buffs );
196200 buffs .clear ();
197- mark = null ;
201+ unsetMark () ;
198202
199203 return l ;
200204 }
You can’t perform that action at this time.
0 commit comments