From 5896c595e7590d4e4b65185d290f68231bde8708 Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Thu, 25 Aug 2022 19:09:14 +0000 Subject: [PATCH] sonar issues git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1903687 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/poi/openxml4j/opc/OPCPackage.java | 2 +- .../apache/poi/xssf/streaming/AutoSizeColumnTracker.java | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/OPCPackage.java b/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/OPCPackage.java index 0fc4c624be..4625a940ed 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/OPCPackage.java +++ b/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/OPCPackage.java @@ -282,7 +282,7 @@ public abstract class OPCPackage implements RelationshipSource, Closeable { throw new IllegalArgumentException("file must not be a directory"); } - OPCPackage pack = new ZipPackage(file, access); + OPCPackage pack = new ZipPackage(file, access); //NOSONAR try { if (pack.partList == null && access != PackageAccess.WRITE) { pack.getParts(); diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/AutoSizeColumnTracker.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/AutoSizeColumnTracker.java index 82359fe80b..9df140d414 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/AutoSizeColumnTracker.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/AutoSizeColumnTracker.java @@ -234,7 +234,11 @@ import org.apache.poi.util.Internal; public boolean untrackColumns(Collection columns) { untrackedColumns.addAll(columns); - return maxColumnWidths.keySet().removeAll(columns); + boolean result = false; + for (Integer col : columns) { + result = maxColumnWidths.remove(col) != null || result; + } + return result; } /** @@ -248,7 +252,7 @@ import org.apache.poi.util.Internal; */ public boolean untrackColumn(int column) { untrackedColumns.add(column); - return maxColumnWidths.keySet().remove(column); + return maxColumnWidths.remove(column) != null; } /**