You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ak...@apache.org on 2015/11/23 09:46:32 UTC
[29/30] 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-1753-1282
Commit: 96ae696f1cb7aad3fce47c3dd7e43699b0d78fff
Parents: 5dce6d9
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Mon Nov 23 11:45:41 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
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)