动态权限报错请个位看看

Spring Security 动态权限 getAttributes报错
Failed to create a session, as response has been committed. Unable to store SecurityContext


 @Override
    public Collection<ConfigAttribute> getAttributes(Object object) throws IllegalArgumentException {
        AntPathMatcher antPathMatcher = new AntPathMatcher();
        String url=((FilterInvocation)object).getRequestUrl();

        for (Menu menu : allMenu) {
            String menuUrl=getUrl(menu);
            if(antPathMatcher.match(menuUrl,url)){
               List<Rolebymenu> list=getRoleByMenu(menu);
               String[] roleArr=getRoleArr(list);
                return SecurityConfig.createList(roleArr);
            }
        }
               return SecurityConfig.createList("ROLE_LOGIN");
    }

getRoleByMenu 方法代码

 private List<Rolebymenu> getRoleByMenu(Menu meun)
        {//查询该资源对应的权限
        int type=meun.getType();
        MyWrapper<Rolebymenu> myWrapper= (MyWrapper<Rolebymenu>) new MyWrapper<>().eq("menuid",type);
        try {
            List<Rolebymenu> list = rolebymenuService.list(myWrapper);//数据库查询
            return list;
        }catch (Exception e){
            System.out.println(e.getMessage());
        }

        return null;
    }

这是为什么?