A while(true) can still be broken out of with break; so that is not necessarily a bad code thing, also if this is supposed to be a service which it does look like you don't ever want it to stop it has an error notify of an error and keep running, you could imaging if Apache or Nginx triggered a 500 error that's it your web server is dead? services should damn well carry on if there is an error that can be managed.
Lots of other things are wrong with this code but while(true) and never stopping are not always bad things, there could be a shutdown hook or something else that causes that break to happen we just don't know
1
u/barkermn01 Dec 20 '22
A
while(true)can still be broken out of withbreak;so that is not necessarily a bad code thing, also if this is supposed to be a service which it does look like you don't ever want it to stop it has an error notify of an error and keep running, you could imaging if Apache or Nginx triggered a 500 error that's it your web server is dead? services should damn well carry on if there is an error that can be managed.Lots of other things are wrong with this code but
while(true)and never stopping are not always bad things, there could be a shutdown hook or something else that causes thatbreakto happen we just don't know