osama-raddad/encog-java

Corrupt temp file will cause workbench to crash

Closed this issue · 2 comments

If the temp file becomes corrupted, this will cause an error while starting
up the workbench.  This causes the workbench to fail to load.  A corrupt
temp file should simply be deleted.

Original issue reported on code.google.com by JeffHeat...@gmail.com on 8 Jul 2009 at 1:22

The issue 25 is still present in HEAD as of today (for 2.2.0 ?).
The change made in org.encog.workbench.EncogWorkBench didn't fix it (at least 
for me)
because the Exception throw was a NullPointerException and only EncodeException 
are
surrounded by a try/catch block.
I didn't submit a patch because i see 3 ways to fix it :
1) Fix it in org.encog.workbench.EncogWorkBench by catching all Exceptions. 
This is
bad for a framework but it make sens in a gui application where there is nothing
worst than a silent death.
2) Fix the PersistReader in the encode-core to throws more exceptions when the 
file
is corrupted. In my case it occur in the buildDirectory method but it's because 
the
compareTo method of the DirectoryEntry crash if the type of one of the two 
objects is
null.
3) Fix the DirectoryEntry compareTo method to handle objects with type null.

I would vote 3 and 1 :D

Stacktrace :

Z:\Appli\encog-workbench-win-2.2.0-SNAPSHOT>java -classpath
jar\encog-core-2.2.0.jar;jar\encog-workbench-2.2.0.jar;jar\jcommon-1.0.16.jar;ja
r\jfreechart-1.0.13.jar;jar\slf4j-api-1.5.6.jar;jar\slf4j-jdk14-1.5.6.jar
org.encog.workbench.EncogWorkBench

Exception in thread "main" java.lang.NullPointerException
        at java.lang.String.compareTo(String.java:1167)
        at org.encog.persist.DirectoryEntry.compareTo(Unknown Source)
        at java.util.TreeMap.put(TreeMap.java:545)
        at java.util.TreeSet.add(TreeSet.java:238)
        at org.encog.persist.PersistReader.buildDirectory(Unknown Source)
        at org.encog.persist.EncogPersistedCollection.buildDirectory(Unknown Source)
        at org.encog.persist.EncogPersistedCollection.<init>(Unknown Source)
        at org.encog.persist.EncogPersistedCollection.<init>(Unknown Source)
        at org.encog.workbench.EncogWorkBench.<init>(Unknown Source)
        at org.encog.workbench.EncogWorkBench.getInstance(Unknown Source)
        at org.encog.workbench.EncogWorkBench.main(Unknown Source)

Original comment by nicolas....@gmail.com on 19 Sep 2009 at 6:42

Work bench no longer uses temp files this way.  Also if you open a bad EG file, 
a corruption message is displayed now.

Original comment by heatonre...@gmail.com on 16 Aug 2010 at 7:49

  • Changed state: Verified