Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-141 236f40f6d -> cc32cced9


# Minor changes to read/writeStringMap() methods.


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/684a8aed
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/684a8aed
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/684a8aed

Branch: refs/heads/ignite-141
Commit: 684a8aedbc7e728d7b4a0eebbddc43acbe6d3d71
Parents: 551b3d1
Author: vozerov-gridgain <voze...@gridgain.com>
Authored: Fri Mar 6 10:03:33 2015 +0300
Committer: vozerov-gridgain <voze...@gridgain.com>
Committed: Fri Mar 6 10:03:33 2015 +0300

----------------------------------------------------------------------
 .../ignite/internal/util/IgniteUtils.java       | 34 ++++++++++++++++++--
 1 file changed, 31 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/684a8aed/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java 
b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
index 6b12554..79b2171 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
@@ -4544,8 +4544,8 @@ public abstract class IgniteUtils {
             out.writeInt(map.size());
 
             for (Map.Entry<String, String> e : map.entrySet()) {
-                out.writeUTF(e.getKey());
-                out.writeUTF(e.getValue());
+                writeUTFStringNullable(out, e.getKey());
+                writeUTFStringNullable(out, e.getValue());
             }
         }
         else
@@ -4568,13 +4568,41 @@ public abstract class IgniteUtils {
             Map<String, String> map = U.newHashMap(size);
 
             for (int i = 0; i < size; i++)
-                map.put(in.readUTF(), in.readUTF());
+                map.put(readUTFStringNullable(in), readUTFStringNullable(in));
 
             return map;
         }
     }
 
     /**
+     * Write UTF string which can be {@code null}.
+     *
+     * @param out Output stream.
+     * @param val Value.
+     * @throws IOException If failed.
+     */
+    public static void writeUTFStringNullable(DataOutput out, @Nullable String 
val) throws IOException {
+        if (val != null) {
+            out.writeBoolean(true);
+
+            out.writeUTF(val);
+        }
+        else
+            out.writeBoolean(false);
+    }
+
+    /**
+     * Read UTF string which can be {@code null}.
+     *
+     * @param in Input stream.
+     * @return Value.
+     * @throws IOException If failed.
+     */
+    public static String readUTFStringNullable(DataInput in) throws 
IOException {
+        return in.readBoolean() ? in.readUTF() : null;
+    }
+
+    /**
      *
      * @param in Input.
      * @return Read map.

Reply via email to