Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OnlineTaskAspect这个类里面很多地方都有空指针异常情况。 #30

Closed
littleyang opened this issue May 29, 2019 · 3 comments
Closed

Comments

@littleyang
Copy link

  1. 这个方法里面从runningTaskMap读取不到数据的时候会空指针异常
    @before(value = "serviceStatistics(onlineTask)")
    public void deBefore(JoinPoint joinPoint, OnlineTask onlineTask) throws Throwable

    if (runningTaskMap.containsKey(task) && runningTaskMap.get(task).equals(TaskStatus.RUNNING)) {
    throw new OnlineTaskException("This task is running");
    }

2.下面这个方法同样的问题。
@AfterReturning(returning = "result", pointcut = "serviceStatistics(onlineTask)")
public void afterReturning(JoinPoint joinPoint, OnlineTask onlineTask, Object result)
if (runningTaskMap.get(task).equals(TaskStatus.RUNNING))

3.同样的问题。
@before(value = "serviceStatistics(onlineTask)")
public void deBefore(JoinPoint joinPoint, OnlineTask onlineTask) throws Throwable {
if (runningTaskMap.containsKey(task) && runningTaskMap.get(task).equals(TaskStatus.RUNNING)) {
throw new OnlineTaskException("This task is running");
}
4. 下面这个方法既然后面用横线截取字符串,那就是要求application name必须带中划线(-)记得文档里面写清楚啊,这里会报字符串数组越界异常的,如果application name里面没有中划线。
/**
* @param request
* @return
*/
public Map<String, String> builtMqMessage(HttpServletRequest request) {

    Map<String, String> jsonObject = new HashMap<String, String>(8);
    jsonObject.put("GroupName", onlineTaskAppProperty.getApplicationName().substring(0,
            onlineTaskAppProperty.getApplicationName().indexOf("-")));
    jsonObject.put("ApplicationName", onlineTaskAppProperty.getApplicationName());
    jsonObject.put("TaskName", onlineTaskAppProperty.getApplicationName() + ":" + request.getServletPath());
    jsonObject.put("Host", onlineTaskAppProperty.getIPAddress() + ":" + onlineTaskAppProperty.getServerPort());
    jsonObject.put("RequestURL", request.getRequestURL().toString());
    jsonObject.put("Date", DateFormatHelper.format(new Date()));
    return jsonObject;
}
@TeddiWolf
Copy link
Contributor

收到,我们会抓紧调整

@Maozw
Copy link
Contributor

Maozw commented May 30, 2019

感谢指正,针对1-3提出的的确是代码不严谨导致。针对4 在使用文档中我们进行了说明请参考:
项目名称(必须)
命名规则:项目组名-项目名-其他
命名示例:skytrain-supervise,项目组名为skytrain
spring.application.name=spring-3.x-test

@TeddiWolf
Copy link
Contributor

fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants