Return-Path: X-Original-To: apmail-ignite-commits-archive@minotaur.apache.org Delivered-To: apmail-ignite-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id E54E6183C8 for ; Tue, 24 Nov 2015 17:51:18 +0000 (UTC) Received: (qmail 36589 invoked by uid 500); 24 Nov 2015 17:51:18 -0000 Delivered-To: apmail-ignite-commits-archive@ignite.apache.org Received: (qmail 36467 invoked by uid 500); 24 Nov 2015 17:51:18 -0000 Mailing-List: contact commits-help@ignite.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.apache.org Delivered-To: mailing list commits@ignite.apache.org Received: (qmail 35335 invoked by uid 99); 24 Nov 2015 17:51:18 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 24 Nov 2015 17:51:18 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 2AC75E0A36; Tue, 24 Nov 2015 17:51:18 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: raulk@apache.org To: commits@ignite.apache.org Date: Tue, 24 Nov 2015 17:51:44 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [28/51] [abbrv] ignite git commit: IGNITE-1973: Binary format: raw reader can be called only once. IGNITE-1973: Binary format: raw reader can be called only once. Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/96ae696f Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/96ae696f Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/96ae696f Branch: refs/heads/ignite-1270 Commit: 96ae696f1cb7aad3fce47c3dd7e43699b0d78fff Parents: 5dce6d9 Author: vozerov-gridgain Authored: Mon Nov 23 11:45:41 2015 +0300 Committer: vozerov-gridgain Committed: Mon Nov 23 11:45:41 2015 +0300 ---------------------------------------------------------------------- .../internal/portable/BinaryReaderExImpl.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/96ae696f/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryReaderExImpl.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryReaderExImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryReaderExImpl.java index 2534fd7..a2e18b4 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryReaderExImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryReaderExImpl.java @@ -168,6 +168,9 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Obje /** Order of a field whose match is expected. */ private int matchingOrder; + /** Whether stream is in raw mode. */ + private boolean raw; + /** * Constructor. * @@ -1384,9 +1387,15 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Obje /** {@inheritDoc} */ @Override public BinaryRawReader rawReader() { - streamPositionRandom(rawOff); + if (!raw) { + streamPositionRandom(rawOff); + + raw = true; - return this; + return this; + } + else + throw new BinaryObjectException("Method \"rawReader\" can be called only once."); } /** @@ -2483,6 +2492,9 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Obje * @return Offset. */ public boolean findFieldByName(String name) { + if (raw) + throw new BinaryObjectException("Failed to read named field because reader is in raw mode."); + assert dataStart != start; if (footerLen == 0) @@ -2556,6 +2568,7 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Obje * @return {@code True} if field was found and stream was positioned accordingly. */ private boolean findFieldById(int id) { + assert !raw; // Assert, not exception, because this is called only from internals for Serializable types. assert dataStart != start; if (footerLen == 0)