Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / October 2005

Tip: Looking for answers? Try searching our database.

java -server buggy?  Random NullPointerExcpetions!

Thread view: 
Markus Dehmann - 07 Oct 2005 09:09 GMT
I just wasted hours and hours finding the source of a
NullPointerException I was getting.

It turns out the "java -server" switch causes such a NullPointerException.

My application reads in 40,000 text lines and processes them.  The
tricky thing is that the NullPointerException occurs every time on a
different input line.

I nearly got insane.  But now I know it's "java -server"'s fault.

I tested it with java 1.4.2_01 and 1.5.0_03-b07 on Redhat Linux.  And
everytime I use -server I get the exception.

Is this a known bug?

Another thing that made me insane is that the exception *never* occured
on my Mac, with java 1.4.2-54, no matter if I used -server or not.

BTW, I read the input from a FileInputStream.  Should I better use
something Buffered...?

Thanks!
Markus
hiwa - 07 Oct 2005 09:30 GMT
Code please. See:
http://www.physci.org/codes/sscce.jsp
Thomas Weidenfeller - 07 Oct 2005 10:13 GMT
> My application reads in 40,000 text lines and processes them.  The
> tricky thing is that the NullPointerException occurs every time on a
> different input line.
>
> I nearly got insane.  But now I know it's "java -server"'s fault.

No, with a very high probability it is not. With a very high probability
you messed up some thread handling. The problem is exposed by some VMs,
but not by others.

> Is this a known bug?

Check Sun's bug parade by your own if you really think this is a bug in
the VM.

> BTW, I read the input from a FileInputStream.  Should I better use
> something Buffered...?

How should we know? You didn't show us your code. You didn't show us the
exact exception, including the stack trace. You just ranted a little bit
about an assumed bug. Just a few days such behavior was discussed her:

http://groups.google.com/group/comp.lang.java.help/browse_frm/thread/976ecf5c4f734cb7

See also:

http://www.catb.org/~esr/faqs/smart-questions.html#id3001405

/Thomas
Signature

The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq
http://www.uni-giessen.de/faq/archiv/computer-lang.java.gui.faq/

Markus Dehmann - 07 Oct 2005 22:19 GMT
> How should we know? You didn't show us your code. You didn't show us the
> exact exception, including the stack trace. You just ranted a little bit
> about an assumed bug.

Sorry, I can't show the code since the NullPointerExceptions occur in an
external library that I am using.  I do have the source, but it's hard
to construct a minimal example from it.  So, after all I've read here it
might be that a Thread in that library is not safe.

Markus
Roedy Green - 08 Oct 2005 07:06 GMT
>Sorry, I can't show the code since the NullPointerExceptions occur in an
>external library that I am using.  I do have the source, but it's hard
>to construct a minimal example from it.

If you can't do that, show at least some context around the exception.
Even knowing the type of the reference can be a big clue.  Knowing
what methods you called just prior to the exceptions, or the method
you called to create the bad reference help.

Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.

Chris Uppal - 07 Oct 2005 10:31 GMT
> I tested it with java 1.4.2_01 and 1.5.0_03-b07 on Redhat Linux.  And
> everytime I use -server I get the exception.
>
> Is this a known bug?

Quite possibly.  The server VM uses different (more aggressive) optimisation,
and if there's every been an optimising code generator that lacks bugs then I
have yet to hear of it ;-)

> BTW, I read the input from a FileInputStream.  Should I better use
> something Buffered...?

Very definitely you should.  Indeed, given the size of your files, I would say
that you /must/ use buffering of some sort, either with a BufferedReader or by
doing it yourself.

BTW, someone mentioned a problem some time ago, where they were encountering
random errors reading lots of data unbuffered on a Linux system.  It may be
that there's some subtle bug somewhere in the software stack (including any
code included in the disk's own controller) which is exposed by doing many,
many, many, tiny reads at the OS/hardware level.  So there's a /chance/ (albeit
small) that using proper buffering in your code would also side-step the
problem you are seeing with -server.

   -- chris
Markus Dehmann - 07 Oct 2005 22:17 GMT
>>BTW, I read the input from a FileInputStream.  Should I better use
>>something Buffered...?
>
> Very definitely you should.  Indeed, given the size of your files, I would say
> that you /must/ use buffering of some sort, either with a BufferedReader or by
> doing it yourself.

I double-checked it:  I am calling a method in an external library,
passing an InputStream, but the library actually wraps it into a
BufferedReader, internally.  So, that's not the reason for the failures
after all.

Thanks
Markus
Roedy Green - 07 Oct 2005 11:40 GMT
>Is this a known bug?

see http://mindprod.com/jgloss/bugs.html
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.

Roedy Green - 07 Oct 2005 11:49 GMT
>BTW, I read the input from a FileInputStream.  Should I better use
>something Buffered...?

I know you are frustrated but in your frustration the only clue you
have given us is that the problem SOMETIMES shows up.  That is it.
That is all WE have to go on.

That is like going to the doctor and saying "I have a problem that
sometimes shows up most often when I wear my red jacket.  I won't tell
you anything more or let you run any tests, or let you look at my
body."  What is the matter with me??

The only generic advice I can give is that problems that sometimes
show up are nearly always something to do with threads.  

See http://mindprod.com/jgloss/threads.html
http://mindprod.com/jgloss/threadsafe.html
http://mindprod.com/jgloss/volatile.html
http://mindprod.com/jgloss/synchonized.html

For more specific help we have to see the code.  At the very least we
have to  see the stack trace and the code relevant to the stack trace.

-server is going to make bad thread code fail faster since
optimisation spreads logic out over time.
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.

zero - 07 Oct 2005 15:02 GMT
> That is like going to the doctor and saying "I have a problem that
> sometimes shows up most often when I wear my red jacket.  I won't tell
> you anything more or let you run any tests, or let you look at my
> body."  What is the matter with me??

You're allergic to red.  That'll be $15.  Have a nice day.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.