diff options
Diffstat (limited to 'ncomp-utils-java-extra/src')
-rw-r--r-- | ncomp-utils-java-extra/src/main/java/org/openecomp/ncomp/utils/extra/FileTail.java | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/ncomp-utils-java-extra/src/main/java/org/openecomp/ncomp/utils/extra/FileTail.java b/ncomp-utils-java-extra/src/main/java/org/openecomp/ncomp/utils/extra/FileTail.java index 623733d..c0c2e33 100644 --- a/ncomp-utils-java-extra/src/main/java/org/openecomp/ncomp/utils/extra/FileTail.java +++ b/ncomp-utils-java-extra/src/main/java/org/openecomp/ncomp/utils/extra/FileTail.java @@ -173,22 +173,26 @@ public class FileTail { continue; } RandomAccessFile rf = new RandomAccessFile(file, "r"); - rf.seek(p); - String line = null; - while ((line = rf.readLine()) != null) { - if (line.length() == 0) - continue; - if (logger.isDebugEnabled()) - logger.debug("New line from file: " + f + " " + line); - p = rf.getFilePointer(); - try { - handler.newLine(file.getAbsolutePath(),line,context); - } catch (Exception e) { - logger.warn("Handler error: " + f + " " + e + " line=" + line); - e.printStackTrace(); + try { + rf.seek(p); + String line = null; + while ((line = rf.readLine()) != null) { + if (line.length() == 0) + continue; + if (logger.isDebugEnabled()) + logger.debug("New line from file: " + f + " " + line); + p = rf.getFilePointer(); + try { + handler.newLine(file.getAbsolutePath(),line,context); + } catch (Exception e) { + logger.warn("Handler error: " + f + " " + e + " line=" + line); + e.printStackTrace(); + } } } - rf.close(); + finally { + rf.close(); + } } synchronized (this) { filePointerMap.put(f, p); |