0
@Override
public boolean changeEquipmentCmd( String serialNumber, String cmd )
{
  Equipment e = equipmentRepository.findEquipmentBySerialNumber( serialNumber );
  e.setCommand( cmd );
  equipmentRepository.save( e );
  return true;
}

@RequestMapping( value = "/equipment/changeCmd", method = RequestMethod.PUT )
public boolean changeEquipmentCmd( @RequestParam( "sn" ) String serialNumber, @RequestParam( "cmd" ) String cmd ) 
{
  return iotMetier.changeEquipmentCmd( serialNumber, cmd );
}
tquadrat
  • 3,033
  • 1
  • 16
  • 29

1 Answers1

0

What's so difficult in understanding the error message?

e is null in the call to e.setCommand( cmd );.

That's because the call to equipmentRepository.findEquipmentBySerialNumber( serialNumber ); returns null.

Why that call returns null… well, that is another question.

tquadrat
  • 3,033
  • 1
  • 16
  • 29
  • what I don't understand is why it returns null – Boucounta Ba Jun 03 '22 at 15:17
  • @BoucountaBa – As said: that is another question! One that cannot be answered without knowing the specification of `findEquipmentBySerialNumber()` and its implementation; also useful would be the value of `serialNumber` and whether that value exists in the data that is search by `findEquipmentBySerialNumber()`. – tquadrat Jun 03 '22 at 22:16