Skip to content

Commit

Permalink
[core] Avoid NPE in AgentTrait.
Browse files Browse the repository at this point in the history
see #76

Signed-off-by: Stéphane Galland <galland@arakhne.org>
  • Loading branch information
gallandarakhneorg committed Nov 26, 2016
1 parent 50d3cf6 commit 06ec111
Showing 1 changed file with 6 additions and 4 deletions.
Expand Up @@ -102,11 +102,13 @@ protected final <S extends Capacity> S getSkill(Class<S> capacity) {
*/
@Pure
protected <S extends Capacity> S $castSkill(Class<S> capacity, ClearableReference<Skill> skillReference) {
final S skill = capacity.cast(skillReference.get());
if (skill == null) {
throw new UnimplementedCapacityException(capacity, getOwner().getID());
if (skillReference != null) {
final S skill = capacity.cast(skillReference.get());
if (skill != null) {
return skill;
}
}
return skill;
throw new UnimplementedCapacityException(capacity, getOwner().getID());
}

@Override
Expand Down

0 comments on commit 06ec111

Please sign in to comment.