From 56cb73914fd05db40417a6219b5968c8eea8a0b6 Mon Sep 17 00:00:00 2001 From: Carsten Lund Date: Fri, 9 Jun 2017 16:28:10 +0000 Subject: [DCAE-15] Final update for rebased code. Change-Id: I51a54dfc3bf645684dd94e8eea9bc55313bea176 Signed-off-by: Carsten Lund --- .../org/openecomp/ncomp/utils/extra/FileTail.java | 32 ++++++++++++---------- 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'ncomp-utils-java-extra/src') 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); -- cgit 1.2.3-korg