Source:
public static TaskFactory fromTaskClassConfig(Config config, ApplicationRunner runner) { String taskClassName; if (isStreamOperatorTask(config)) { taskClassName = StreamOperatorTask.class.getName(); } else { taskClassName = new TaskConfig(config).getTaskClass().getOrElse( new AbstractFunction0<String>() { @Override public String apply() { throw new ConfigException("There is no task class defined in the configuration. Failed to create a valid TaskFactory"); } }); } log.info("Got task class name: {}", taskClassName); boolean isAsyncTaskClass; try { isAsyncTaskClass = AsyncStreamTask.class.isAssignableFrom(Class.forName(taskClassName)); } catch (Throwable t) { log.error("Invalid configuration for AsyncStreamTask class: {}. error: {}", taskClassName, t); throw new ConfigException(String.format("Invalid configuration for AsyncStreamTask class: %s", taskClassName), t); } if (isAsyncTaskClass) { return new AsyncStreamTaskFactory() { @Override public AsyncStreamTask createInstance() { try { return (AsyncStreamTask) Class.forName(taskClassName).newInstance(); } catch (Throwable t) { log.error("Error loading AsyncStreamTask class: {}. error: {}", taskClassName, t); throw new SamzaException(String.format("Error loading AsyncStreamTask class: %s", taskClassName), t); } } }; } return new StreamTaskFactory() { @Override public StreamTask createInstance() { try { if (taskClassName.equals(StreamOperatorTask.class.getName())) { return createStreamOperatorTask(config, runner); } return (StreamTask) Class.forName(taskClassName).newInstance(); } catch (Throwable t) { log.error("Error loading StreamTask class: {}. error: {}", taskClassName, t); throw new SamzaException(String.format("Error loading StreamTask class: %s", taskClassName), t); } } }; }

Target:
public static Object fromTaskClassConfig(Config config, ApplicationRunner runner) { String taskClassName; if (isStreamOperatorTask(config)) { taskClassName = StreamOperatorTask.class.getName(); } else { taskClassName = new TaskConfig(config).getTaskClass().getOrElse( new AbstractFunction0<String>() { @Override public String apply() { throw new ConfigException("There is no task class defined in the configuration. Failed to create a valid TaskFactory"); } }); } log.info("Got task class name: {}", taskClassName); boolean isAsyncTaskClass; try { isAsyncTaskClass = AsyncStreamTask.class.isAssignableFrom(Class.forName(taskClassName)); } catch (Throwable t) { throw new ConfigException(String.format("Invalid configuration for AsyncStreamTask class: %s", taskClassName), t); } if (isAsyncTaskClass) { return new AsyncStreamTaskFactory() { @Override public AsyncStreamTask createInstance() { try { return (AsyncStreamTask) Class.forName(taskClassName).newInstance(); } catch (Throwable t) { log.error("Error loading AsyncStreamTask class: {}. error: {}", taskClassName, t); throw new SamzaException(String.format("Error loading AsyncStreamTask class: %s", taskClassName), t); } } }; } return new StreamTaskFactory() { @Override public StreamTask createInstance() { try { if (taskClassName.equals(StreamOperatorTask.class.getName())) { return createStreamOperatorTask(config, runner); } return (StreamTask) Class.forName(taskClassName).newInstance(); } catch (Throwable t) { log.error("Error loading StreamTask class: {}. error: {}", taskClassName, t); throw new SamzaException(String.format("Error loading StreamTask class: %s", taskClassName), t); } } }; }