|
25 | 25 | import java.io.IOException;
|
26 | 26 | import java.util.Arrays;
|
27 | 27 | import java.util.List;
|
| 28 | +import java.util.logging.Level; |
| 29 | + |
| 30 | +import vavi.util.Debug; |
28 | 31 |
|
29 | 32 | import DiscUtils.Streams.SparseStream;
|
30 | 33 | import DiscUtils.Streams.StreamExtent;
|
@@ -179,7 +182,7 @@ public List<StreamExtent> getExtentsInRange(long start, long count) {
|
179 | 182 | * @param count The number of bytes to read.
|
180 | 183 | * @return The number of bytes read.
|
181 | 184 | */
|
182 |
| - public int read(byte[] buffer, int offset, int count) { |
| 185 | + public synchronized int read(byte[] buffer, int offset, int count) { |
183 | 186 | checkDisposed();
|
184 | 187 |
|
185 | 188 | if (_position >= getLength()) {
|
@@ -229,6 +232,7 @@ public int read(byte[] buffer, int offset, int count) {
|
229 | 232 | int bytesToRead = Math.min(count - totalBytesRead, block[0].getAvailable() - offsetInNextBlock);
|
230 | 233 |
|
231 | 234 | System.arraycopy(block[0].getData(), offsetInNextBlock, buffer, offset + totalBytesRead, bytesToRead);
|
| 235 | + |
232 | 236 | offsetInNextBlock = 0;
|
233 | 237 | totalBytesRead += bytesToRead;
|
234 | 238 | _position += bytesToRead;
|
@@ -313,7 +317,7 @@ public void flush() {
|
313 | 317 | * @param origin The base location.
|
314 | 318 | * @return The new absolute stream position.
|
315 | 319 | */
|
316 |
| - public long seek(long offset, SeekOrigin origin) { |
| 320 | + public synchronized long seek(long offset, SeekOrigin origin) { |
317 | 321 | checkDisposed();
|
318 | 322 | long effectiveOffset = offset;
|
319 | 323 | if (origin == SeekOrigin.Current) {
|
@@ -348,7 +352,7 @@ public void setLength(long value) {
|
348 | 352 | * @param offset The first byte to write from buffer.
|
349 | 353 | * @param count The number of bytes to write.
|
350 | 354 | */
|
351 |
| - public void write(byte[] buffer, int offset, int count) { |
| 355 | + public synchronized void write(byte[] buffer, int offset, int count) { |
352 | 356 | checkDisposed();
|
353 | 357 |
|
354 | 358 | _stats.setTotalWritesIn(_stats.getTotalWritesIn() + 1);
|
|
0 commit comments