From 9f681776b297a09ad96f10b866c90fc32606ad29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20B=C3=BCrgin?= <676c7473@gmail.com> Date: Sat, 2 Apr 2016 20:55:16 +0200 Subject: [PATCH] Fix possible null argument warning --- .../springframework/samples/petclinic/web/PetController.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/springframework/samples/petclinic/web/PetController.java b/src/main/java/org/springframework/samples/petclinic/web/PetController.java index a944997..d89bccc 100644 --- a/src/main/java/org/springframework/samples/petclinic/web/PetController.java +++ b/src/main/java/org/springframework/samples/petclinic/web/PetController.java @@ -77,7 +77,8 @@ public String initCreationForm(Owner owner, ModelMap model) { @RequestMapping(value = "/pets/new", method = RequestMethod.POST) public String processCreationForm(Owner owner, @Valid Pet pet, BindingResult result, ModelMap model) { - if (StringUtils.hasLength(pet.getName()) && pet.isNew() && owner.getPet(pet.getName(), true) != null){ + String petName = pet.getName(); + if (StringUtils.hasLength(petName) && pet.isNew() && owner.getPet(petName, true) != null) { result.rejectValue("name", "duplicate", "already exists"); } if (result.hasErrors()) {