jcabi-github
jcabi-github copied to clipboard
User will fail with class cast exception if name is null
RtIssueITCase#talksInGithubProject will fail with CCE, if User has json name property but the name is null e.g
"name":null
this code (in User.java)
@NotNull(message = "Name is never NULL")
public String name() throws IOException {
final JsonObject json = this.json();
if (!json.containsKey("name")) {
throw new IllegalStateException(
String.format(
// @checkstyle LineLength (1 line)
"User %s doesn't have a name specified in his/her Github account; use #hasName() first.",
this.login()
)
);
}
return json.getString("name");
}
needs to be something like
@NotNull(message = "Name is never NULL")
public String name() throws IOException {
final JsonObject json = this.json();
if (!json.containsKey("name")) {
throw new IllegalStateException(
String.format(
// @checkstyle LineLength (1 line)
"User %s doesn't have a name specified in his/her Github account; use #hasName() first.",
this.login()
)
);
}
return (json.getValueType() == JsonValue.ValueType.STRING) ?
json.getString("name") : json.getJsonObject("name").toString();
}
java.lang.ClassCastException: javax.json.JsonValue$1 cannot be cast to javax.json.JsonString at org.glassfish.json.JsonObjectBuilderImpl$JsonObjectImpl.getJsonString(JsonObjectBuilderImpl.java:194) at org.glassfish.json.JsonObjectBuilderImpl$JsonObjectImpl.getString(JsonObjectBuilderImpl.java:199) at com.jcabi.github.User$Smart.name_aroundBody6(User.java:191) at com.jcabi.github.User$Smart$AjcClosure7.run(User.java:1) at org.aspectj.runtime.reflect.JoinPointImpl.proceed(JoinPointImpl.java:149) at com.jcabi.aspects.aj.MethodLogger.wrap(MethodLogger.java:207) at com.jcabi.aspects.aj.MethodLogger.ajc$inlineAccessMethod$com_jcabi_aspects_aj_MethodLogger$com_jcabi_aspects_aj_MethodLogger$wrap(MethodLogger.java:1) at com.jcabi.aspects.aj.MethodLogger.wrapClass(MethodLogger.java:136) at com.jcabi.github.User$Smart.name(User.java:181) at com.jcabi.github.RtIssueITCase.talksInGithubProject(RtIssueITCase.java:107)
@yegor256 please pay attention to this issue
@tmjee thank you for the ticket reported, I topped your account for 15 mins, transaction AP-11418293C5878071W