IDEMPIERE-3618 Support OFX 2 in org.compiere.impexp.OFXFileBankStatementLoader

This commit is contained in:
Diego Ruiz 2018-06-21 10:50:27 +02:00
parent 36985e7096
commit 2cf832fc43
2 changed files with 19 additions and 8 deletions

View File

@ -202,6 +202,10 @@ public abstract class OFXBankStatementHandler extends DefaultHandler
m_errorMessage = new StringBuffer("ErrorInitializingParser");
m_errorDescription = new StringBuffer("Unable to initialize SAX parser: ").append(e.getMessage());
}
if (!result)
closeBufferedReader();
return result;
} // init
@ -256,6 +260,7 @@ public abstract class OFXBankStatementHandler extends DefaultHandler
{
m_errorMessage = new StringBuffer("ErrorReadingData");
m_errorDescription = new StringBuffer(e.getMessage());
closeBufferedReader();
return result;
}
@ -322,11 +327,22 @@ public abstract class OFXBankStatementHandler extends DefaultHandler
{
m_errorMessage = new StringBuffer("ErrorReadingData");
m_errorDescription = new StringBuffer(e.getMessage());
} finally {
closeBufferedReader();
}
return result;
} // loadLines
private void closeBufferedReader() {
if (m_reader != null)
try {
m_reader.close();
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* Method getDateLastRun
* @return Timestamp

View File

@ -17,7 +17,6 @@
package org.compiere.impexp;
import java.io.FileInputStream;
import java.io.IOException;
import org.compiere.model.MBankStatementLoader;
import org.xml.sax.SAXException;
@ -38,6 +37,9 @@ public final class OFXFileBankStatementLoader extends OFXBankStatementHandler im
* @return boolean
* @see org.compiere.impexp.BankStatementLoaderInterface#init(MBankStatementLoader)
*/
//m_stream is not closed because the BufferedReader in the parent class is closed and according to the Java docs:
//Calling close() on the BufferedReader closes the underlying stream by default implementation
@SuppressWarnings("resource")
public boolean init(MBankStatementLoader controller)
{
boolean result = false;
@ -72,13 +74,6 @@ public final class OFXFileBankStatementLoader extends OFXBankStatementHandler im
{
m_errorMessage = new StringBuffer("ErrorReadingData");
m_errorDescription = new StringBuffer();
}finally{
if (m_stream != null)
try {
m_stream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return result;