rjohnsondev / java-libpst

A library to read PST files with java, without need for external libraries.
251 stars 122 forks source link

PSTFolder::getNextChild exceptions leave PSTFolder in unadvanceable state #79

Open matthewjosephtaylor opened 5 years ago

matthewjosephtaylor commented 5 years ago

If PSTFolder has an error in getNextChild it leaves PSTFolder object in a state where it can never advance to the next child.

Example of exception that leaves PSTFolder in a bad state:

Exception com.pff.PSTException: Unable to find 2098852 is desc: true
      at PSTFile.findBtreeItem (PSTFile.java:756)
      at PSTFile.getDescriptorIndexNode (PSTFile.java:773)
      at PSTFolder.getNextChild (PSTFolder.java:295)

Believe this could be overcome by incrementing this.currentEmailIndex ahead of doing the work of creating the child object.

Might also be better to give users a simple API to get children at a specific index.

My present work-around is to attempt to use the PstFolder::moveChildCursorTo method to advance manually, and keep track fo the current index outside of PSTFolder. (still testing code not 100% on if this strategy works as expected).