You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-commits@axis.apache.org by ro...@apache.org on 2026/01/15 00:51:02 UTC
(axis-axis2-c-core) branch master updated (a08a6396b -> 639dd76e9)
This is an automated email from the ASF dual-hosted git repository.
robertlazarski pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/axis-axis2-c-core.git
from a08a6396b Fix JSON-direct service loading to properly extract ServiceClass from dll_desc
new 79e7ab723 AXIS2C-1590: Release attribute references after adding to elements
new 0ee78a23a Update HTTP/2 build docs to use correct --enable-http2 flag
new 639dd76e9 Enhance JSON writer/reader with AXIOM node support for HTTP/2 mode
The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
axiom/src/soap/soap_fault_text.c | 3 +
axiom/src/soap/soap_header_block.c | 6 +-
axiom/test/om/test_om.cc | 15 ++
axiom/test/soap/test_soap.cc | 7 +
docs/HTTP2_CONDITIONAL_COMPILATION.md | 42 +++---
docs/userguide/json-httpd-h2-userguide.md | 21 ++-
neethi/src/reference.c | 2 +
src/core/transport/h2/test/Makefile.am | 8 ++
src/core/transport/http/sender/axis2_json_writer.c | 160 +++++++++++++++++----
src/core/transport/http/util/axis2_json_reader.c | 3 +-
src/modules/mod_addr/addr_out_handler.c | 4 +
11 files changed, 208 insertions(+), 63 deletions(-)
(axis-axis2-c-core) 01/03: AXIS2C-1590: Release attribute references after adding to elements
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
robertlazarski pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/axis-axis2-c-core.git
commit 79e7ab723466815f7e1d049de62c5393e1ad3d04
Author: Robert Lazarski <ro...@gmail.com>
AuthorDate: Wed Jan 14 14:43:14 2026 -1000
AXIS2C-1590: Release attribute references after adding to elements
Follow-up to AXIS2C-1590 reference counting fix. Callers that add
attributes to elements must now release their reference since
axiom_element_add_attribute increments the ref count.
Files updated:
- soap_fault_text.c: Release lang_attribute after adding
- soap_header_block.c: Release om_attr after adding
- neethi/reference.c: Release att_uri after adding
- mod_addr/addr_out_handler.c: Release attributes after adding
- test_om.cc, test_soap.cc: Updated tests for new behavior
Co-Authored-By: Claude Opus 4.5 <no...@anthropic.com>
---
axiom/src/soap/soap_fault_text.c | 3 +++
axiom/src/soap/soap_header_block.c | 6 +++++-
axiom/test/om/test_om.cc | 15 +++++++++++++++
axiom/test/soap/test_soap.cc | 7 +++++++
neethi/src/reference.c | 2 ++
src/modules/mod_addr/addr_out_handler.c | 4 ++++
6 files changed, 36 insertions(+), 1 deletion(-)
diff --git a/axiom/src/soap/soap_fault_text.c b/axiom/src/soap/soap_fault_text.c
index b074af302..5a0bb050d 100644
--- a/axiom/src/soap/soap_fault_text.c
+++ b/axiom/src/soap/soap_fault_text.c
@@ -197,6 +197,9 @@ axiom_soap_fault_text_set_lang(
if(status == AXIS2_SUCCESS)
{
fault_text->lang_ns_used = AXIS2_TRUE;
+ /* AXIS2C-1590: Release our reference after adding - element now owns a reference.
+ * The pointer remains valid for get_lang() because the element keeps it alive. */
+ axiom_attribute_free(fault_text->lang_attribute, env);
}
else
{
diff --git a/axiom/src/soap/soap_header_block.c b/axiom/src/soap/soap_header_block.c
index 6f80f3a45..63ad540bd 100644
--- a/axiom/src/soap/soap_header_block.c
+++ b/axiom/src/soap/soap_header_block.c
@@ -283,6 +283,7 @@ axiom_soap_header_block_set_attribute(
axutil_qname_t *qn = NULL;
axiom_namespace_t *om_ns = NULL;
axiom_element_t *om_ele = NULL;
+ axis2_status_t status = AXIS2_FAILURE;
AXIS2_PARAM_CHECK(env->error, attr_name, AXIS2_FAILURE);
@@ -344,7 +345,10 @@ axiom_soap_header_block_set_attribute(
return AXIS2_FAILURE;
}
- return axiom_element_add_attribute(om_ele, env, om_attr, header_block->om_ele_node);
+ status = axiom_element_add_attribute(om_ele, env, om_attr, header_block->om_ele_node);
+ /* AXIS2C-1590: Release our reference after adding - element now owns a reference */
+ axiom_attribute_free(om_attr, env);
+ return status;
}
AXIS2_EXTERN axis2_char_t *AXIS2_CALL
diff --git a/axiom/test/om/test_om.cc b/axiom/test/om/test_om.cc
index dfadd0d38..1dc148cdd 100644
--- a/axiom/test/om/test_om.cc
+++ b/axiom/test/om/test_om.cc
@@ -67,7 +67,14 @@ class TestOM: public ::testing::Test
TEST_F(TestOM, test_om_build) {
+ /* Try both paths: from source dir (automake) and from .libs (direct run) */
char *filename = "../resources/xml/om/test.xml";
+ FILE *test_file = fopen(filename, "r");
+ if (!test_file) {
+ filename = "../../resources/xml/om/test.xml";
+ } else {
+ fclose(test_file);
+ }
FILE *f = NULL;
axiom_element_t *ele1 = NULL;
@@ -286,6 +293,8 @@ TEST_F(TestOM, test_om_serialize) {
attr1 = axiom_attribute_create(m_env, "title22", NULL, NULL);
axiom_element_add_attribute(ele2, m_env, attr1, node2);
+ /* AXIS2C-1590: Release our reference after adding - element now owns a reference */
+ axiom_attribute_free(attr1, m_env);
text1 = axiom_text_create(m_env, node2, "Axis2/C OM HOWTO", &node3);
@@ -298,10 +307,14 @@ TEST_F(TestOM, test_om_serialize) {
attr1 = axiom_attribute_create(m_env, "title", "Mr", ns1);
axiom_element_add_attribute(ele4, m_env, attr1, node6);
+ /* AXIS2C-1590: Release our reference after adding - element now owns a reference */
+ axiom_attribute_free(attr1, m_env);
attr2 = axiom_attribute_create(m_env, "name", "Axitoc Oman", ns1);
axiom_element_add_attribute(ele4, m_env, attr2, node6);
+ /* AXIS2C-1590: Release our reference after adding - element now owns a reference */
+ axiom_attribute_free(attr2, m_env);
data_source = axiom_data_source_create(m_env, node1, &node6);
stream = axiom_data_source_get_stream(data_source, m_env);
@@ -386,6 +399,8 @@ TEST_F(TestOM, test_attr_special_chars)
axiom_element_set_text(element, m_env, "T1 & T2", node);
attr = axiom_attribute_create(m_env, "name", "A1 & A2", NULL);
axiom_element_add_attribute(element, m_env, attr, node);
+ /* AXIS2C-1590: Release our reference after adding - element now owns a reference */
+ axiom_attribute_free(attr, m_env);
axis2_char_t * xml = axiom_node_to_string(node, m_env);
diff --git a/axiom/test/soap/test_soap.cc b/axiom/test/soap/test_soap.cc
index e473f6f54..73ce550e4 100644
--- a/axiom/test/soap/test_soap.cc
+++ b/axiom/test/soap/test_soap.cc
@@ -147,7 +147,14 @@ class TestSOAP: public ::testing::Test
TEST_F(TestSOAP, test_build_soap) {
const axis2_char_t *uri = AXIOM_SOAP12_SOAP_ENVELOPE_NAMESPACE_URI;
+ /* Try both paths: from source dir (automake) and from .libs (direct run) */
const char *filename = "../resources/xml/soap/test.xml";
+ FILE *test_file = fopen(filename, "r");
+ if (!test_file) {
+ filename = "../../resources/xml/soap/test.xml";
+ } else {
+ fclose(test_file);
+ }
axiom_stax_builder_t *om_builder = NULL;
diff --git a/neethi/src/reference.c b/neethi/src/reference.c
index 8b52a2637..583a99ba4 100644
--- a/neethi/src/reference.c
+++ b/neethi/src/reference.c
@@ -99,6 +99,8 @@ neethi_reference_serialize(
att_uri = axiom_attribute_create(env, NEETHI_URI, neethi_reference->uri, NULL);
axiom_element_add_attribute(ref_ele, env, att_uri, ref_node);
+ /* AXIS2C-1590: Release our reference after adding - element now owns a reference */
+ axiom_attribute_free(att_uri, env);
return AXIS2_SUCCESS;
}
diff --git a/src/modules/mod_addr/addr_out_handler.c b/src/modules/mod_addr/addr_out_handler.c
index 4098d3aa4..9ed521209 100644
--- a/src/modules/mod_addr/addr_out_handler.c
+++ b/src/modules/mod_addr/addr_out_handler.c
@@ -333,6 +333,8 @@ axis2_addr_out_handler_invoke(
addr_ns_obj);
axiom_element_add_attribute(reference_ele, env,
reference_attr, reference_node);
+ /* AXIS2C-1590: Release our reference after adding */
+ axiom_attribute_free(reference_attr, env);
axiom_element_set_text(reference_ele, env,
axiom_element_get_text(temp_ele, env, temp_node),
reference_node);
@@ -535,6 +537,8 @@ axis2_addr_out_handler_invoke(
axiom_attribute_set_namespace(om_attr, env, dec_ns);
}
}
+ /* AXIS2C-1590: Release our reference after adding - element now owns a reference */
+ axiom_attribute_free(om_attr, env);
}
}
(axis-axis2-c-core) 02/03: Update HTTP/2 build docs to use correct --enable-http2 flag
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
robertlazarski pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/axis-axis2-c-core.git
commit 0ee78a23a8acc6f041476ef10bc0949f9f336199
Author: Robert Lazarski <ro...@gmail.com>
AuthorDate: Wed Jan 14 14:43:22 2026 -1000
Update HTTP/2 build docs to use correct --enable-http2 flag
The configure flag for HTTP/2 support is --enable-http2, not --with-nghttp2.
Updated documentation to reflect the correct configure options:
- Added --enable-http2 flag
- Removed unnecessary --enable-ssl and --enable-libcurl
- Fixed --with-apache2 path to include /include suffix
- Added --enable-libxml2=no for HTTP/2 JSON-only mode
Co-Authored-By: Claude Opus 4.5 <no...@anthropic.com>
---
docs/HTTP2_CONDITIONAL_COMPILATION.md | 42 +++++++++++++++----------------
docs/userguide/json-httpd-h2-userguide.md | 21 ++++++++--------
2 files changed, 30 insertions(+), 33 deletions(-)
diff --git a/docs/HTTP2_CONDITIONAL_COMPILATION.md b/docs/HTTP2_CONDITIONAL_COMPILATION.md
index 914874f20..97f091699 100644
--- a/docs/HTTP2_CONDITIONAL_COMPILATION.md
+++ b/docs/HTTP2_CONDITIONAL_COMPILATION.md
@@ -580,34 +580,32 @@ autoreconf -fiv
# 2. Configure with proper flags
./configure --prefix=/usr/local/axis2c \
- --enable-json \
- --enable-tests \
- --enable-ssl \
- --enable-libcurl \
- --with-apache2=/usr/local/apache2 \
- --with-apr=/usr/include/apr-1.0 \
- --with-gtest=/usr/src/googletest/googletest \
- PKG_CONFIG_PATH=/usr/lib/pkgconfig:/usr/lib/x86_64-linux-gnu/pkgconfig \
- CFLAGS="$CFLAGS -DAXIS2_JSON_ENABLED -DWITH_NGHTTP2 -O2" \
- CPPFLAGS="$CPPFLAGS -DAXIS2_JSON_ENABLED -DWITH_NGHTTP2" \
- LDFLAGS="$LDFLAGS -L/usr/lib/x86_64-linux-gnu"
+ --enable-json \
+ --enable-http2 \
+ --enable-tests \
+ --with-apache2=/usr/local/apache2/include \
+ --with-apr=/usr/include/apr-1.0 \
+ --enable-libxml2=no \
+ PKG_CONFIG_PATH=/usr/lib/pkgconfig:/usr/lib/x86_64-linux-gnu/pkgconfig \
+ CFLAGS="-DAXIS2_JSON_ENABLED -DWITH_NGHTTP2 -O2" \
+ CPPFLAGS="-DAXIS2_JSON_ENABLED -DWITH_NGHTTP2" \
+ LDFLAGS="-L/usr/lib/x86_64-linux-gnu"
# 3. Clean with enhanced targets (removes .libs/ directories)
make distclean
# 4. Reconfigure (distclean removes Makefiles)
./configure --prefix=/usr/local/axis2c \
- --enable-json \
- --enable-tests \
- --enable-ssl \
- --enable-libcurl \
- --with-apache2=/usr/local/apache2 \
- --with-apr=/usr/include/apr-1.0 \
- --with-gtest=/usr/src/googletest/googletest \
- PKG_CONFIG_PATH=/usr/lib/pkgconfig:/usr/lib/x86_64-linux-gnu/pkgconfig \
- CFLAGS="$CFLAGS -DAXIS2_JSON_ENABLED -DWITH_NGHTTP2 -O2" \
- CPPFLAGS="$CPPFLAGS -DAXIS2_JSON_ENABLED -DWITH_NGHTTP2" \
- LDFLAGS="$LDFLAGS -L/usr/lib/x86_64-linux-gnu"
+ --enable-json \
+ --enable-http2 \
+ --enable-tests \
+ --with-apache2=/usr/local/apache2/include \
+ --with-apr=/usr/include/apr-1.0 \
+ --enable-libxml2=no \
+ PKG_CONFIG_PATH=/usr/lib/pkgconfig:/usr/lib/x86_64-linux-gnu/pkgconfig \
+ CFLAGS="-DAXIS2_JSON_ENABLED -DWITH_NGHTTP2 -O2" \
+ CPPFLAGS="-DAXIS2_JSON_ENABLED -DWITH_NGHTTP2" \
+ LDFLAGS="-L/usr/lib/x86_64-linux-gnu"
# 5. Build and install with automatic verification
sudo make clean
diff --git a/docs/userguide/json-httpd-h2-userguide.md b/docs/userguide/json-httpd-h2-userguide.md
index e554b309e..874a53574 100644
--- a/docs/userguide/json-httpd-h2-userguide.md
+++ b/docs/userguide/json-httpd-h2-userguide.md
@@ -988,17 +988,16 @@ sudo make install
# Run the EXACT configure command for your distro as explained below.
# This is specifically for Ubuntu 25.10 with apache2-custom
# --enable-tests is optional, skipped here
- ./configure \
- --prefix=/usr/local/axis2c \
- --enable-json \
- --enable-ssl \
- --enable-libcurl \
- --with-apache2=/usr/local/apache2 \
- --with-apr=/usr/include/apr-1.0 \
- PKG_CONFIG_PATH=/usr/lib/pkgconfig:/usr/lib/x86_64-linux-gnu/pkgconfig \
- CFLAGS="$CFLAGS -DAXIS2_JSON_ENABLED -DWITH_NGHTTP2 -O2" \
- CPPFLAGS="$CPPFLAGS -DAXIS2_JSON_ENABLED -DWITH_NGHTTP2" \
- LDFLAGS="$LDFLAGS -L/usr/lib/x86_64-linux-gnu"
+ ./configure --prefix=/usr/local/axis2c \
+ --enable-json \
+ --enable-http2 \
+ --with-apache2=/usr/local/apache2/include \
+ --with-apr=/usr/include/apr-1.0 \
+ --enable-libxml2=no \
+ PKG_CONFIG_PATH=/usr/lib/pkgconfig:/usr/lib/x86_64-linux-gnu/pkgconfig \
+ CFLAGS="-DAXIS2_JSON_ENABLED -DWITH_NGHTTP2 -O2" \
+ CPPFLAGS="-DAXIS2_JSON_ENABLED -DWITH_NGHTTP2" \
+ LDFLAGS="-L/usr/lib/x86_64-linux-gnu"
# Add Axis2/C to library path (standard Unix paths) , could be in /etc/environment or root .bashrc
export AXIS2C_HOME=/usr/local/axis2c
(axis-axis2-c-core) 03/03: Enhance JSON writer/reader with AXIOM node support for HTTP/2 mode
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
robertlazarski pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/axis-axis2-c-core.git
commit 639dd76e9bd8730e558ae8ebb24c55c729f0e1a1
Author: Robert Lazarski <ro...@gmail.com>
AuthorDate: Wed Jan 14 14:43:34 2026 -1000
Enhance JSON writer/reader with AXIOM node support for HTTP/2 mode
Add full AXIOM node to JSON conversion support in json_writer:
- axis2_json_element_is_nil(): Check xsi:nil attribute
- axis2_json_write_node(): Convert AXIOM nodes to JSON objects
- Handle arrays, nested elements, and text content
Minor fixes to json_reader and h2 test Makefile.
Co-Authored-By: Claude Opus 4.5 <no...@anthropic.com>
---
src/core/transport/h2/test/Makefile.am | 8 ++
src/core/transport/http/sender/axis2_json_writer.c | 160 +++++++++++++++++----
src/core/transport/http/util/axis2_json_reader.c | 3 +-
3 files changed, 142 insertions(+), 29 deletions(-)
diff --git a/src/core/transport/h2/test/Makefile.am b/src/core/transport/h2/test/Makefile.am
index 391e2d29c..4b6d683db 100644
--- a/src/core/transport/h2/test/Makefile.am
+++ b/src/core/transport/h2/test/Makefile.am
@@ -30,6 +30,10 @@ h2_json_integration_test_SOURCES = h2_json_integration_test.c \
h2_json_integration_test_LDADD = \
$(LDFLAGS) \
$(top_builddir)/util/src/libaxutil.la \
+ $(top_builddir)/axiom/src/om/libaxis2_axiom.la \
+ $(top_builddir)/axiom/src/parser/@WRAPPER_DIR@/libaxis2_parser.la \
+ $(top_builddir)/src/core/engine/libaxis2_engine.la \
+ $(top_builddir)/src/core/transport/http/common/libaxis2_http_common.la \
$(top_builddir)/src/core/transport/http/util/libaxis2_http_util.la \
$(JSON_LIBS)
@@ -48,6 +52,10 @@ h2_performance_benchmark_test_SOURCES = h2_performance_benchmark_test.c \
h2_performance_benchmark_test_LDADD = \
$(LDFLAGS) \
$(top_builddir)/util/src/libaxutil.la \
+ $(top_builddir)/axiom/src/om/libaxis2_axiom.la \
+ $(top_builddir)/axiom/src/parser/@WRAPPER_DIR@/libaxis2_parser.la \
+ $(top_builddir)/src/core/engine/libaxis2_engine.la \
+ $(top_builddir)/src/core/transport/http/common/libaxis2_http_common.la \
$(top_builddir)/src/core/transport/http/util/libaxis2_http_util.la \
$(JSON_LIBS) \
-lm
diff --git a/src/core/transport/http/sender/axis2_json_writer.c b/src/core/transport/http/sender/axis2_json_writer.c
index 84d2e5535..41afcc624 100644
--- a/src/core/transport/http/sender/axis2_json_writer.c
+++ b/src/core/transport/http/sender/axis2_json_writer.c
@@ -12,70 +12,174 @@
* limitations under the License.
*/
-/* Revolutionary HTTP/2 JSON Architecture - AXIOM-free stub implementation */
+#include <axiom_node.h>
+#include <axiom_element.h>
+#include <axiom_attribute.h>
#include <json-c/json.h>
-#include <string.h>
#include "axis2_json_writer.h"
+#define AXIS2_JSON_XSI_URI "http://www.w3.org/2001/XMLSchema-instance"
+
struct axis2_json_writer
{
json_object* json_obj;
};
-/* Revolutionary AXIOM-free stub implementation */
+axis2_bool_t axis2_json_element_is_nil(axiom_element_t* om_element, const axutil_env_t* env)
+{
+ axiom_attribute_t* attr = NULL;
+ axutil_hash_index_t* index;
+ axutil_hash_t* attr_hash = axiom_element_get_all_attributes(om_element, env);
+ axis2_bool_t result = AXIS2_FALSE;
+
+ if (!attr_hash)
+ return AXIS2_FALSE;
+
+ for (index = axutil_hash_first(attr_hash, env);
+ index; index = axutil_hash_next(env, index))
+ {
+ axutil_hash_this(index, NULL, NULL, (void**)&attr);
+ if (attr && !strcmp(axiom_attribute_get_localname(attr, env), "nil"))
+ {
+ /* found some "nil" attribute, check it namespace */
+ axutil_qname_t* qname =
+ axiom_attribute_get_qname(attr, env);
+ if (qname && !strcmp(axutil_qname_get_uri(qname, env), AXIS2_JSON_XSI_URI))
+ {
+ axis2_char_t* attr_value =
+ axiom_attribute_get_value(attr, env);
+ result = (!strcmp(attr_value, "true") || !strcmp(attr_value, "1")) ?
+ AXIS2_TRUE : AXIS2_FALSE;
+ /* Found what we're looking for - use axutil_hash_index_free to cleanup */
+ axutil_hash_index_free(index, env);
+ return result;
+ }
+ }
+ }
+
+ return result;
+}
+
+void axis2_json_write_node(json_object* parent, axiom_node_t* om_node, const axutil_env_t* env)
+{
+ axiom_element_t* elem;
+ axiom_node_t* child_node;
+ const axis2_char_t* local_name;
+ json_object* obj;
+ json_object* array = NULL;
+
+ if (!om_node || axiom_node_get_node_type(om_node, env) != AXIOM_ELEMENT)
+ return;
+
+ elem = (axiom_element_t*)axiom_node_get_data_element(om_node, env);
+ local_name = axiom_element_get_localname(elem, env);
+
+ child_node = axiom_node_get_first_element(om_node, env);
+
+ /* find existing object */
+ if (json_object_object_get_ex(parent, local_name, &obj))
+ {
+ /* check that object is array? */
+ if (!json_object_is_type(obj, json_type_array))
+ {
+ /* convert to array */
+ obj = json_object_get(obj);
+ array = json_object_new_array();
+ json_object_array_add(array, obj);
+ json_object_object_del(parent, local_name);
+ json_object_object_add(parent, local_name, array);
+ }
+ else
+ array = obj;
+ }
+
+ if (!child_node)
+ {
+ /* this is a leaf node */
+ json_object* json_value = NULL;
+
+ /* check for nillable */
+ if (!axis2_json_element_is_nil(elem, env))
+ {
+ const axis2_char_t* value =
+ axiom_element_get_text(elem, env, om_node);
+ json_value = json_object_new_string(value ? value : "");
+ }
+
+ if (array)
+ json_object_array_add(array, json_value);
+ else
+ json_object_object_add(parent, local_name, json_value);
+ return;
+ }
+
+ /* iterate through children elements */
+ obj = json_object_new_object();
+ if (array)
+ json_object_array_add(array, obj);
+ else
+ json_object_object_add(parent, local_name, obj);
+
+ for (; child_node; child_node = axiom_node_get_next_sibling(child_node, env))
+ if (axiom_node_get_node_type(child_node, env) == AXIOM_ELEMENT)
+ axis2_json_write_node(obj, child_node, env);
+}
+
+
AXIS2_EXTERN axis2_json_writer_t* AXIS2_CALL
-axis2_json_writer_create(const axutil_env_t* env)
+axis2_json_writer_create(
+ const axutil_env_t* env)
{
- /* Revolutionary: Stub implementation - actual JSON processing handled by JsonRpcMessageReceiver */
axis2_json_writer_t* writer = (axis2_json_writer_t*)AXIS2_MALLOC(env->allocator,
sizeof(struct axis2_json_writer));
- if (writer) {
- writer->json_obj = json_object_new_object();
- }
+ if (writer)
+ writer->json_obj = NULL;
+
return writer;
}
+
AXIS2_EXTERN void AXIS2_CALL
axis2_json_writer_free(
axis2_json_writer_t* writer,
const axutil_env_t* env)
{
- /* Revolutionary: Minimal cleanup */
- if (writer) {
- if (writer->json_obj) {
+ if (writer)
+ {
+ if (writer->json_obj)
json_object_put(writer->json_obj);
- }
AXIS2_FREE(env->allocator, writer);
}
}
+
AXIS2_EXTERN void AXIS2_CALL
axis2_json_writer_write(
axis2_json_writer_t* writer,
const axiom_node_t* node,
const axutil_env_t* env)
{
- /* Revolutionary: Stub - actual JSON processing done by JsonRpcMessageReceiver */
- /* Compatibility shim for existing tests */
- return;
+ /* free existing object */
+ if (writer->json_obj)
+ json_object_put(writer->json_obj);
+
+ writer->json_obj = json_object_new_object();
+ axis2_json_write_node(writer->json_obj, (axiom_node_t*)node, env);
}
+
AXIS2_EXTERN const axis2_char_t* AXIS2_CALL
axis2_json_writer_get_json_string(
axis2_json_writer_t* writer,
const axutil_env_t* env,
int* json_string_length)
{
- /* Revolutionary: Return empty JSON object */
- if (writer && writer->json_obj) {
- const char* json_str = json_object_to_json_string(writer->json_obj);
- if (json_string_length) {
- *json_string_length = (int)strlen(json_str);
- }
- return json_str;
- }
- if (json_string_length) {
- *json_string_length = 2;
- }
- return "{}";
-}
\ No newline at end of file
+ (void)env;
+ const axis2_char_t* result =
+ (const axis2_char_t*)json_object_to_json_string_ext(writer->json_obj,
+ JSON_C_TO_STRING_PLAIN);
+ if (json_string_length)
+ *json_string_length = strlen(result);
+
+ return result;
+}
diff --git a/src/core/transport/http/util/axis2_json_reader.c b/src/core/transport/http/util/axis2_json_reader.c
index e9194bb0e..9c46c13d5 100644
--- a/src/core/transport/http/util/axis2_json_reader.c
+++ b/src/core/transport/http/util/axis2_json_reader.c
@@ -165,7 +165,6 @@ axis2_json_read_child_node(
attr = axiom_attribute_create(env, "nil", "true", ns);
if (!attr)
{
- axiom_attribute_free(attr, env);
return AXIS2_FAILURE;
}
@@ -175,6 +174,8 @@ axis2_json_read_child_node(
axiom_attribute_free(attr, env);
return AXIS2_FAILURE;
}
+ /* AXIS2C-1590: Release our reference after adding - element now owns a reference */
+ axiom_attribute_free(attr, env);
/* Free the namespace after successful use */
axiom_namespace_free(ns, env);