Court sources said the firing incident occurred near gate 5 of the complex and the assailant, identified as Kishan, was caught at the spot by security personnel.
Rohan, who had come to the court to depose in an attempt to murder case, was the target but he escaped unhurt as the bullet missed him, the sources said.
The assailant is being interrogated by the police, sources said.