• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to fix null pointer in this situation

 
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


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


 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 22781
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
On line 59 you explicitly throw this NullPointerException. I have no idea why though.
 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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..

 
Bartender
Posts: 4568
9
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Ranch Hand
Posts: 343
Mac OS X Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic