Incorrect hasName implementation
- Dominant language
- Java
- Stars
- 307
- Forks
- 144
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 14
Description
Github API returns `null` as `name` JSON field if user doesn't have a name, but `User.Smart#hasName` implementation doesn't check it:
```java
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).
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.