No stack trace generated on client site for NullPointerException?

I've been learning Java for about a month now, and not very familiar with a client/server situation like this one.

Basically I ran into a situation where our client java software (GUI) displayed a nullpointerexception popup but no stack trace on the client side. Someone had to go check the server side for the stack trace.

My question is, shouldn't the client side receive this precious information as well? Are situations like that ok, the rationale being one only needs one copy of the stack trace?


Asked by: David565 | Posted: 23-01-2022






Answer 1

Not really. It is not recommended to show the way your app works from behind to the client. Mainly for security reasons. Your stacktrace shows all the objects being called, methods and if compiled with debug info, even lines. That's too much information for the client, it is ok to have it on the server.

This among SQL injection, Cross side script and others that I cannot remember, improper exception handling is a security vulnerability.

EDIT: Here are other vulnerabilities ( although I don't see this one listed :( )

http://en.wikipedia.org/wiki/Vulnerability_(computing)

Answered by: Lenny796 | Posted: 24-02-2022



Answer 2

The client only needs to know hat it needs to know. In alot of cases it perfectly fine to not show any stacktraces on your client. Your users should get clear error messages but dont care about a stacktrace.

For debugging purposes a stacktrace is generally lost anyway, application gives errors, users restart it and gone is any excpetion, so if you need to know the errors use a logging framework.

Answered by: Alissa300 | Posted: 24-02-2022



Similar questions

java - Button is set to Null and NullPointerException is generated in Android

This question already has answers here:


java - Generated Signed APK gives NullPointerException

So I have been facing this problem for a while and I have been searching everywhere for a similar problem but I can not find one. Believe me when I say I have tried most of the methods that I thought may relate. The problem is; When I generate a signed APK to put on the google play store it generates fine and no errors are shown. When I download the app and login it gives this error: ja...


jdbc - Java NullPointerException when traversing a non-null recordset

I am running a query on Sybase ASE that produces a ResultSet that I then traverse and write the contents out to a file. Sometimes, this will throw a NullPointerException, stating that the ResultSet is null. However, it will do this after printing out one or two records. Other times, with the same exact input, I will receive no errors. I have been unable to consist...


java - How to trace a NullPointerException in a chain of getters

If I get a NullPointerException in a call like this: someObject.getSomething().getSomethingElse(). getAnotherThing().getYetAnotherObject().getValue(); I get a rather useless exception text like: Exception in thread "main" java.lang.NullPointerException at package.SomeClass.someMethod(SomeClass.java:12) I find it rather hard to find out which call...


java - Why am I getting a NullPointerException when trying to read a file?

I use this test to convert txt to pdf : package convert.pdf; //getResourceAsStream(String name) : Returns an input stream for reading the specified resource. //toByteArray : Get the contents of an InputStream as a byte[]. import java.io.FileOutputStream; import java.io.IOException; import org.apache.commons.io.IOUtils; import convert.pdf.txt.TextConversion; public class TestConversion { private stat...


java - How to redirect NullPointerExceptions in Struts?

is there a way to redirect all NullPointerExceptions to a pretty jsp page perhaps in Struts? Thanks in advance!


java - Why is my NullPointerException not being caught in my catch block?

I have a thread in which I catch all errors in a big, all-encompassing catch block. I do this so that I can report any error, not just expected ones, in my application. My Runnable looks like this: public final void run() { try { System.out.println("Do things"); /* [1] */ doUnsafeThings(); } catch (Throwable t) { System.out.println("Catch"); /* [2] */ re...


java - NullPointerException using ImageIO.read

I'm getting an NPE while trying to read in an image file, and I can't for the life of me figure out why. Here is my line: BufferedImage source = ImageIO.read(new File(imgPath)); imgPath is basically guaranteed to be valid and right before it gets here it copies the file from the server. When it hits that line, I get this stack trace: Exception in thread "Thread-26" java.l...


java - Why am I getting a NullPointerException in this for loop?

here is my code: Comic[] comix = new Comic[3]; comix[0] = new Comic("The Amazing Spider-man","A-1","Very Fine",9240.00F); comix[0].setPrice((Float)quality.get(comix[0].condition)); for(int i=0;i<comix.length;i++){ System.out.println("Title: " + comix[i].title); } Why am I getting a NullPointerException when this code runs?


coding style - Gracefully avoiding NullPointerException in Java

Consider this line: if (object.getAttribute("someAttr").equals("true")) { // .... Obviously this line is a potential bug, the attribute might be null and we will get a NullPointerException. So we need to refactor it to one of two choices: First option: if ("true".equals(object.getAttribute("someAttr"))) { // ....


java - NullPointerException with an override method

Can anyone comment with their opinion on the best way to resolve the following issue? I've tried init blocks and initializing the field in the constructor, but neither get called before the overridden method tries to clear it. class TestRunner { public static void main(String[] args) { ftw ftw = new ftw(); ftw.dontPanic(); } } class wtf { wtf(){ ...


java - Hibernate NullPointerException when using criteria in a EntityMode.DOM4J session

I'm running into a null pointer exception if I try to use the following code: //Spring JPA entityManager allow us to retriver the underlying session. org.hibernate.Session session = (org.hibernate.Session)entityManager.getDelegate(); org.hibernate.Session dom4jSession = session.getSession(org.hibernate.EntityMode.DOM4J); org.hibernate.Criteria c = session.createCriteria(User.class); c.list(); ...






Still can't find your answer? Check out these amazing Java communities for help...



Java Reddit Community | Java Help Reddit Community | Dev.to Java Community | Java Discord | Java Programmers (Facebook) | Java developers (Facebook)



top