Source:
<code>private int createPermanentFunction(Hive db, CreateFunctionDesc createFunctionDesc) throws HiveException, IOException { String[] qualifiedNameParts = FunctionUtils.getQualifiedFunctionNameParts( createFunctionDesc.getFunctionName()); String dbName = qualifiedNameParts[0]; String funcName = qualifiedNameParts[1]; String registeredName = FunctionUtils.qualifyFunctionName(funcName, dbName); String className = createFunctionDesc.getClassName(); List<ResourceUri> resources = createFunctionDesc.getResources(); checkLocalFunctionResources(db, createFunctionDesc.getResources()); FunctionInfo registered = null; HiveConf oldConf = SessionState.get().getConf(); try { SessionState.get().setConf(conf); registered = FunctionRegistry.registerPermanentFunction( registeredName, className, true, toFunctionResource(resources)); } catch (RuntimeException ex) { Throwable t = ex; while (t.getCause() != null) { t = t.getCause(); } } finally { SessionState.get().setConf(oldConf); } if (registered == null) { console.printError("Failed to register " + registeredName + " using class " + createFunctionDesc.getClassName()); return 1; } Function func = new Function( funcName, dbName, className, SessionState.get().getUserName(), PrincipalType.USER, (int) (System.currentTimeMillis() / 1000), org.apache.hadoop.hive.metastore.api.FunctionType.JAVA, resources ); try { db.createFunction(func); <START> } catch (HiveException he) { <END> FunctionRegistry.unregisterPermanentFunction(registeredName); throw he; } return 0; }</code><technical_language>exceptions, including run time exception</technical_language>

Target:
private int createPermanentFunction(Hive db, CreateFunctionDesc createFunctionDesc) throws HiveException, IOException { String[] qualifiedNameParts = FunctionUtils.getQualifiedFunctionNameParts( createFunctionDesc.getFunctionName()); String dbName = qualifiedNameParts[0]; String funcName = qualifiedNameParts[1]; String registeredName = FunctionUtils.qualifyFunctionName(funcName, dbName); String className = createFunctionDesc.getClassName(); List<ResourceUri> resources = createFunctionDesc.getResources(); checkLocalFunctionResources(db, createFunctionDesc.getResources()); FunctionInfo registered = null; HiveConf oldConf = SessionState.get().getConf(); try { SessionState.get().setConf(conf); registered = FunctionRegistry.registerPermanentFunction( registeredName, className, true, toFunctionResource(resources)); } catch (RuntimeException ex) { Throwable t = ex; while (t.getCause() != null) { t = t.getCause(); } } finally { SessionState.get().setConf(oldConf); } if (registered == null) { console.printError("Failed to register " + registeredName + " using class " + createFunctionDesc.getClassName()); return 1; } Function func = new Function( funcName, dbName, className, SessionState.get().getUserName(), PrincipalType.USER, (int) (System.currentTimeMillis() / 1000), org.apache.hadoop.hive.metastore.api.FunctionType.JAVA, resources ); try { db.createFunction(func); } catch (Exception e) { FunctionRegistry.unregisterPermanentFunction(registeredName); setException(e); LOG.error("Failed to add function " + createFunctionDesc.getFunctionName() + " to the metastore.", e); return 1; } return 0; }