• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to fix null pointer in this situation

 
raj talatam
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


if first client gets failed next one also not getting output how to fix this problem


 
Winston Gutkowski
Bartender
Pie
Posts: 10422
63
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
raj talatam wrote:if first client gets failed next one also not getting output how to fix this problem

First, please TellTheDetails (←click). In this case, the stack trace would be useful. If it's huge, just give the first 10 lines or so.

Winston
 
Rob Spoor
Sheriff
Pie
Posts: 20546
56
Chrome Eclipse IDE Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On line 59 you explicitly throw this NullPointerException. I have no idea why though.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
raj talatam wrote:
ts.registerObserver(printMedia);
ts.registerObserver(onlineMedia);
if first client gets failed next one also not getting output how to fix this problem

rearrange the subscribing sequence..

 
Matthew Brown
Bartender
Posts: 4567
8
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I assume the idea is for a failing observer not to cause following observers to be skipped, and the explicitly thrown exception is a test. In which case, put a try/catch block around the code that notifies the individual observers.

I'd question whether it's a great idea, though. Any NullPointerException should be a bug, and the best way to handle it is to fix it!
 
Palak Mathur
Ranch Hand
Posts: 342
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Matthew Brown wrote:I assume the idea is for a failing observer not to cause following observers to be skipped, and the explicitly thrown exception is a test. In which case, put a try/catch block around the code that notifies the individual observers.

I'd question whether it's a great idea, though. Any NullPointerException should be a bug, and the best way to handle it is to fix it!


I second Matthew over here. I remember when I started programming, my Lead used to say that getting a NullPointerException is a SIN and if it is your code, then you are a SINNER!!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic