jcabi-github
jcabi-github copied to clipboard
Incorrect hasName implementation
Github API returns null as name JSON field if user doesn't have a name, but User.Smart#hasName implementation doesn't check it:
public boolean hasName() throws IOException {
return this.json().containsKey("name");
}
So when I check that user has a name and then read this name I'm getting an error:
java.lang.ClassCastException: javax.json.JsonValueImpl cannot be cast to javax.json.JsonString
at org.glassfish.json.JsonObjectBuilderImpl$JsonObjectImpl.getJsonString(JsonObjectBuilderImpl.java:252)
at org.glassfish.json.JsonObjectBuilderImpl$JsonObjectImpl.getString(JsonObjectBuilderImpl.java:257)
at com.jcabi.github.User$Smart.name_aroundBody8(User.java:191)
at com.jcabi.github.User$Smart$AjcClosure9.run(User.java:1)
at org.aspectj.runtime.reflect.JoinPointImpl.proceed(JoinPointImpl.java:149)
at com.jcabi.aspects.aj.MethodLogger.wrap(MethodLogger.java:213)
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:140)
at com.jcabi.github.User$Smart.name(User.java:181)
(https://github.com/zerocracy/farm/issues/1753).
@amihaiemil/z please, pay attention to this issue
@g4s8/z this project will fix the problem faster if you donate a few dollars to it; just click here and pay via Stripe, it's very fast, convenient and appreciated; thanks a lot!
@g4s8 please provide a PR, there are no DEVs on the project and I don't really have time for it now.
I'll release it afterwards. Thanks!
@g4s8 do you still have this issue, care to provide a PR? :D