mirror of https://github.com/apache/poi.git
fix issue in IOUtils.toByteArrayWithMaxLength
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1898861 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e7f9cd277d
commit
f4bfcaeec9
|
@ -92,13 +92,11 @@ public class XWPFChart extends XDDFChart {
|
||||||
|
|
||||||
public Long getChecksum() {
|
public Long getChecksum() {
|
||||||
if (this.checksum == null) {
|
if (this.checksum == null) {
|
||||||
byte[] data;
|
|
||||||
try (InputStream is = getPackagePart().getInputStream()) {
|
try (InputStream is = getPackagePart().getInputStream()) {
|
||||||
data = IOUtils.toByteArrayWithMaxLength(is, XWPFPictureData.getMaxImageSize());
|
this.checksum = IOUtils.calculateChecksum(is);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new POIXMLException(e);
|
throw new POIXMLException(e);
|
||||||
}
|
}
|
||||||
this.checksum = IOUtils.calculateChecksum(data);
|
|
||||||
}
|
}
|
||||||
return this.checksum;
|
return this.checksum;
|
||||||
}
|
}
|
||||||
|
|
|
@ -163,13 +163,11 @@ public class XWPFPictureData extends POIXMLDocumentPart {
|
||||||
|
|
||||||
public Long getChecksum() {
|
public Long getChecksum() {
|
||||||
if (this.checksum == null) {
|
if (this.checksum == null) {
|
||||||
byte[] data;
|
|
||||||
try (InputStream is = getPackagePart().getInputStream()) {
|
try (InputStream is = getPackagePart().getInputStream()) {
|
||||||
data = IOUtils.toByteArrayWithMaxLength(is, getMaxImageSize());
|
this.checksum = IOUtils.calculateChecksum(is);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new POIXMLException(e);
|
throw new POIXMLException(e);
|
||||||
}
|
}
|
||||||
this.checksum = IOUtils.calculateChecksum(data);
|
|
||||||
}
|
}
|
||||||
return this.checksum;
|
return this.checksum;
|
||||||
}
|
}
|
||||||
|
|
|
@ -202,7 +202,7 @@ public final class IOUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
final int derivedLen = Math.min(length, derivedMaxLength);
|
final int derivedLen = Math.min(length, derivedMaxLength);
|
||||||
final int bufferLen = isLengthKnown ? derivedLen : 4096;
|
final int bufferLen = isLengthKnown ? derivedLen : Math.min(4096, derivedLen);
|
||||||
try (UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream(bufferLen)) {
|
try (UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream(bufferLen)) {
|
||||||
byte[] buffer = new byte[4096];
|
byte[] buffer = new byte[4096];
|
||||||
int totalBytes = 0, readBytes;
|
int totalBytes = 0, readBytes;
|
||||||
|
|
Loading…
Reference in New Issue