From b55fd0c0fc990687dab1484e1046a82a5999d850 Mon Sep 17 00:00:00 2001 From: kimchy Date: Wed, 21 Jul 2010 23:46:11 +0300 Subject: [PATCH] verify that data that is written to the blob (in fs) is the same as expected in the blob write api call --- .../common/blobstore/fs/FsImmutableBlobContainer.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/common/blobstore/fs/FsImmutableBlobContainer.java b/modules/elasticsearch/src/main/java/org/elasticsearch/common/blobstore/fs/FsImmutableBlobContainer.java index bd26a0d91e5..99c5df8de84 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/common/blobstore/fs/FsImmutableBlobContainer.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/common/blobstore/fs/FsImmutableBlobContainer.java @@ -19,6 +19,7 @@ package org.elasticsearch.common.blobstore.fs; +import org.elasticsearch.ElasticSearchIllegalStateException; import org.elasticsearch.common.blobstore.BlobPath; import org.elasticsearch.common.blobstore.ImmutableBlobContainer; import org.elasticsearch.common.blobstore.support.BlobStores; @@ -53,10 +54,16 @@ public class FsImmutableBlobContainer extends AbstractFsBlobContainer implements } try { try { + long bytesWritten = 0; byte[] buffer = new byte[blobStore.bufferSizeInBytes()]; int bytesRead; while ((bytesRead = is.read(buffer)) != -1) { raf.write(buffer, 0, bytesRead); + bytesWritten += bytesRead; + } + if (bytesWritten != sizeInBytes) { + listener.onFailure(new ElasticSearchIllegalStateException("[" + blobName + "]: wrote [" + bytesWritten + "], expected to write [" + sizeInBytes + "]")); + return; } } finally { try {