fix null point error

This commit is contained in:
oppofind 2019-12-23 20:39:27 +08:00
parent ec59855850
commit 75b5742973
2 changed files with 5 additions and 5 deletions

View File

@ -1007,10 +1007,10 @@ public class SourceBuilder {
String mockValue = "";
if (DocClassUtil.isPrimitive(simpleTypeName)) {
mockValue = paramsComments.get(paraName);
if(mockValue.contains("|")){
if (Objects.nonNull(mockValue) && mockValue.contains("|")) {
mockValue = mockValue.substring(mockValue.lastIndexOf("|") + 1, mockValue.length());
} else {
mockValue ="";
mockValue = "";
}
if (StringUtil.isEmpty(mockValue)) {
mockValue = DocUtil.getValByTypeAndFieldName(simpleTypeName, paraName, true);
@ -1176,8 +1176,8 @@ public class SourceBuilder {
if (StringUtil.isEmpty(comment)) {
comment = NO_COMMENTS_FOUND;
} else {
if(comment.contains("|")){
comment = comment.substring(0,comment.indexOf("|"));
if (comment.contains("|")) {
comment = comment.substring(0, comment.indexOf("|"));
}
}
List<JavaAnnotation> annotations = parameter.getAnnotations();

View File

@ -181,7 +181,7 @@ public class SpringBootDocBuildTemplate implements IDocBuildTemplate {
String typeName = parameter.getType().getGenericCanonicalName();
String simpleName = parameter.getType().getValue().toLowerCase();
String fullTypeName = parameter.getType().getFullyQualifiedName();
JavaClass javaClass = builder.getClassByName(fullTypeName);
JavaClass javaClass = builder.getJavaProjectBuilder().getClassByName(fullTypeName);
if (!DocClassUtil.isMvcIgnoreParams(typeName)) {
if (!paramTagMap.containsKey(paramName) && DocClassUtil.isPrimitive(fullTypeName) && isStrict) {
throw new RuntimeException("ERROR: Unable to find javadoc @param for actual param \""