mirror of
https://github.com/msgpack/msgpack-c.git
synced 2025-03-19 13:02:13 +01:00
java: throws MessagePackException if target==null on *ArrayTemplate
This commit is contained in:
parent
aff964c58b
commit
339725f73d
@ -28,7 +28,11 @@ public class BooleanArrayTemplate implements Template {
|
||||
throw new MessageTypeException();
|
||||
}
|
||||
boolean[] array = (boolean[])target;
|
||||
pk.packArray(array.length);
|
||||
try {
|
||||
pk.packArray(array.length);
|
||||
} catch (NullPointerException e) {
|
||||
throw new MessageTypeException("target is null.", e);
|
||||
}
|
||||
for(boolean a : array) {
|
||||
pk.pack(a);
|
||||
}
|
||||
|
@ -24,7 +24,11 @@ public class ByteTemplate implements Template {
|
||||
private ByteTemplate() { }
|
||||
|
||||
public void pack(Packer pk, Object target) throws IOException {
|
||||
pk.packByte((Byte)target);
|
||||
try {
|
||||
pk.packByte((Byte)target);
|
||||
} catch (NullPointerException e) {
|
||||
throw new MessageTypeException("target is null.", e);
|
||||
}
|
||||
}
|
||||
|
||||
public Object unpack(Unpacker pac, Object to) throws IOException, MessageTypeException {
|
||||
|
@ -42,6 +42,9 @@ public class DefaultTemplate implements Template {
|
||||
|
||||
public void pack(Packer pk, Object target) throws IOException {
|
||||
if(messagePackable) {
|
||||
if(target == null) {
|
||||
throw new MessageTypeException("target is null.");
|
||||
}
|
||||
((MessagePackable)target).messagePack(pk);
|
||||
return;
|
||||
}
|
||||
|
@ -28,7 +28,11 @@ public class DoubleArrayTemplate implements Template {
|
||||
throw new MessageTypeException();
|
||||
}
|
||||
double[] array = (double[])target;
|
||||
pk.packArray(array.length);
|
||||
try {
|
||||
pk.packArray(array.length);
|
||||
} catch (NullPointerException e) {
|
||||
throw new MessageTypeException("target is null.", e);
|
||||
}
|
||||
for(double a : array) {
|
||||
pk.pack(a);
|
||||
}
|
||||
|
@ -28,7 +28,11 @@ public class FloatArrayTemplate implements Template {
|
||||
throw new MessageTypeException();
|
||||
}
|
||||
float[] array = (float[])target;
|
||||
pk.packArray(array.length);
|
||||
try {
|
||||
pk.packArray(array.length);
|
||||
} catch (NullPointerException e) {
|
||||
throw new MessageTypeException("target is null.", e);
|
||||
}
|
||||
for(float a : array) {
|
||||
pk.pack(a);
|
||||
}
|
||||
|
@ -28,7 +28,11 @@ public class IntArrayTemplate implements Template {
|
||||
throw new MessageTypeException();
|
||||
}
|
||||
int[] array = (int[])target;
|
||||
pk.packArray(array.length);
|
||||
try {
|
||||
pk.packArray(array.length);
|
||||
} catch (NullPointerException e) {
|
||||
throw new MessageTypeException("target is null.", e);
|
||||
}
|
||||
for(int a : array) {
|
||||
pk.pack(a);
|
||||
}
|
||||
|
@ -28,7 +28,11 @@ public class LongArrayTemplate implements Template {
|
||||
throw new MessageTypeException();
|
||||
}
|
||||
long[] array = (long[])target;
|
||||
pk.packArray(array.length);
|
||||
try {
|
||||
pk.packArray(array.length);
|
||||
} catch (NullPointerException e) {
|
||||
throw new MessageTypeException("target is null.", e);
|
||||
}
|
||||
for(long a : array) {
|
||||
pk.pack(a);
|
||||
}
|
||||
|
@ -28,7 +28,11 @@ public class ShortArrayTemplate implements Template {
|
||||
throw new MessageTypeException();
|
||||
}
|
||||
short[] array = (short[])target;
|
||||
pk.packArray(array.length);
|
||||
try {
|
||||
pk.packArray(array.length);
|
||||
} catch (NullPointerException e) {
|
||||
throw new MessageTypeException("target is null.", e);
|
||||
}
|
||||
for(short a : array) {
|
||||
pk.pack(a);
|
||||
}
|
||||
|
@ -24,7 +24,11 @@ public class ShortTemplate implements Template {
|
||||
private ShortTemplate() { }
|
||||
|
||||
public void pack(Packer pk, Object target) throws IOException {
|
||||
pk.packShort((Short)target);
|
||||
try {
|
||||
pk.packShort((Short)target);
|
||||
} catch (NullPointerException e) {
|
||||
throw new MessageTypeException("target is null.", e);
|
||||
}
|
||||
}
|
||||
|
||||
public Object unpack(Unpacker pac, Object to) throws IOException, MessageTypeException {
|
||||
|
Loading…
x
Reference in New Issue
Block a user