在春节时浅橙的接口nginx上偶尔会报500的错误,但tomcat应用日志里找不到什么东西。后来想到有可能不是应用报的错,而是在应用处理之前tomcat就报错了,于是在spring boot中加上了tomcat的访问日志。几天后,发现了这个错

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.util.concurrent.RejectedExecutionException: Task java.util.concurrent.FutureTask@4542552a rejected from java.util.concurrent.ThreadPoolExecutor@a3464b4[Running, pool size = 10, active threads = 10, queued tasks = 0, completed tasks = 43433]

看起来是线程池的问题,而且是业务逻辑进入处理之前出的问题,业务逻辑的总入口是

     * 浅橙请求我方api接口封装
     *
     * @Description
     *
     * @author <a href="changjunhui8173@adpanshi.com">changjunhui</a>
     * @param request
     * @param httpRequest
     * @return
     */
    @RequestMapping(value = "/doCall")
     @HystrixCommand(commandProperties = {
     @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds",
     value = "50000") })
    @ResponseBody
    public String doCall(HttpServletRequest httpRequest, @RequestParam String ua, @RequestParam String call,
            @RequestParam() String args, @RequestParam String sign, @RequestParam(required = false) String timestamp) {
        ResponseMessageQCApi response = new ResponseMessageQCApi(QianchengCode.SUCCESS);
        // String call = "";

        try {
            // 浅橙请求我放接口传入的参数
            // Map<String, String> parameters = new HashMap<String, String>();
            // Map<String, String[]> requestParams = httpRequest.getParameterMap();
            //
            // for (Iterator<String> iter = requestParams.keySet().iterator();
            // iter.hasNext();) {
            // String name = iter.next();
            // String[] values = requestParams.get(name);
            // String valueStr = "";
            // for (int i = 0; i < values.length; i++) {
            // valueStr = (i == values.length - 1) ? valueStr + values[i] : valueStr +
            // values[i] + ",";
            // }

后来在网上查到Hystrix是有个线程池的,而且默认的线程数就是10,于是把@HystrixCommand注释掉,后来就没有这个问题了。看来是因为正在处理的请求达到了最大线程数,来的新的请求就被拒绝掉了