aboutsummaryrefslogtreecommitdiffstats
path: root/poi
diff options
context:
space:
mode:
authorPJ Fanning <fanningpj@apache.org>2022-09-13 23:38:12 +0000
committerPJ Fanning <fanningpj@apache.org>2022-09-13 23:38:12 +0000
commit34601b5377387e293868937bfa8f7e4cb4d45573 (patch)
tree0808a35acf7ae70b156ae104fce3608f6fa90901 /poi
parente694cf4d534bb09d2a706f390db49e6e779dfa2b (diff)
downloadpoi-34601b5377387e293868937bfa8f7e4cb4d45573.tar.gz
poi-34601b5377387e293868937bfa8f7e4cb4d45573.zip
some lgtm issues
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1904048 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi')
-rw-r--r--poi/src/main/java/org/apache/poi/hssf/util/HSSFColor.java4
-rw-r--r--poi/src/main/java/org/apache/poi/ss/util/CellUtil.java2
-rw-r--r--poi/src/main/java/org/apache/poi/util/IOUtils.java36
3 files changed, 21 insertions, 21 deletions
diff --git a/poi/src/main/java/org/apache/poi/hssf/util/HSSFColor.java b/poi/src/main/java/org/apache/poi/hssf/util/HSSFColor.java
index 1d791102aa..263a7c0da9 100644
--- a/poi/src/main/java/org/apache/poi/hssf/util/HSSFColor.java
+++ b/poi/src/main/java/org/apache/poi/hssf/util/HSSFColor.java
@@ -190,11 +190,11 @@ public class HSSFColor implements Color {
Map<Integer,HSSFColor> result = new HashMap<>(eList.size() * 3 / 2);
for (Map.Entry<HSSFColorPredefined,HSSFColor> colorRef : eList.entrySet()) {
- Integer index1 = (int)colorRef.getKey().getIndex();
+ Integer index1 = Integer.valueOf(colorRef.getKey().getIndex());
if (!result.containsKey(index1)) {
result.put(index1, colorRef.getValue());
}
- Integer index2 = (int)colorRef.getKey().getIndex2();
+ Integer index2 = Integer.valueOf(colorRef.getKey().getIndex2());
if (index2 != -1 && !result.containsKey(index2)) {
result.put(index2, colorRef.getValue());
}
diff --git a/poi/src/main/java/org/apache/poi/ss/util/CellUtil.java b/poi/src/main/java/org/apache/poi/ss/util/CellUtil.java
index 0ba1123161..43f2be2600 100644
--- a/poi/src/main/java/org/apache/poi/ss/util/CellUtil.java
+++ b/poi/src/main/java/org/apache/poi/ss/util/CellUtil.java
@@ -258,7 +258,7 @@ public final class CellUtil {
}
// Copy CellStyle
- if (policy.isCopyCellStyle()) {
+ if (policy.isCopyCellStyle() && srcCell != null) {
if (srcCell.getSheet() != null && destCell.getSheet() != null &&
destCell.getSheet().getWorkbook() == srcCell.getSheet().getWorkbook()) {
destCell.setCellStyle(srcCell.getCellStyle());
diff --git a/poi/src/main/java/org/apache/poi/util/IOUtils.java b/poi/src/main/java/org/apache/poi/util/IOUtils.java
index 8d80c7b7d8..66fec9473c 100644
--- a/poi/src/main/java/org/apache/poi/util/IOUtils.java
+++ b/poi/src/main/java/org/apache/poi/util/IOUtils.java
@@ -136,26 +136,26 @@ public final class IOUtils {
checkByteSizeLimit(limit);
stream.mark(limit);
- UnsynchronizedByteArrayOutputStream bos = new UnsynchronizedByteArrayOutputStream(limit);
- copy(new BoundedInputStream(stream, limit), bos);
+ try (UnsynchronizedByteArrayOutputStream bos = new UnsynchronizedByteArrayOutputStream(limit)) {
+ copy(new BoundedInputStream(stream, limit), bos);
- int readBytes = bos.size();
- if (readBytes == 0) {
- throw new EmptyFileException();
- }
+ int readBytes = bos.size();
+ if (readBytes == 0) {
+ throw new EmptyFileException();
+ }
- if (readBytes < limit) {
- bos.write(new byte[limit-readBytes]);
- }
- byte[] peekedBytes = bos.toByteArray();
- if(stream instanceof PushbackInputStream) {
- PushbackInputStream pin = (PushbackInputStream)stream;
- pin.unread(peekedBytes, 0, readBytes);
- } else {
- stream.reset();
+ if (readBytes < limit) {
+ bos.write(new byte[limit-readBytes]);
+ }
+ byte[] peekedBytes = bos.toByteArray();
+ if(stream instanceof PushbackInputStream) {
+ PushbackInputStream pin = (PushbackInputStream)stream;
+ pin.unread(peekedBytes, 0, readBytes);
+ } else {
+ stream.reset();
+ }
+ return peekedBytes;
}
-
- return peekedBytes;
}
/**
@@ -522,7 +522,7 @@ public final class IOUtils {
}
/*
* N.B. no need to synchronize this because: - we don't care if the buffer is created multiple times (the data
- * is ignored) - we always use the same size buffer, so if it it is recreated it will still be OK (if the buffer
+ * is ignored) - we always use the same size buffer, so if it is recreated it will still be OK (if the buffer
* size were variable, we would need to synch. to ensure some other thread did not create a smaller one)
*/
if (SKIP_BYTE_BUFFER == null) {