Doesn't clone() set the id as well?

Hi all,

In case where we use get(req) and put(rsp) instead of get_next_item(req) and item_done() - the cookbook says that its a good practice to clone the req item to rsp item and then call rsp.set_id_info(req).

  1. When we do a clone isn’t the id info copied as well?
  2. If its not then why?
  3. If yes then do we need to do the set_id_info separately?

Following is the code from the cookbook for reference:

$cast(rsp_item, req_item.clone()); // Create a response transaction by cloning req_item
    rsp_item.set_id_info(req_item); // Set the rsp_item sequence id to match req_item

Thanks in advance.

In reply to yasaswi93:

No. clone(), which calls copy() only copies the user-level information, not the ids in the base class.