[asterisk-commits] main/sorcery: Don't fail object set creation from JSON if fi... (asterisk[master])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Jul 13 11:51:10 CDT 2015


Joshua Colp has submitted this change and it was merged.

Change subject: main/sorcery: Don't fail object set creation from JSON if field fails
......................................................................


main/sorcery: Don't fail object set creation from JSON if field fails

Some individual fields may fail their conversion due to their default
values being invalid for their custom handlers. In particular,
configuration values that depend on others being enabled (and thus have
an empty default value) are notorious for tripping this routine up. An
example of this are any of the DTLS options for endpoints. Any of the
DTLS options will fail to be applied (as DTLS is not enabled), causing
the entire object set to be aborted.

This patch makes it so that we log a debug message when skipping a
field, and rumble on anyway.

ASTERISK-25238

Change-Id: I0bea13de79f66bf9f9ae6ece0e94a2dc1c026a76
---
M main/sorcery.c
1 file changed, 5 insertions(+), 2 deletions(-)

Approvals:
  Kevin Harwell: Looks good to me, but someone else must approve
  Anonymous Coward #1000019: Verified
  Joshua Colp: Looks good to me, approved



diff --git a/main/sorcery.c b/main/sorcery.c
index 790e782..6d24b14 100644
--- a/main/sorcery.c
+++ b/main/sorcery.c
@@ -1600,10 +1600,13 @@
 			char *buf = NULL;
 			struct ast_json *value = NULL;
 
-			if ((res = object_field->handler(object, object_field->args, &buf))
+			if (object_field->handler(object, object_field->args, &buf)
 				|| !(value = ast_json_string_create(buf))
 				|| ast_json_object_set(json, object_field->name, value)) {
-				res = -1;
+				ast_free(buf);
+				ast_debug(5, "Skipping field '%s' for object type '%s'\n",
+					object_field->name, object_type->name);
+				continue;
 			}
 
 			ast_free(buf);

-- 
To view, visit https://gerrit.asterisk.org/878
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I0bea13de79f66bf9f9ae6ece0e94a2dc1c026a76
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Matt Jordan <mjordan at digium.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>



More information about the asterisk-commits mailing list