RFR: 24: Allow lazy evaluation of the fullName field in HostUserDetails

Erik Duveblad via github.com duke at openjdk.java.net
Thu Jun 27 12:42:26 UTC 2019


On Thu, 27 Jun 2019 12:01:28 GMT, Robin Westberg via github.com <duke at openjdk.java.net> wrote:

> Hi all,
> 
> Please review the following change that allows lazy evaluation of the fullName field in HostUserDetails. Most GitHub API calls only return the id and username, so to populate the full name we have to do a separate request. However, the full name is rarely used, so we can save a few API calls by only fetching it when needed.
> 
> Best regards,
> Robin
> 
> ----------------
> 
> Commits:
>  - 54d7f40a:	Allow lazy evaluation of the fullName field in HostUserDetails
> 
> Pull request:
> http://git.openjdk.java.net/skara/pull/9
> 
> Webrev:
> https://openjdk.github.io/cr/skara/9/webrev.00
> 
> Patch:
> http://git.openjdk.java.net/skara/pull/9.diff
> 
> Fetch command:
> git fetch https://github.com/openjdk/skara.git 54d7f40a:pr/9

host/src/main/java/org/openjdk/skara/host/HostUserDetails.java line 52:

> 51:             return true;
> 52:         }
> 53:         if (o == null || getClass() != o.getClass()) {

Perhaps check an throw an exception here instead? Assertions are not enabled by default in the launchers. You can use `Optional` to make this short and sweet:
```
var supplier = Optional.ofNullable(nameSupplier).orElseThrow(IllegalStateException::new)
name = supplier.get();
return name;
```


More information about the skara-dev mailing list