You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by ni...@apache.org on 2016/10/11 18:35:04 UTC

[19/47] lucenenet git commit: Core.Store.CompoundFileDirectory: Fixed issue where magic byte was not correctly represented as negative (secondByte is always negative and represents the Lucene version).

Core.Store.CompoundFileDirectory: Fixed issue where magic byte was not correctly represented as negative (secondByte is always negative and represents the Lucene version).


Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/824ee5e0
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/824ee5e0
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/824ee5e0

Branch: refs/heads/master
Commit: 824ee5e0a720e7243d4d97603948b67e2e7f12e9
Parents: 731a4cb
Author: Shad Storhaug <sh...@shadstorhaug.com>
Authored: Sun Oct 9 01:41:06 2016 +0700
Committer: Shad Storhaug <sh...@shadstorhaug.com>
Committed: Tue Oct 11 00:26:21 2016 +0700

----------------------------------------------------------------------
 src/Lucene.Net.Core/Store/CompoundFileDirectory.cs | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/824ee5e0/src/Lucene.Net.Core/Store/CompoundFileDirectory.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Store/CompoundFileDirectory.cs b/src/Lucene.Net.Core/Store/CompoundFileDirectory.cs
index 061048f..019c0f1 100644
--- a/src/Lucene.Net.Core/Store/CompoundFileDirectory.cs
+++ b/src/Lucene.Net.Core/Store/CompoundFileDirectory.cs
@@ -130,10 +130,11 @@ namespace Lucene.Net.Store
             }
         }
 
-        private static readonly byte CODEC_MAGIC_BYTE1 = (byte)Number.URShift(CodecUtil.CODEC_MAGIC, 24);
-        private static readonly byte CODEC_MAGIC_BYTE2 = (byte)Number.URShift(CodecUtil.CODEC_MAGIC, 16);
-        private static readonly byte CODEC_MAGIC_BYTE3 = (byte)Number.URShift(CodecUtil.CODEC_MAGIC, 8);
-        private static readonly byte CODEC_MAGIC_BYTE4 = unchecked((byte)CodecUtil.CODEC_MAGIC);
+        // LUCENENET NOTE: These MUST be sbyte because they can be negative
+        private static readonly sbyte CODEC_MAGIC_BYTE1 = (sbyte)Number.URShift(CodecUtil.CODEC_MAGIC, 24);
+        private static readonly sbyte CODEC_MAGIC_BYTE2 = (sbyte)Number.URShift(CodecUtil.CODEC_MAGIC, 16);
+        private static readonly sbyte CODEC_MAGIC_BYTE3 = (sbyte)Number.URShift(CodecUtil.CODEC_MAGIC, 8);
+        private static readonly sbyte CODEC_MAGIC_BYTE4 = unchecked((sbyte)CodecUtil.CODEC_MAGIC);
 
         /// <summary>
         /// Helper method that reads CFS entries from an input stream </summary>
@@ -153,9 +154,9 @@ namespace Lucene.Net.Store
                 // and separate norms/etc are outside of cfs.
                 if (firstInt == CODEC_MAGIC_BYTE1)
                 {
-                    byte secondByte = stream.ReadByte();
-                    byte thirdByte = stream.ReadByte();
-                    byte fourthByte = stream.ReadByte();
+                    sbyte secondByte = (sbyte)stream.ReadByte();
+                    sbyte thirdByte = (sbyte)stream.ReadByte();
+                    sbyte fourthByte = (sbyte)stream.ReadByte();
                     if (secondByte != CODEC_MAGIC_BYTE2 || thirdByte != CODEC_MAGIC_BYTE3 || fourthByte != CODEC_MAGIC_BYTE4)
                     {
                         throw new CorruptIndexException("Illegal/impossible header for CFS file: " + secondByte + "," + thirdByte + "," + fourthByte);