Merge "Revert^2 "Fix the potential memory leak issue caused by setExtension."" into main