diff --git a/src/test/java/org/elasticsearch/index/store/CorruptedFileTest.java b/src/test/java/org/elasticsearch/index/store/CorruptedFileTest.java index e0ae43a440c..9fc97f419a2 100644 --- a/src/test/java/org/elasticsearch/index/store/CorruptedFileTest.java +++ b/src/test/java/org/elasticsearch/index/store/CorruptedFileTest.java @@ -35,7 +35,6 @@ import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus; import org.elasticsearch.action.admin.cluster.node.stats.NodeStats; import org.elasticsearch.action.admin.cluster.node.stats.NodesStatsResponse; import org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotResponse; -import org.elasticsearch.action.admin.cluster.snapshots.restore.RestoreSnapshotResponse; import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse; import org.elasticsearch.action.count.CountResponse; import org.elasticsearch.action.index.IndexRequestBuilder; @@ -493,9 +492,10 @@ public class CorruptedFileTest extends ElasticsearchIntegrationTest { long filePointer = raf.getFilePointer(); byte b = raf.readByte(); raf.seek(filePointer); - raf.writeByte(~b); + int corruptedValue = (b + 1) & 0xff; + raf.writeByte(corruptedValue); raf.getFD().sync(); - logger.info("Corrupting file for shard {} -- flipping at position {} from {} to {} file: {}", shardRouting, filePointer, Integer.toHexString(b), Integer.toHexString(~b), fileToCorrupt.getName()); + logger.info("Corrupting file for shard {} -- flipping at position {} from {} to {} file: {}", shardRouting, filePointer, Integer.toHexString(b), Integer.toHexString(corruptedValue), fileToCorrupt.getName()); } long checksumAfterCorruption; long actualChecksumAfterCorruption; diff --git a/src/test/java/org/elasticsearch/index/store/CorruptedTranslogTests.java b/src/test/java/org/elasticsearch/index/store/CorruptedTranslogTests.java index 854dca09a6d..8a3df647db4 100644 --- a/src/test/java/org/elasticsearch/index/store/CorruptedTranslogTests.java +++ b/src/test/java/org/elasticsearch/index/store/CorruptedTranslogTests.java @@ -139,9 +139,10 @@ public class CorruptedTranslogTests extends ElasticsearchIntegrationTest { long filePointer = raf.getFilePointer(); byte b = raf.readByte(); raf.seek(filePointer); - raf.writeByte(~b); + int corruptedValue = (b + 1) & 0xff; + raf.writeByte(corruptedValue); raf.getFD().sync(); - logger.info("--> corrupting file {} -- flipping at position {} from {} to {} file: {}", fileToCorrupt.getName(), filePointer, Integer.toHexString(b), Integer.toHexString(~b), fileToCorrupt); + logger.info("--> corrupting file {} -- flipping at position {} from {} to {} file: {}", fileToCorrupt.getName(), filePointer, Integer.toHexString(b), Integer.toHexString(corruptedValue), fileToCorrupt); } } }