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