atsevan / garbagecat

Automatically exported from code.google.com/p/garbagecat
0 stars 0 forks source link

NullPointerException when started with -p flag on file with first line not being the proper GC log line #17

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

 java -jar garbagecat-1.0.0.jar -p gc_err.log 

What is the expected output? What do you see instead?

Exception in thread "main" java.lang.NullPointerException
    at org.eclipselabs.garbagecat.service.GcaManager.preprocess(GcaManager.java:101)

fix:
problem is caused by string initialized to null

in the body of GcaManager.preprocess():

instead:

String currentLogLine = null ;
String priorLogLine = null ;
String preprocessedLogLine = null ;

should be:

String currentLogLine = "" ;
String priorLogLine = "" ;
String preprocessedLogLine = "" ;

---------
by the way I made some code cleanings in this method
proposed version in attachment

cleanings:
1.
close only external streams, when you build one stream on another it is enough 
to close only external one

2. simplified while()

Original issue reported on code.google.com by jbor...@gmail.com on 5 May 2011 at 8:33

Attachments:

GoogleCodeExporter commented 9 years ago
Looks good.

Original comment by mgm...@gmail.com on 6 May 2011 at 7:07

GoogleCodeExporter commented 9 years ago

Original comment by mgm...@gmail.com on 19 May 2011 at 1:24