This is an automated email from the ASF dual-hosted git repository. snagel pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nutch.git
The following commit(s) were added to refs/heads/master by this push: new 96bd757 NUTCH-2823 IllegalStateException in IndexWriters.describe() when validating url param for SolrIndexer new 0b46ac2 Merge pull request #551 from sebastian-nagel/NUTCH-2823 96bd757 is described below commit 96bd7577b7276c91f01e6b226742805b481151b4 Author: Sebastian Nagel <sna...@apache.org> AuthorDate: Mon Aug 17 16:54:42 2020 +0200 NUTCH-2823 IllegalStateException in IndexWriters.describe() when validating url param for SolrIndexer - when calculating required column width for first (param names) and third column (param values): verify that none of these columns occupy more than one third of the table width, otherwise reset width to 1/3 --- .../org/apache/nutch/indexer/IndexWriters.java | 33 +++++++++++----------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/src/java/org/apache/nutch/indexer/IndexWriters.java b/src/java/org/apache/nutch/indexer/IndexWriters.java index 5778997..04cc70a 100644 --- a/src/java/org/apache/nutch/indexer/IndexWriters.java +++ b/src/java/org/apache/nutch/indexer/IndexWriters.java @@ -286,26 +286,27 @@ public class IndexWriters { // Building the table AsciiTable at = new AsciiTable(); at.getRenderer().setCWC((rows, colNumbers, tableWidth) -> { + /* + * first and third column (configuration param names and values) usually + * require less width than the second column which contains the + * description + */ int maxLengthFirstColumn = 0; - int maxLengthLastColumn = 0; + int maxLengthThirdColumn = 0; for (AT_Row row : rows) { if (row.getType() == TableRowType.CONTENT) { - // First column - int lengthFirstColumn = row.getCells().get(0).toString().length(); - if (lengthFirstColumn > maxLengthFirstColumn) { - maxLengthFirstColumn = lengthFirstColumn; - } - - // Last column - int lengthLastColumn = row.getCells().get(2).toString().length(); - if (lengthLastColumn > maxLengthLastColumn) { - maxLengthLastColumn = lengthLastColumn; - } + maxLengthFirstColumn = Math.max(row.getCells().get(0).toString().length(), maxLengthFirstColumn); + maxLengthThirdColumn = Math.max(row.getCells().get(2).toString().length(), maxLengthThirdColumn); } } - return new int[] { maxLengthFirstColumn, - tableWidth - maxLengthFirstColumn - maxLengthLastColumn, - maxLengthLastColumn }; + // reset max. lengths if exceeding one third of the table width + maxLengthFirstColumn = Math.min((tableWidth / 3), maxLengthFirstColumn); + maxLengthThirdColumn = Math.min( + ((tableWidth - maxLengthFirstColumn) / 2), maxLengthThirdColumn); + int widthSecondColumn = tableWidth - maxLengthFirstColumn + - maxLengthThirdColumn; + return new int[] { maxLengthFirstColumn, widthSecondColumn, + maxLengthThirdColumn }; }); // Getting the properties @@ -323,7 +324,7 @@ public class IndexWriters { at.addRule(); // Rendering the table - builder.append(at.render(150)).append("\n\n"); + builder.append(at.render(120)).append("\n\n"); } return builder.toString();