From f78bb44ad1e658ab90a4525f1306acf7c7dc2ded Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Berenguel?= Date: Fri, 27 Oct 2023 14:30:23 -0300 Subject: [PATCH 01/12] #1855: installs the AmazonCorrettoCryptoProvider if it is available --- .../src/main/java/iped/engine/core/Manager.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/iped-engine/src/main/java/iped/engine/core/Manager.java b/iped-engine/src/main/java/iped/engine/core/Manager.java index b3afd9c432..e155967812 100644 --- a/iped-engine/src/main/java/iped/engine/core/Manager.java +++ b/iped-engine/src/main/java/iped/engine/core/Manager.java @@ -21,6 +21,7 @@ import java.io.File; import java.io.IOException; import java.io.UnsupportedEncodingException; +import java.lang.reflect.Method; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.nio.file.Files; @@ -158,6 +159,16 @@ public class Manager { private static final String appWinExeFileName = "IPED-SearchApp.exe"; static { + + // installs the AmazonCorrettoCryptoProvider if it is available + try { + Class clazz = Class.forName("com.amazon.corretto.crypto.provider.AmazonCorrettoCryptoProvider"); + Method method = clazz.getMethod("install"); + method.invoke(null); + } catch (Exception e) { + LOGGER.debug("AmazonCorrettoCryptoProvider not installed", e); + } + if (Security.getProvider(BouncyCastleProvider.PROVIDER_NAME) == null) { Security.addProvider(new BouncyCastleProvider()); } From fe32d98eac54b0d7b9598f14f9dcd70c30787356 Mon Sep 17 00:00:00 2001 From: Luis Nassif Date: Fri, 27 Oct 2023 15:22:12 -0300 Subject: [PATCH 02/12] update NER module not found error message --- .../src/main/java/iped/engine/task/NamedEntityTask.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iped-engine/src/main/java/iped/engine/task/NamedEntityTask.java b/iped-engine/src/main/java/iped/engine/task/NamedEntityTask.java index 71bf4a9e27..58cb210a24 100644 --- a/iped-engine/src/main/java/iped/engine/task/NamedEntityTask.java +++ b/iped-engine/src/main/java/iped/engine/task/NamedEntityTask.java @@ -72,7 +72,7 @@ public void init(ConfigurationManager configurationManager) throws Exception { Class.forName("edu.stanford.nlp.ie.crf.CRFClassifier"); //$NON-NLS-1$ } catch (ClassNotFoundException e) { - LOGGER.error("StanfordCoreNLP not found. Did you put the jar in the optional lib folder?"); + LOGGER.error("StanfordCoreNLP not found. Did you put the jar in 'plugins' folder?"); nerConfig.setEnabled(false); return; } @@ -86,7 +86,7 @@ public void init(ConfigurationManager configurationManager) throws Exception { URL modelResource = this.getClass().getResource("/" + modelPath); //$NON-NLS-1$ if (modelResource == null) { - LOGGER.error(modelPath + " not found. Did you put the model in the optional lib folder?"); + LOGGER.error(modelPath + " not found. Did you put the model in 'plugins' folder?"); nerConfig.setEnabled(false); return; } From f6a329106203a1c0c7cf75948643e6714c8f10ec Mon Sep 17 00:00:00 2001 From: tc-wleite Date: Sun, 29 Oct 2023 14:39:55 -0300 Subject: [PATCH 03/12] '#1950: Simplify times per parser control. --- .../iped/app/processing/ui/ProgressFrame.java | 16 +++--- .../java/iped/engine/task/ParsingTask.java | 51 ++++++++----------- 2 files changed, 29 insertions(+), 38 deletions(-) diff --git a/iped-app/src/main/java/iped/app/processing/ui/ProgressFrame.java b/iped-app/src/main/java/iped/app/processing/ui/ProgressFrame.java index 8d94f9a0d6..ba4da6bfe7 100644 --- a/iped-app/src/main/java/iped/app/processing/ui/ProgressFrame.java +++ b/iped-app/src/main/java/iped/app/processing/ui/ProgressFrame.java @@ -40,8 +40,8 @@ import java.util.Date; import java.util.HashMap; import java.util.Map; -import java.util.Map.Entry; -import java.util.concurrent.atomic.AtomicLong; +import java.util.SortedMap; +import java.util.TreeMap; import javax.swing.BorderFactory; import javax.swing.BoxLayout; @@ -93,6 +93,7 @@ public class ProgressFrame extends JFrame implements PropertyChangeListener, Act private boolean paused = false; private String decodingDir = null; private long physicalMemory; + private static final SortedMap timesPerParser = new TreeMap(); private static class RestrictedSizeLabel extends JLabel { @@ -377,7 +378,8 @@ private String getTaskTimes() { } private String getParserTimes() { - if (ParsingTask.times.isEmpty()) + ParsingTask.copyTimesPerParser(timesPerParser); + if (timesPerParser.isEmpty()) return ""; StringBuilder msg = new StringBuilder(); startTable(msg); @@ -391,14 +393,12 @@ private String getParserTimes() { if (totalTime < 1) totalTime = 1; - for (Object o : ParsingTask.times.entrySet().toArray()) { - @SuppressWarnings("unchecked") - Entry e = (Entry) o; - long time = e.getValue().get(); + for (String parserName : timesPerParser.keySet()) { + long time = timesPerParser.get(parserName); long sec = time / (1000000 * workers.length); int pct = (int) ((100 * time) / totalTime); - startRow(msg, e.getKey(), pct); + startRow(msg, parserName, pct); addCell(msg, nf.format(sec) + "s", Align.RIGHT); finishRow(msg, pct + "%", Align.RIGHT); } diff --git a/iped-engine/src/main/java/iped/engine/task/ParsingTask.java b/iped-engine/src/main/java/iped/engine/task/ParsingTask.java index 4e286ce261..a3b8247d6c 100644 --- a/iped-engine/src/main/java/iped/engine/task/ParsingTask.java +++ b/iped-engine/src/main/java/iped/engine/task/ParsingTask.java @@ -1,7 +1,7 @@ /* * Copyright 2012-2014, Luis Filipe da Cruz Nassif * - * This file is part of Indexador e Processador de Evidências Digitais (IPED). + * This file is part of Indexador e Processador de Evidências Digitais (IPED). * * IPED is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,13 +23,11 @@ import java.io.InputStream; import java.util.Arrays; import java.util.Base64; -import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; -import java.util.TreeMap; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; @@ -155,7 +153,7 @@ public class ParsingTask extends ThumbTask implements EmbeddedDocumentExtractor private static int max_expanding_containers; public static AtomicLong totalText = new AtomicLong(); - public static Map times = Collections.synchronizedMap(new TreeMap()); + private static final Map timesPerParser = new HashMap(); private static Map zipBombStatsMap = new ConcurrentHashMap<>(); private static final Set typesToCheckZipBomb = getTypesToCheckZipbomb(); @@ -170,8 +168,7 @@ public class ParsingTask extends ThumbTask implements EmbeddedDocumentExtractor private boolean extractEmbedded; private volatile ParsingReader reader; private String firstParentPath = null; - private Map timeInDepth = new ConcurrentHashMap<>(); - private volatile int depth = 0; + private volatile long subitemsTime; private Map idToItemMap = new HashMap<>(); private int numSubitems = 0; private StandardParser autoParser; @@ -307,34 +304,26 @@ public void process(IItem evidence) throws Exception { return; } - String parserName = getParserName(parser, evidence.getMetadata().get(Metadata.CONTENT_TYPE)); - AtomicLong time = times.get(parserName); - if (time == null) { - time = new AtomicLong(); - times.put(parserName, time); - } - SplitLargeBinaryConfig splitConfig = ConfigurationManager.get() .findObject(SplitLargeBinaryConfig.class); if (((Item) evidence).getTextCache() == null && ((evidence.getLength() == null || evidence.getLength() < splitConfig.getMinItemSizeToFragment()) || StandardParser.isSpecificParser(parser))) { + + ParsingTask task = null; try { - depth++; - ParsingTask task = new ParsingTask(worker, autoParser); + task = new ParsingTask(worker, autoParser); task.parsingConfig = this.parsingConfig; task.expandConfig = this.expandConfig; - task.depth = depth; - task.timeInDepth = timeInDepth; task.safeProcess(evidence); } finally { - depth--; + String parserName = getParserName(parser, evidence.getMetadata().get(Metadata.CONTENT_TYPE)); + long st = task == null ? 0 : task.subitemsTime; long diff = System.nanoTime() / 1000 - start; - Long subitemsTime = timeInDepth.remove(depth + 1); - if (subitemsTime == null) - subitemsTime = 0L; - time.addAndGet(diff - subitemsTime); + synchronized (timesPerParser) { + timesPerParser.merge(parserName, diff - st, Long::sum); + } } } @@ -694,22 +683,18 @@ public void parseEmbedded(InputStream inputStream, ContentHandler handler, Metad // pausa contagem de timeout do pai antes de extrair e processar subitem if (reader.setTimeoutPaused(true)) { + long start = System.nanoTime() / 1000; try { - long start = System.nanoTime() / 1000; - ProcessTime time = ProcessTime.AUTO; worker.processNewItem(subItem, time); Statistics.get().incSubitemsDiscovered(); numSubitems++; - long diff = (System.nanoTime() / 1000) - start; - Long prevTime = timeInDepth.get(depth); - if (prevTime == null) - prevTime = 0L; - timeInDepth.put(depth, prevTime + diff); - } finally { + // Store time spent on subitems processing + subitemsTime += System.nanoTime() / 1000 - start; + // despausa contador de timeout do pai somente após processar subitem reader.setTimeoutPaused(false); @@ -875,4 +860,10 @@ public void finish() throws Exception { totalText = null; } + public static void copyTimesPerParser(Map dest) { + dest.clear(); + synchronized (timesPerParser) { + dest.putAll(timesPerParser); + } + } } From a4c64965ff26754bbfe4d934eac544617a4c837c Mon Sep 17 00:00:00 2001 From: tc-wleite Date: Sun, 29 Oct 2023 14:42:00 -0300 Subject: [PATCH 04/12] '#1950: Compute parser total time from timesPerParser. --- .../main/java/iped/app/processing/ui/ProgressFrame.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/iped-app/src/main/java/iped/app/processing/ui/ProgressFrame.java b/iped-app/src/main/java/iped/app/processing/ui/ProgressFrame.java index ba4da6bfe7..df773c07fe 100644 --- a/iped-app/src/main/java/iped/app/processing/ui/ProgressFrame.java +++ b/iped-app/src/main/java/iped/app/processing/ui/ProgressFrame.java @@ -386,10 +386,9 @@ private String getParserTimes() { addTitle(msg, 3, Messages.getString("ProgressFrame.ParserTimes")); long totalTime = 0; - for (Worker worker : workers) - for (AbstractTask task : worker.tasks) - if (task.getClass().equals(ParsingTask.class)) - totalTime += task.getTaskTime(); + for (long parserTime : timesPerParser.values()) { + totalTime += parserTime; + } if (totalTime < 1) totalTime = 1; From f399bf5a63c15b4122ea54677d8e0f7c40b16b45 Mon Sep 17 00:00:00 2001 From: tc-wleite Date: Sun, 29 Oct 2023 14:45:41 -0300 Subject: [PATCH 05/12] '#1950: Use rounding for task and parser percentages. --- .../src/main/java/iped/app/processing/ui/ProgressFrame.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iped-app/src/main/java/iped/app/processing/ui/ProgressFrame.java b/iped-app/src/main/java/iped/app/processing/ui/ProgressFrame.java index df773c07fe..59146c9a2e 100644 --- a/iped-app/src/main/java/iped/app/processing/ui/ProgressFrame.java +++ b/iped-app/src/main/java/iped/app/processing/ui/ProgressFrame.java @@ -361,7 +361,7 @@ private String getTaskTimes() { if (task.isEnabled()) { long time = taskTimes[i]; long sec = time / (1000000 * workers.length); - int pct = (int) ((100 * time) / totalTime); + int pct = (int) ((100 * time + totalTime / 2) / totalTime); // Round percentage startRow(msg, task.getName(), pct); addCell(msg, nf.format(sec) + "s", Align.RIGHT); @@ -395,7 +395,7 @@ private String getParserTimes() { for (String parserName : timesPerParser.keySet()) { long time = timesPerParser.get(parserName); long sec = time / (1000000 * workers.length); - int pct = (int) ((100 * time) / totalTime); + int pct = (int) ((100 * time + totalTime / 2) / totalTime); // Round percentage startRow(msg, parserName, pct); addCell(msg, nf.format(sec) + "s", Align.RIGHT); From c74a604753c2fbd88b5724543898cfb6de1cd9d0 Mon Sep 17 00:00:00 2001 From: tc-wleite Date: Sun, 29 Oct 2023 14:46:37 -0300 Subject: [PATCH 06/12] '#1950: Add a log warning if parsing time is negative. --- iped-engine/src/main/java/iped/engine/task/ParsingTask.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/iped-engine/src/main/java/iped/engine/task/ParsingTask.java b/iped-engine/src/main/java/iped/engine/task/ParsingTask.java index a3b8247d6c..bc75e48491 100644 --- a/iped-engine/src/main/java/iped/engine/task/ParsingTask.java +++ b/iped-engine/src/main/java/iped/engine/task/ParsingTask.java @@ -321,6 +321,10 @@ public void process(IItem evidence) throws Exception { String parserName = getParserName(parser, evidence.getMetadata().get(Metadata.CONTENT_TYPE)); long st = task == null ? 0 : task.subitemsTime; long diff = System.nanoTime() / 1000 - start; + if (diff < st) { + LOGGER.warn("{} Negative Parsing Time: {} {} Diff={} SubItemsTime={}", + Thread.currentThread().getName(), evidence.getPath(), parserName, diff, st); + } synchronized (timesPerParser) { timesPerParser.merge(parserName, diff - st, Long::sum); } @@ -685,6 +689,7 @@ public void parseEmbedded(InputStream inputStream, ContentHandler handler, Metad if (reader.setTimeoutPaused(true)) { long start = System.nanoTime() / 1000; try { + ProcessTime time = ProcessTime.AUTO; worker.processNewItem(subItem, time); From 0725205b35041087e4fe84ec96ddda3b912868a2 Mon Sep 17 00:00:00 2001 From: tc-wleite Date: Sun, 29 Oct 2023 14:47:41 -0300 Subject: [PATCH 07/12] '#1950: Get minItemSizeToFragment during initialization. --- .../src/main/java/iped/engine/task/ParsingTask.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/iped-engine/src/main/java/iped/engine/task/ParsingTask.java b/iped-engine/src/main/java/iped/engine/task/ParsingTask.java index bc75e48491..b912c06d47 100644 --- a/iped-engine/src/main/java/iped/engine/task/ParsingTask.java +++ b/iped-engine/src/main/java/iped/engine/task/ParsingTask.java @@ -172,6 +172,7 @@ public class ParsingTask extends ThumbTask implements EmbeddedDocumentExtractor private Map idToItemMap = new HashMap<>(); private int numSubitems = 0; private StandardParser autoParser; + private long minItemSizeToFragment; private static Set getTypesToCheckZipbomb() { HashSet set = new HashSet<>(); @@ -304,12 +305,9 @@ public void process(IItem evidence) throws Exception { return; } - SplitLargeBinaryConfig splitConfig = ConfigurationManager.get() - .findObject(SplitLargeBinaryConfig.class); if (((Item) evidence).getTextCache() == null - && ((evidence.getLength() == null || evidence.getLength() < splitConfig.getMinItemSizeToFragment()) - || StandardParser.isSpecificParser(parser))) { - + && ((evidence.getLength() == null || evidence.getLength() < minItemSizeToFragment) + || StandardParser.isSpecificParser(parser))) { ParsingTask task = null; try { task = new ParsingTask(worker, autoParser); @@ -778,6 +776,9 @@ public void init(ConfigurationManager configurationManager) { parsingConfig = configurationManager.findObject(ParsingTaskConfig.class); expandConfig = configurationManager.findObject(CategoryToExpandConfig.class); + SplitLargeBinaryConfig splitConfig = configurationManager.findObject(SplitLargeBinaryConfig.class); + minItemSizeToFragment = splitConfig.getMinItemSizeToFragment(); + setupParsingOptions(configurationManager); this.autoParser = new StandardParser(); From 9f4dc9321b339320c1237286661ef13f73e72c61 Mon Sep 17 00:00:00 2001 From: tc-wleite Date: Sun, 29 Oct 2023 16:04:34 -0300 Subject: [PATCH 08/12] '#1950: Format times per task in processing log. --- .../java/iped/engine/core/Statistics.java | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/iped-engine/src/main/java/iped/engine/core/Statistics.java b/iped-engine/src/main/java/iped/engine/core/Statistics.java index c953294e36..801240c9c6 100644 --- a/iped-engine/src/main/java/iped/engine/core/Statistics.java +++ b/iped-engine/src/main/java/iped/engine/core/Statistics.java @@ -233,22 +233,37 @@ public void logStatistics(Manager manager) throws Exception { int carvedIgnored = getCorruptCarveIgnored(); int ignored = getIgnored(); + // Processing times per task long totalTime = 0; Worker[] workers = manager.getWorkers(); long[] taskTimes = new long[workers[0].tasks.size()]; for (Worker worker : workers) { for (int i = 0; i < taskTimes.length; i++) { - taskTimes[i] += worker.tasks.get(i).getTaskTime(); - totalTime += worker.tasks.get(i).getTaskTime(); + long t = worker.tasks.get(i).getTaskTime(); + taskTimes[i] += t; + totalTime += t; } } LocalConfig localConfig = ConfigurationManager.get().findObject(LocalConfig.class); totalTime = totalTime / (1000000 * localConfig.getNumThreads()); + StringBuilder sb = new StringBuilder(); + sb.append("Processing Times per Task:\n\n"); + sb.append(String.format("%-30s", "TASK")); + sb.append(String.format(" %7s", "TIME(s)")); + sb.append(String.format(" %6s", "PCT(%)")); + sb.append("\n"); + sb.append(String.format("%-30s", "").replace(' ', '=')); + sb.append(" ").append(String.format("%7s", "").replace(' ', '=')); + sb.append(" ").append(String.format("%6s", "").replace(' ', '=')); + sb.append("\n"); for (int i = 0; i < taskTimes.length; i++) { long sec = taskTimes[i] / (1000000 * localConfig.getNumThreads()); - LOGGER.info(workers[0].tasks.get(i).getName() + ":\tProcessing Time:\t" + sec + "s (" //$NON-NLS-1$ //$NON-NLS-2$ - + Math.round((100f * sec) / totalTime) + "%)"); //$NON-NLS-1$ + sb.append(String.format("%-30s", workers[0].tasks.get(i).getName())); + sb.append(String.format(" %7d", sec)); + sb.append(String.format(" %6d", Math.round((100f * sec) / totalTime))); + sb.append("\n"); } + LOGGER.info(sb.toString()); int numDocs; try (IndexReader reader = DirectoryReader.open(ConfiguredFSDirectory.open(indexDir))) { From 84997cc33cd096e96470589e178820e622372bf0 Mon Sep 17 00:00:00 2001 From: tc-wleite Date: Sun, 29 Oct 2023 16:20:23 -0300 Subject: [PATCH 09/12] '#1950: Log processing times per parser. --- .../java/iped/engine/core/Statistics.java | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/iped-engine/src/main/java/iped/engine/core/Statistics.java b/iped-engine/src/main/java/iped/engine/core/Statistics.java index 801240c9c6..967935e1aa 100644 --- a/iped-engine/src/main/java/iped/engine/core/Statistics.java +++ b/iped-engine/src/main/java/iped/engine/core/Statistics.java @@ -10,6 +10,7 @@ import java.lang.management.RuntimeMXBean; import java.util.Date; import java.util.HashMap; +import java.util.TreeMap; import java.util.concurrent.atomic.AtomicInteger; import javax.swing.JOptionPane; @@ -34,6 +35,7 @@ import iped.engine.localization.Messages; import iped.engine.lucene.ConfiguredFSDirectory; import iped.engine.task.ExportFileTask; +import iped.engine.task.ParsingTask; import iped.engine.task.carver.BaseCarveTask; import iped.engine.task.index.IndexItem; import iped.engine.util.Util; @@ -265,6 +267,37 @@ public void logStatistics(Manager manager) throws Exception { } LOGGER.info(sb.toString()); + // Processing times per parser + TreeMap timesPerParser = new TreeMap(); + ParsingTask.copyTimesPerParser(timesPerParser); + if (!timesPerParser.isEmpty()) { + totalTime = 0; + for (long parserTime : timesPerParser.values()) { + totalTime += parserTime; + } + if (totalTime < 1) + totalTime = 1; + sb = new StringBuilder(); + sb.append("Processing Times per Parser:\n\n"); + sb.append(String.format("%-30s", "PARSER")); + sb.append(String.format(" %7s", "TIME(s)")); + sb.append(String.format(" %6s", "PCT(%)")); + sb.append("\n"); + sb.append(String.format("%-30s", "").replace(' ', '=')); + sb.append(" ").append(String.format("%7s", "").replace(' ', '=')); + sb.append(" ").append(String.format("%6s", "").replace(' ', '=')); + sb.append("\n"); + for (String parserName : timesPerParser.keySet()) { + long time = timesPerParser.get(parserName); + long sec = time / (1000000 * workers.length); + sb.append(String.format("%-30s", parserName)); + sb.append(String.format(" %7d", sec)); + sb.append(String.format(" %6d", Math.round(100.0 * time / totalTime))); + sb.append("\n"); + } + LOGGER.info(sb.toString()); + } + int numDocs; try (IndexReader reader = DirectoryReader.open(ConfiguredFSDirectory.open(indexDir))) { numDocs = reader.numDocs(); From 84f2f43c8f2e2352fa697735e405bfdfd99f15cb Mon Sep 17 00:00:00 2001 From: tc-wleite Date: Sun, 29 Oct 2023 16:33:11 -0300 Subject: [PATCH 10/12] '#1950: No need for using SortedMap. --- .../src/main/java/iped/app/processing/ui/ProgressFrame.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/iped-app/src/main/java/iped/app/processing/ui/ProgressFrame.java b/iped-app/src/main/java/iped/app/processing/ui/ProgressFrame.java index 59146c9a2e..aa72feafa0 100644 --- a/iped-app/src/main/java/iped/app/processing/ui/ProgressFrame.java +++ b/iped-app/src/main/java/iped/app/processing/ui/ProgressFrame.java @@ -40,7 +40,6 @@ import java.util.Date; import java.util.HashMap; import java.util.Map; -import java.util.SortedMap; import java.util.TreeMap; import javax.swing.BorderFactory; @@ -93,7 +92,7 @@ public class ProgressFrame extends JFrame implements PropertyChangeListener, Act private boolean paused = false; private String decodingDir = null; private long physicalMemory; - private static final SortedMap timesPerParser = new TreeMap(); + private static final Map timesPerParser = new TreeMap(); private static class RestrictedSizeLabel extends JLabel { From 17636d16dd8eda6a8d632ad650bf09d38b1dd0bf Mon Sep 17 00:00:00 2001 From: Luis Nassif Date: Sat, 28 Oct 2023 16:47:47 -0300 Subject: [PATCH 11/12] 'fix #1955: fix race condition that might cause FileNotFounfException --- .../src/main/java/iped/engine/io/ZIPInputStreamFactory.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/iped-engine/src/main/java/iped/engine/io/ZIPInputStreamFactory.java b/iped-engine/src/main/java/iped/engine/io/ZIPInputStreamFactory.java index 76a130dcbf..27b33eb156 100644 --- a/iped-engine/src/main/java/iped/engine/io/ZIPInputStreamFactory.java +++ b/iped-engine/src/main/java/iped/engine/io/ZIPInputStreamFactory.java @@ -158,9 +158,9 @@ public SeekableInputStream getSeekableInputStream(String path) throws IOExceptio } synchronized (filesCache) { tmp = filesCache.get(path); - } - if (tmp != null) { - return new SeekableFileInputStream(tmp.toFile()); + if (tmp != null) { + return new SeekableFileInputStream(tmp.toFile()); + } } ZipArchiveEntry zae; From f9dd52bbcf73130b4df5ddee1076eeb43eebcf0d Mon Sep 17 00:00:00 2001 From: Luis Nassif Date: Sun, 29 Oct 2023 19:48:33 -0300 Subject: [PATCH 12/12] '#1950: minor change to follow previous log alignment --- .../java/iped/engine/core/Statistics.java | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/iped-engine/src/main/java/iped/engine/core/Statistics.java b/iped-engine/src/main/java/iped/engine/core/Statistics.java index 967935e1aa..33cea61f65 100644 --- a/iped-engine/src/main/java/iped/engine/core/Statistics.java +++ b/iped-engine/src/main/java/iped/engine/core/Statistics.java @@ -248,24 +248,26 @@ public void logStatistics(Manager manager) throws Exception { } LocalConfig localConfig = ConfigurationManager.get().findObject(LocalConfig.class); totalTime = totalTime / (1000000 * localConfig.getNumThreads()); + LOGGER.info("Processing Times per Task:"); StringBuilder sb = new StringBuilder(); - sb.append("Processing Times per Task:\n\n"); sb.append(String.format("%-30s", "TASK")); sb.append(String.format(" %7s", "TIME(s)")); sb.append(String.format(" %6s", "PCT(%)")); - sb.append("\n"); + LOGGER.info(sb.toString()); + sb.setLength(0); sb.append(String.format("%-30s", "").replace(' ', '=')); sb.append(" ").append(String.format("%7s", "").replace(' ', '=')); sb.append(" ").append(String.format("%6s", "").replace(' ', '=')); - sb.append("\n"); + LOGGER.info(sb.toString()); + sb.setLength(0); for (int i = 0; i < taskTimes.length; i++) { long sec = taskTimes[i] / (1000000 * localConfig.getNumThreads()); sb.append(String.format("%-30s", workers[0].tasks.get(i).getName())); sb.append(String.format(" %7d", sec)); sb.append(String.format(" %6d", Math.round((100f * sec) / totalTime))); - sb.append("\n"); + LOGGER.info(sb.toString()); + sb.setLength(0); } - LOGGER.info(sb.toString()); // Processing times per parser TreeMap timesPerParser = new TreeMap(); @@ -278,24 +280,26 @@ public void logStatistics(Manager manager) throws Exception { if (totalTime < 1) totalTime = 1; sb = new StringBuilder(); - sb.append("Processing Times per Parser:\n\n"); + LOGGER.info("Processing Times per Parser:"); sb.append(String.format("%-30s", "PARSER")); sb.append(String.format(" %7s", "TIME(s)")); sb.append(String.format(" %6s", "PCT(%)")); - sb.append("\n"); + LOGGER.info(sb.toString()); + sb.setLength(0); sb.append(String.format("%-30s", "").replace(' ', '=')); sb.append(" ").append(String.format("%7s", "").replace(' ', '=')); sb.append(" ").append(String.format("%6s", "").replace(' ', '=')); - sb.append("\n"); + LOGGER.info(sb.toString()); + sb.setLength(0); for (String parserName : timesPerParser.keySet()) { long time = timesPerParser.get(parserName); long sec = time / (1000000 * workers.length); sb.append(String.format("%-30s", parserName)); sb.append(String.format(" %7d", sec)); sb.append(String.format(" %6d", Math.round(100.0 * time / totalTime))); - sb.append("\n"); + LOGGER.info(sb.toString()); + sb.setLength(0); } - LOGGER.info(sb.toString()); } int numDocs;