From 40efeefb0522a4603ffe9b4e63316aef640c6271 Mon Sep 17 00:00:00 2001 From: Damian Minkov Date: Tue, 17 Oct 2006 08:23:10 +0000 Subject: [PATCH] Skip unparsable documets wihout exception --- .../java/sip/communicator/impl/history/HistoryImpl.java | 7 +++++-- .../sip/communicator/impl/history/HistoryReaderImpl.java | 9 +++++++++ .../sip/communicator/impl/history/HistoryWriterImpl.java | 7 +++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/net/java/sip/communicator/impl/history/HistoryImpl.java b/src/net/java/sip/communicator/impl/history/HistoryImpl.java index 4641b21fa..e730d6d1f 100644 --- a/src/net/java/sip/communicator/impl/history/HistoryImpl.java +++ b/src/net/java/sip/communicator/impl/history/HistoryImpl.java @@ -227,8 +227,11 @@ protected Document getDocumentForFile(String filename) retVal = builder.parse(file); } catch (Exception e) { - throw new RuntimeException("Error occured while " - + "parsing XML document.", e); +// throw new RuntimeException("Error occured while " +// + "parsing XML document.", e); +// log.error("Error occured while parsing XML document.", e); + log.error("Error occured while parsing XML document."); + return null; } // Cache the loaded document for reuse if configured diff --git a/src/net/java/sip/communicator/impl/history/HistoryReaderImpl.java b/src/net/java/sip/communicator/impl/history/HistoryReaderImpl.java index b3813a33d..e755f5caf 100644 --- a/src/net/java/sip/communicator/impl/history/HistoryReaderImpl.java +++ b/src/net/java/sip/communicator/impl/history/HistoryReaderImpl.java @@ -160,6 +160,12 @@ public synchronized QueryResultSet findLast(int count) throws RuntimeException Document doc = this.historyImpl. getDocumentForFile( (String) filelist.get(currentFile)); + if(doc == null) + { + currentFile--; + continue; + } + // will get nodes and construct a List of nodes // so we can easyly get sublist of it List nodes = new ArrayList(); @@ -313,6 +319,9 @@ private QueryResultSet find( Document doc = this.historyImpl.getDocumentForFile(filename); + if(doc == null) + continue; + NodeList nodes = doc.getElementsByTagName("record"); double nodesProgressStep = fileProgressStep; diff --git a/src/net/java/sip/communicator/impl/history/HistoryWriterImpl.java b/src/net/java/sip/communicator/impl/history/HistoryWriterImpl.java index 461eaff38..321717733 100644 --- a/src/net/java/sip/communicator/impl/history/HistoryWriterImpl.java +++ b/src/net/java/sip/communicator/impl/history/HistoryWriterImpl.java @@ -176,6 +176,13 @@ private void createNewDoc(Date date, boolean loadLastFile) this.currentFile = file; loaded = true; } + + // if something happend and file was not loaded + // then we must create new one + if(this.currentDoc == null) + { + loaded = false; + } } if (!loaded)