/**
 * Copyright 2016, RadiantBlue Technologies, Inc.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 **/
package jobmanager;

import java.util.concurrent.Executor;

import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.web.SpringBootServletInitializer;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.AsyncConfigurer;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

@SpringBootApplication
@Configuration
@EnableAsync
@EnableScheduling
@ComponentScan({ "jobmanager, util" })
public class Application extends SpringBootServletInitializer implements AsyncConfigurer {

	@Override
	protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
		return builder.sources(Application.class);
	}

	public static void main(String[] args) {
		SpringApplication.run(Application.class, args);
	}

	@Override
	public Executor getAsyncExecutor() {
		ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
		// Thread pool site is capped at 500 because that is the maximum number of concurrent Mongo connections that
		// this client can handle.
		executor.setCorePoolSize(500);
		executor.setMaxPoolSize(500);
		executor.initialize();
		return executor;
	}

	@Override
	public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
		return null;
	}
}
@@ -628,24 +628,57 @@
 obmanager;%0A%0A
+import java.lang.reflect.Method;%0A
 import java.
@@ -2335,11 +2335,327 @@
 rn n
-ull
+ew AsyncUncaughtExceptionHandler() %7B%0A%09%09%09@Override%0A%09%09%09public void handleUncaughtException(Throwable ex, Method method, Object... params) %7B%0A%09%09%09%09String error = String.format(%22Uncaught Threading exception encountered in %25s with details: %25s%22, ex.getMessage(),%0A%09%09%09%09%09%09method.getName());%0A%09%09%09%09System.out.println(error);%0A%09%09%09%7D%0A%09%09%7D
 ;%0A%09%7D

Add Thread Exception Handler