diff --git a/modules/core/src/main/java/org/apache/ignite/internal/jdbc2/JdbcDataBufferImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/jdbc2/JdbcDataBufferImpl.java index 4ca31c21b71a4..7afa73308fc8f 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/jdbc2/JdbcDataBufferImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/jdbc2/JdbcDataBufferImpl.java @@ -177,6 +177,10 @@ private static class MemoryStreamContext implements Context { private int inBufPos; public MemoryStreamContext(int idx, int inBufPos) { + set(idx, inBufPos); + } + + public void set(int idx, int inBufPos) { this.idx = idx; this.inBufPos = inBufPos; } @@ -292,9 +296,7 @@ public MemoryStorage(byte[] arr) { pos.setPos(pos.getPos() + step); - MemoryStreamContext context = (MemoryStreamContext)pos.context; - context.idx = idx; - context.inBufPos = inBufPos; + ((MemoryStreamContext)pos.context).set(idx, inBufPos); } @Override public void truncate(long len) { @@ -422,6 +424,13 @@ private static class FileStorage implements Storage { } @Override public void close() { + try { + tempFileChannel.close(); + } + catch (IOException ignore) { + // No-op + } + tempFileCleaner.clean(); } @@ -515,7 +524,7 @@ private BufferOutputStream(long pos) { /** {@inheritDoc} */ @Override public void write(int b) throws IOException { - data.write(bufPos, new byte[] {(byte)b}, 0, 1); + data.write(bufPos, b); totalCnt = Math.max(bufPos.getPos(), totalCnt); }