Repository: kafka Updated Branches: refs/heads/0.9.0 ebd5f3360 -> c2b732584
MINOR: MemoryRecords.sizeInBytes throws NPE when non-writable. I just noticed that `MemoryRecords.sizeInBytes` throws NPE when MemoryRecords is non-writable. `compressor` is explicitly set to null when `writable` is false (L56) at the construction time, for instance when `MemoryRecords.readableRecords` is used. guozhangwang Could you take a look when you have time? Author: David Jacot <[email protected]> Reviewers: Guozhang Wang Closes #786 from dajac/kafka-npe (cherry picked from commit 0a7f2bf335e426b12f717ec7f6d51779d56fe59b) Signed-off-by: Guozhang Wang <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/kafka/repo Commit: http://git-wip-us.apache.org/repos/asf/kafka/commit/c2b73258 Tree: http://git-wip-us.apache.org/repos/asf/kafka/tree/c2b73258 Diff: http://git-wip-us.apache.org/repos/asf/kafka/diff/c2b73258 Branch: refs/heads/0.9.0 Commit: c2b73258454778731a8a27bca2836d25eaf04d06 Parents: ebd5f33 Author: David Jacot <[email protected]> Authored: Mon Jan 18 22:25:37 2016 -0800 Committer: Guozhang Wang <[email protected]> Committed: Mon Jan 18 22:25:56 2016 -0800 ---------------------------------------------------------------------- .../main/java/org/apache/kafka/common/record/MemoryRecords.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/kafka/blob/c2b73258/clients/src/main/java/org/apache/kafka/common/record/MemoryRecords.java ---------------------------------------------------------------------- diff --git a/clients/src/main/java/org/apache/kafka/common/record/MemoryRecords.java b/clients/src/main/java/org/apache/kafka/common/record/MemoryRecords.java index a5a56e1..971f0a2 100644 --- a/clients/src/main/java/org/apache/kafka/common/record/MemoryRecords.java +++ b/clients/src/main/java/org/apache/kafka/common/record/MemoryRecords.java @@ -145,7 +145,7 @@ public class MemoryRecords implements Records { if (writable) { return compressor.buffer().position(); } else { - return compressor.buffer().limit(); + return buffer.limit(); } }
