Source:
public boolean submitTopology() { String statemgrClass = Context.stateManagerClass(config); IStateManager statemgr; String launcherClass = Context.launcherClass(config); ILauncher launcher; String uploaderClass = Context.uploaderClass(config); IUploader uploader; try { statemgr = ReflectionUtils.newInstance(statemgrClass); launcher = ReflectionUtils.newInstance(launcherClass); uploader = ReflectionUtils.newInstance(uploaderClass); } catch (IllegalAccessException | InstantiationException | ClassNotFoundException e) { LOG.log(Level.SEVERE, "Failed to instantiate instances", e); return false; } boolean isSuccessful = false; URI packageURI = null; try { statemgr.initialize(config); SchedulerStateManagerAdaptor adaptor = new SchedulerStateManagerAdaptor(statemgr, 5000); validateSubmit(adaptor, topology.getName()); LOG.log(Level.FINE, "Topology {0} to be submitted", topology.getName()); packageURI = uploadPackage(uploader); if (packageURI == null) { LOG.severe("Failed to upload package."); return false; } else { Config runtime = Config.newBuilder() .putAll(LauncherUtils.getInstance().getPrimaryRuntime(topology, adaptor)) .put(Keys.topologyPackageUri(), packageURI) .put(Keys.launcherClassInstance(), launcher) .build(); isSuccessful = callLauncherRunner(runtime); } } catch (TopologySubmissionException ex) { isSuccessful = false; System.out.println(ex.getMessage()); } finally { if (!isSuccessful) { if (packageURI != null) { uploader.undo(); } } SysUtils.closeIgnoringExceptions(uploader); SysUtils.closeIgnoringExceptions(launcher); SysUtils.closeIgnoringExceptions(statemgr); } return isSuccessful; }

Target:
public void submitTopology() throws TopologySubmissionException { String statemgrClass = Context.stateManagerClass(config); IStateManager statemgr; String launcherClass = Context.launcherClass(config); ILauncher launcher; String uploaderClass = Context.uploaderClass(config); IUploader uploader; try { statemgr = ReflectionUtils.newInstance(statemgrClass); } catch (IllegalAccessException | InstantiationException | ClassNotFoundException e) { throw new TopologySubmissionException( String.format("Failed to instantiate state manager class '%s'", statemgrClass), e); } try { launcher = ReflectionUtils.newInstance(launcherClass); } catch (IllegalAccessException | InstantiationException | ClassNotFoundException e) { throw new LauncherException( String.format("Failed to instantiate launcher class '%s'", launcherClass), e); } try { uploader = ReflectionUtils.newInstance(uploaderClass); } catch (IllegalAccessException | InstantiationException | ClassNotFoundException e) { throw new UploaderException( String.format("Failed to instantiate uploader class '%s'", uploaderClass), e); } try { statemgr.initialize(config); SchedulerStateManagerAdaptor adaptor = new SchedulerStateManagerAdaptor(statemgr, 5000); validateSubmit(adaptor, topology.getName()); LOG.log(Level.FINE, "Topology {0} to be submitted", topology.getName()); URI packageURI = uploadPackage(uploader); Config runtime = Config.newBuilder() .putAll(LauncherUtils.getInstance().getPrimaryRuntime(topology, adaptor)) .put(Keys.topologyPackageUri(), packageURI) .put(Keys.launcherClassInstance(), launcher) .build(); callLauncherRunner(runtime); } catch (LauncherException | PackingException e) { uploader.undo(); throw e; } finally { SysUtils.closeIgnoringExceptions(uploader); SysUtils.closeIgnoringExceptions(launcher); SysUtils.closeIgnoringExceptions(statemgr); } }