Hi Jaideep, when I tried debugging hiveserver2 due to
HIVE-6672, it appeared that there was a thread running for each connection (session). Non-SQL commands (such as ADD JAR), were being run within this session thread and so the classloader for the session thread had the JARs loaded. When a SQL command was executed the session thread would start a new thread, and it appeared that this new thread was using the same classloader (and had the added JARs in the classloader's list of URLs). Were you seeing different behavior in your testing (I was running this on Mac, I think with jdk 1.6, not sure if it would have been different)?
In the patch, the thread's classloader is getting set to the HiveConf's classloader .. where is the HiveConf's classloader getting set from? Do we need to worry about having to make sure this classloader is updated whenever a JAR is added to the classpath?