From 70faecb8b526f72094f5284cd42e3a636e013128 Mon Sep 17 00:00:00 2001 From: jrandom Date: Tue, 27 Apr 2004 08:33:15 +0000 Subject: [PATCH] handle the UnsignedInteger's new "IllegalArgumentException on negative" policy --- core/java/src/net/i2p/data/DataHelper.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/core/java/src/net/i2p/data/DataHelper.java b/core/java/src/net/i2p/data/DataHelper.java index 8a13ebb09..ff0cb4168 100644 --- a/core/java/src/net/i2p/data/DataHelper.java +++ b/core/java/src/net/i2p/data/DataHelper.java @@ -221,8 +221,12 @@ public class DataHelper { */ public static void writeLong(OutputStream rawStream, int numBytes, long value) throws DataFormatException, IOException { - UnsignedInteger i = new UnsignedInteger(value); - rawStream.write(i.getBytes(numBytes)); + try { + UnsignedInteger i = new UnsignedInteger(value); + rawStream.write(i.getBytes(numBytes)); + } catch (IllegalArgumentException iae) { + throw new DataFormatException("Invalid value (must be positive)", iae); + } } /** Read in a date from the stream as specified by the I2P data structure spec.