summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRajith Muditha Attapattu <rajith@apache.org>2012-06-07 17:35:20 +0000
committerRajith Muditha Attapattu <rajith@apache.org>2012-06-07 17:35:20 +0000
commit7613e7c400e33482eefe7ea430a92eee5d4ffebf (patch)
tree40075954ef02e1e198656c7f7f50ee6bc0e81aea
parentee0fa412153e309878ee8971b0872b97b4f13979 (diff)
downloadqpid-python-7613e7c400e33482eefe7ea430a92eee5d4ffebf.tar.gz
QPID-4027 Handles the empty and null map case.
git-svn-id: https://svn.apache.org/repos/asf/qpid/branches/address-refactor2@1347732 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--qpid/cpp/bindings/swig_java_helper.i9
-rw-r--r--qpid/cpp/bindings/swig_java_typemaps.i21
2 files changed, 27 insertions, 3 deletions
diff --git a/qpid/cpp/bindings/swig_java_helper.i b/qpid/cpp/bindings/swig_java_helper.i
index a5bd8d1b9d..a42f02b480 100644
--- a/qpid/cpp/bindings/swig_java_helper.i
+++ b/qpid/cpp/bindings/swig_java_helper.i
@@ -27,6 +27,7 @@
%pragma(java) moduleimports=%{
import java.util.Arrays;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
@@ -63,6 +64,9 @@ import java.util.Set;
static long getVariantMap(final Map<String,Object> m)
{
+ //optimizing for the null & empty map case.
+ if (m == null || m.size() == 0) { return 0; }
+
WriteOnlyVariantMapWrapper map = new WriteOnlyVariantMapWrapper();
for (String key: m.keySet())
{
@@ -73,6 +77,11 @@ import java.util.Set;
static Map<String, Object> getJavaMap(final ReadOnlyVariantMapWrapper map)
{
+ if (map == null)
+ {
+ return Collections.emptyMap();
+ }
+
return new Map<String, Object>()
{
@Override
diff --git a/qpid/cpp/bindings/swig_java_typemaps.i b/qpid/cpp/bindings/swig_java_typemaps.i
index 07b89cffa3..f6282c5aaa 100644
--- a/qpid/cpp/bindings/swig_java_typemaps.i
+++ b/qpid/cpp/bindings/swig_java_typemaps.i
@@ -90,8 +90,16 @@
/* -- qpid::types::Variant::Map& -- */
%typemap(in) (qpid::types::Variant::Map&){
- WriteOnlyVariantMapWrapper* mapper = *(WriteOnlyVariantMapWrapper **)&$input;
- $1 = new qpid::types::Variant::Map((mapper->getVariantMap()));
+
+ if ($input == 0) // empty or null map case.
+ {
+ $1 = new qpid::types::Variant::Map();
+ }
+ else
+ {
+ WriteOnlyVariantMapWrapper* mapper = *(WriteOnlyVariantMapWrapper **)&$input;
+ $1 = new qpid::types::Variant::Map((mapper->getVariantMap()));
+ }
}
%typemap(javain) (qpid::types::Variant::Map&) "$module.getVariantMap($javainput)"
@@ -101,7 +109,14 @@
}
%typemap(out) qpid::types::Variant::Map& {
- *(ReadOnlyVariantMapWrapper **)&jresult = new ReadOnlyVariantMapWrapper(jenv,*$1);
+ if ($1->size() == 0)
+ {
+ jresult = 0;
+ }
+ else
+ {
+ *(ReadOnlyVariantMapWrapper **)&jresult = new ReadOnlyVariantMapWrapper(jenv,*$1);
+ }
}
%typemap(javaout) qpid::types::Variant::Map& {