summaryrefslogtreecommitdiff
path: root/src/main/java/com
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com')
-rw-r--r--src/main/java/com/amazon/carbonado/lob/ByteArrayBlob.java28
-rw-r--r--src/main/java/com/amazon/carbonado/lob/CharArrayClob.java28
2 files changed, 34 insertions, 22 deletions
diff --git a/src/main/java/com/amazon/carbonado/lob/ByteArrayBlob.java b/src/main/java/com/amazon/carbonado/lob/ByteArrayBlob.java
index 028f575..9ef522e 100644
--- a/src/main/java/com/amazon/carbonado/lob/ByteArrayBlob.java
+++ b/src/main/java/com/amazon/carbonado/lob/ByteArrayBlob.java
@@ -138,9 +138,12 @@ public class ByteArrayBlob extends AbstractBlob {
length = mLength - ipos;
}
- System.arraycopy(mData, ipos, bytes, 0, length);
-
- return length;
+ if (length > 0) {
+ System.arraycopy(mData, ipos, bytes, 0, length);
+ return length;
+ } else {
+ return -1;
+ }
}
synchronized int read(long pos, byte[] bytes, int offset, int length) {
@@ -170,16 +173,19 @@ public class ByteArrayBlob extends AbstractBlob {
length = mLength - ipos;
}
- try {
- System.arraycopy(mData, ipos, bytes, offset, length);
- } catch (IndexOutOfBoundsException e) {
- if (offset >= bytes.length && length > 0) {
- throw new IllegalArgumentException("Offset is too large: " + offset);
+ if (length > 0) {
+ try {
+ System.arraycopy(mData, ipos, bytes, offset, length);
+ } catch (IndexOutOfBoundsException e) {
+ if (offset >= bytes.length && length > 0) {
+ throw new IllegalArgumentException("Offset is too large: " + offset);
+ }
+ throw e;
}
- throw e;
+ return length;
+ } else {
+ return -1;
}
-
- return length;
}
public OutputStream openOutputStream() {
diff --git a/src/main/java/com/amazon/carbonado/lob/CharArrayClob.java b/src/main/java/com/amazon/carbonado/lob/CharArrayClob.java
index ddba889..369eeaf 100644
--- a/src/main/java/com/amazon/carbonado/lob/CharArrayClob.java
+++ b/src/main/java/com/amazon/carbonado/lob/CharArrayClob.java
@@ -144,9 +144,12 @@ public class CharArrayClob extends AbstractClob {
length = mLength - ipos;
}
- System.arraycopy(mData, ipos, chars, 0, length);
-
- return length;
+ if (length > 0) {
+ System.arraycopy(mData, ipos, chars, 0, length);
+ return length;
+ } else {
+ return -1;
+ }
}
synchronized int read(long pos, char[] chars, int offset, int length) {
@@ -176,16 +179,19 @@ public class CharArrayClob extends AbstractClob {
length = mLength - ipos;
}
- try {
- System.arraycopy(mData, ipos, chars, offset, length);
- } catch (IndexOutOfBoundsException e) {
- if (offset >= chars.length && length > 0) {
- throw new IllegalArgumentException("Offset is too large: " + offset);
+ if (length > 0) {
+ try {
+ System.arraycopy(mData, ipos, chars, offset, length);
+ } catch (IndexOutOfBoundsException e) {
+ if (offset >= chars.length && length > 0) {
+ throw new IllegalArgumentException("Offset is too large: " + offset);
+ }
+ throw e;
}
- throw e;
+ return length;
+ } else {
+ return -1;
}
-
- return length;
}
public Writer openWriter() {