Skip to content

Commit

Permalink
Assert obvious non-null references
Browse files Browse the repository at this point in the history
  • Loading branch information
glts committed Apr 2, 2016
1 parent eba849f commit 4518957
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,7 @@
</annotationProcessors>
<compilerArgs>
<arg>-Xbootclasspath/p:${org.checkerframework:jdk8:jar}</arg>
<arg>-AassumeAssertionsAreEnabled</arg>
<arg>-AskipUses=org\.joda\.time\.|org\.springframework\.beans\.|org\.springframework\.core\.|org\.springframework\.dao\.|org\.springframework\.data\.|org\.springframework\.format\.|org\.springframework\.jdbc\.|org\.springframework\.orm\.|org\.springframework\.stereotype\.|org\.springframework\.ui\.|org\.springframework\.util\.|org\.springframework\.validation\.|org\.springframework\.web\.</arg>
</compilerArgs>
</configuration>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,12 @@ public Owner findById(int id) throws DataAccessException {
return owner;
}

public void loadPetsAndVisits(final Owner owner) {
private void loadPetsAndVisits(final Owner owner) {
Integer ownerId = owner.getId();
assert ownerId != null;

Map<String, Object> params = new HashMap<>();
params.put("id", owner.getId());
params.put("id", ownerId);
final List<JdbcPet> pets = this.namedParameterJdbcTemplate.query(
"SELECT pets.id, name, birth_date, type_id, owner_id, visits.id as visit_id, visit_date, description, pet_id FROM pets LEFT OUTER JOIN visits ON pets.id = pet_id WHERE owner_id=:id",
params,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ public Pet findById(int id) throws DataAccessException {
owner.addPet(pet);
pet.setType(EntityUtils.getById(findPetTypes(), PetType.class, pet.getTypeId()));

List<Visit> visits = this.visitRepository.findByPetId(pet.getId());
Integer petId = pet.getId();
assert petId != null;
List<Visit> visits = this.visitRepository.findByPetId(petId);
for (Visit visit : visits) {
pet.addVisit(visit);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ public String processFindForm(Owner owner, BindingResult result, Map<String, Obj
}

// find owners by last name
Collection<Owner> results = this.clinicService.findOwnerByLastName(owner.getLastName());
String lastName = owner.getLastName();
assert lastName != null;
Collection<Owner> results = this.clinicService.findOwnerByLastName(lastName);
if (results.isEmpty()) {
// no owners found
result.rejectValue("lastName", "notFound", "not found");
Expand Down

0 comments on commit 4518957

Please sign in to comment.