It's impossible to get user data by their username. Example 2 in this Wiki doesn't work: http://docs.joomla.org/JFactory/getUser.
You can't compare integer to string like in getUser method:
elseif ($instance->id != $id)
{
$instance = JUser::getInstance($id);
}
Method doesn't return user data.
This repository is for the Joomla! Issue Tracker application. Your issue pertains to the Joomla! CMS, please report your issue at https://github.com/joomla/joomla-cms/issues/new