From: Andreas Beeker Date: Thu, 24 Sep 2015 05:51:38 +0000 (+0000) Subject: fixed some wrong nightly assumptions ... (Note to myself, don't rely on ant automatic... X-Git-Tag: REL_3_14_BETA1~291 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=8541049ee81b88174aaa30c1aebaf0580d96f6f7;p=poi.git fixed some wrong nightly assumptions ... (Note to myself, don't rely on ant automatic file change detection, but run ant clean before ...) git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1704999 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/poi/ddf/EscherBSERecord.java b/src/java/org/apache/poi/ddf/EscherBSERecord.java index 496feb6fca..7c69189379 100644 --- a/src/java/org/apache/poi/ddf/EscherBSERecord.java +++ b/src/java/org/apache/poi/ddf/EscherBSERecord.java @@ -43,7 +43,7 @@ public final class EscherBSERecord extends EscherRecord { private byte field_1_blipTypeWin32; private byte field_2_blipTypeMacOS; - private byte[] field_3_uid; // 16 bytes + private final byte[] field_3_uid = new byte[16]; private short field_4_tag; private int field_5_size; private int field_6_ref; @@ -54,14 +54,13 @@ public final class EscherBSERecord extends EscherRecord { private byte field_11_unused3; private EscherBlipRecord field_12_blipRecord; - private byte[] _remainingData; + private byte[] _remainingData = new byte[0]; public int fillFields(byte[] data, int offset, EscherRecordFactory recordFactory) { int bytesRemaining = readHeader( data, offset ); int pos = offset + 8; field_1_blipTypeWin32 = data[pos]; field_2_blipTypeMacOS = data[pos + 1]; - field_3_uid = new byte[16]; System.arraycopy( data, pos + 2, field_3_uid, 0, 16 ); field_4_tag = LittleEndian.getShort( data, pos + 18 ); field_5_size = LittleEndian.getInt( data, pos + 20 ); @@ -183,9 +182,10 @@ public final class EscherBSERecord extends EscherRecord { * 16 byte MD4 checksum. */ public void setUid(byte[] uid) { - if (uid != null && uid.length == 16) { - System.arraycopy(uid, 0, field_3_uid, 0, field_3_uid.length); - }; + if (uid == null || uid.length != 16) { + throw new IllegalArgumentException("uid must be byte[16]"); + } + System.arraycopy(uid, 0, field_3_uid, 0, field_3_uid.length); } /** @@ -308,7 +308,7 @@ public final class EscherBSERecord extends EscherRecord { */ public void setRemainingData(byte[] remainingData) { if (remainingData == null) { - _remainingData = null; + _remainingData = new byte[0]; } else { _remainingData = remainingData.clone(); } diff --git a/src/java/org/apache/poi/ddf/EscherBitmapBlip.java b/src/java/org/apache/poi/ddf/EscherBitmapBlip.java index e6855d1987..43e8ba516a 100644 --- a/src/java/org/apache/poi/ddf/EscherBitmapBlip.java +++ b/src/java/org/apache/poi/ddf/EscherBitmapBlip.java @@ -30,14 +30,13 @@ public class EscherBitmapBlip extends EscherBlipRecord { private static final int HEADER_SIZE = 8; - private byte[] field_1_UID; + private final byte[] field_1_UID = new byte[16]; private byte field_2_marker = (byte) 0xFF; public int fillFields(byte[] data, int offset, EscherRecordFactory recordFactory) { int bytesAfterHeader = readHeader( data, offset ); int pos = offset + HEADER_SIZE; - field_1_UID = new byte[16]; System.arraycopy( data, pos, field_1_UID, 0, 16 ); pos += 16; field_2_marker = data[pos]; pos++; @@ -75,9 +74,10 @@ public class EscherBitmapBlip extends EscherBlipRecord { } public void setUID( byte[] field_1_UID ) { - if (field_1_UID != null && field_1_UID.length == 16) { - System.arraycopy(field_1_UID, 0, this.field_1_UID , 0, 16); + if (field_1_UID == null || field_1_UID.length != 16) { + throw new IllegalArgumentException("field_1_UID must be byte[16]"); } + System.arraycopy(field_1_UID, 0, this.field_1_UID , 0, 16); } public byte getMarker() diff --git a/src/java/org/apache/poi/ddf/EscherBlipRecord.java b/src/java/org/apache/poi/ddf/EscherBlipRecord.java index 43c0661ef6..005cf25fcd 100644 --- a/src/java/org/apache/poi/ddf/EscherBlipRecord.java +++ b/src/java/org/apache/poi/ddf/EscherBlipRecord.java @@ -71,10 +71,9 @@ public class EscherBlipRecord extends EscherRecord { // TODO - instantiable supe public void setPictureData(byte[] pictureData) { if (pictureData == null) { - field_pictureData = null; - } else { - field_pictureData = pictureData.clone(); + throw new NullPointerException("picture data can't be null"); } + field_pictureData = pictureData.clone(); } public String toString() { diff --git a/src/java/org/apache/poi/ddf/EscherClientAnchorRecord.java b/src/java/org/apache/poi/ddf/EscherClientAnchorRecord.java index 4185d63979..d39601b964 100644 --- a/src/java/org/apache/poi/ddf/EscherClientAnchorRecord.java +++ b/src/java/org/apache/poi/ddf/EscherClientAnchorRecord.java @@ -52,7 +52,7 @@ public class EscherClientAnchorRecord private short field_7_dx2; private short field_8_row2; private short field_9_dy2; - private byte[] remainingData; + private byte[] remainingData = new byte[0]; private boolean shortRecord = false; public int fillFields(byte[] data, int offset, EscherRecordFactory recordFactory) { @@ -335,7 +335,7 @@ public class EscherClientAnchorRecord */ public void setRemainingData( byte[] remainingData ) { if (remainingData == null) { - this.remainingData = null; + this.remainingData = new byte[0]; } else { this.remainingData = remainingData.clone(); }