ramitg254 commented on code in PR #5776: URL: https://github.com/apache/hive/pull/5776#discussion_r2051962233
########## shims/0.23/src/main/java/org/apache/hadoop/mapred/WebHCatJTShim23.java: ########## @@ -51,19 +48,36 @@ public class WebHCatJTShim23 implements WebHCatJTShim { /** * Create a connection to the Job Tracker. */ - public WebHCatJTShim23(final Configuration conf, final UserGroupInformation ugi) - throws IOException { - try { - this.conf = conf; - jc = ugi.doAs(new PrivilegedExceptionAction<JobClient>() { - public JobClient run() throws IOException, InterruptedException { - //create this in doAs() so that it gets a security context based passed in 'ugi' - return new JobClient(conf); - } - }); + public static WebHCatJTShim createInstance(final Configuration conf, final UserGroupInformation ugi) + throws IOException { + int[] flag = new int[1]; + ArrayList<String> eMessage = new ArrayList<>(); + WebHCatJTShim webHCatJTShim = new WebHCatJTShim23(conf, ugi, flag, eMessage); + if (flag[0] == -1) { + throw new IOException("Failed to create job Client" + eMessage.get(0)); + } else if (flag[0] == -2) { + throw new RuntimeException("Failed to create job Client" + eMessage.get(0)); } - catch(InterruptedException ex) { - throw new RuntimeException("Failed to create JobClient", ex); + return webHCatJTShim; + } + + private WebHCatJTShim23(final Configuration conf, final UserGroupInformation ugi, int[] flag, + ArrayList<String> eMessage) { + this.conf = new Configuration(conf); + try { + this.jc = ugi.doAs(new PrivilegedExceptionAction<JobClient>() { + public JobClient run() throws IOException, InterruptedException { + //create this in doAs() so that it gets a security context based passed in 'ugi' + return new JobClient(conf); + } + }); + } catch (InterruptedException ex) { + eMessage.add(ex.getMessage()); + flag[0] = -2; + this.jc = null; + } catch (IOException ex) { + flag[0] = -1; + this.jc = null; } Review Comment: Thanks this one is good approach i added this one instead of the hack i was using 😅 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org For additional commands, e-mail: gitbox-h...@hive.apache.org