@@ -81,12 +81,14 @@ private static void testRawApi(FuzzedDataProvider data) {
8181 byte [] rawUncompressed = new byte [uncompressedLen ];
8282 Snappy .rawUncompress (rawCompressed , 0 , rawCompressed .length , rawUncompressed , 0 );
8383 } catch (Exception e ) {
84+ throw new RuntimeException (e );
8485 }
8586
8687 try {
8788 Snappy .isValidCompressedBuffer (input );
8889 Snappy .isValidCompressedBuffer (input , 0 , input .length );
8990 } catch (Exception e ) {
91+ throw new RuntimeException (e );
9092 }
9193
9294 try {
@@ -95,27 +97,31 @@ private static void testRawApi(FuzzedDataProvider data) {
9597 throw new IllegalStateException ("maxCompressedLength too small" );
9698 }
9799 } catch (Exception e ) {
100+ throw new RuntimeException (e );
98101 }
99102
100103 try {
101104 byte [] compressed = Snappy .compress (input );
102105 int len = Snappy .uncompressedLength (compressed );
103106 int len2 = Snappy .uncompressedLength (compressed , 0 , compressed .length );
104107 } catch (Exception e ) {
108+ throw new RuntimeException (e );
105109 }
106110
107111 try {
108112 int [] intInput = data .consumeInts (100 );
109113 byte [] compressedInts = Snappy .compress (intInput );
110114 int [] uncompressedInts = Snappy .uncompressIntArray (compressedInts );
111115 } catch (Exception e ) {
116+ throw new RuntimeException (e );
112117 }
113118
114119 try {
115120 long [] longInput = data .consumeLongs (50 );
116121 byte [] compressedLongs = Snappy .compress (longInput );
117122 long [] uncompressedLongs = Snappy .uncompressLongArray (compressedLongs );
118123 } catch (Exception e ) {
124+ throw new RuntimeException (e );
119125 }
120126 }
121127
@@ -149,7 +155,7 @@ private static void testFramed(FuzzedDataProvider data) {
149155 new ByteArrayInputStream (data .consumeBytes (100 )))) {
150156 while (invalidIn .read () != -1 ) {}
151157 } catch (IOException e ) {
152- // Expected, ignore.
158+ throw new RuntimeException ( e );
153159 }
154160 }
155161
@@ -223,7 +229,7 @@ private static void testBlockStream(FuzzedDataProvider data) {
223229 try (SnappyInputStream in = new SnappyInputStream (new ByteArrayInputStream (data .consumeBytes (100 )))) {
224230 while (in .read () != -1 ) {}
225231 } catch (Exception e ) {
226- // Expected, ignore.
232+ throw new RuntimeException ( e );
227233 }
228234 }
229235
@@ -235,11 +241,13 @@ private static void testUtil(FuzzedDataProvider data) {
235241 byte [] compressed = Snappy .compress (str );
236242 String uncompressed = Snappy .uncompressString (compressed );
237243 } catch (Exception e ) {
244+ throw new RuntimeException (e );
238245 }
239246
240247 try {
241248 int maxLen = Snappy .maxCompressedLength (input .length );
242249 } catch (Exception e ) {
250+ throw new RuntimeException (e );
243251 }
244252
245253 try {
@@ -250,6 +258,7 @@ private static void testUtil(FuzzedDataProvider data) {
250258 byte [] compressedShorts = Snappy .compress (shortInput );
251259 short [] uncompressedShorts = Snappy .uncompressShortArray (compressedShorts );
252260 } catch (Exception e ) {
261+ throw new RuntimeException (e );
253262 }
254263
255264 try {
@@ -260,6 +269,7 @@ private static void testUtil(FuzzedDataProvider data) {
260269 byte [] compressedChars = Snappy .compress (charInput );
261270 char [] uncompressedChars = Snappy .uncompressCharArray (compressedChars );
262271 } catch (Exception e ) {
272+ throw new RuntimeException (e );
263273 }
264274 }
265275
@@ -269,20 +279,23 @@ private static void testBitShuffle(FuzzedDataProvider data) {
269279 byte [] shuffled = BitShuffle .shuffle (intInput );
270280 int [] unshuffled = BitShuffle .unshuffleIntArray (shuffled );
271281 } catch (Exception e ) {
282+ throw new RuntimeException (e );
272283 }
273284
274285 try {
275286 long [] longInput = data .consumeLongs (50 );
276287 byte [] shuffled = BitShuffle .shuffle (longInput );
277288 long [] unshuffled = BitShuffle .unshuffleLongArray (shuffled );
278289 } catch (Exception e ) {
290+ throw new RuntimeException (e );
279291 }
280292
281293 try {
282294 short [] shortInput = data .consumeShorts (100 );
283295 byte [] shuffled = BitShuffle .shuffle (shortInput );
284296 short [] unshuffled = BitShuffle .unshuffleShortArray (shuffled );
285297 } catch (Exception e ) {
298+ throw new RuntimeException (e );
286299 }
287300 }
288301
@@ -296,16 +309,17 @@ private static void testHadoopStream(FuzzedDataProvider data) {
296309 out .close ();
297310 byte [] compressed = compressedBuf .toByteArray ();
298311
299- SnappyInputStream in = new SnappyInputStream (
300- new ByteArrayInputStream (compressed ));
301- ByteArrayOutputStream result = new ByteArrayOutputStream ();
302- byte [] buf = new byte [1024 ];
303- int read ;
304- while ((read = in .read (buf )) != -1 ) {
305- result .write (buf , 0 , read );
312+ try (SnappyInputStream in = new SnappyInputStream (
313+ new ByteArrayInputStream (compressed ))) {
314+ ByteArrayOutputStream result = new ByteArrayOutputStream ();
315+ byte [] buf = new byte [1024 ];
316+ int read ;
317+ while ((read = in .read (buf )) != -1 ) {
318+ result .write (buf , 0 , read );
319+ }
306320 }
307- in .close ();
308321 } catch (Exception e ) {
322+ throw new RuntimeException (e );
309323 }
310324 }
311325
@@ -333,6 +347,7 @@ private static void testByteBuffer(FuzzedDataProvider data) {
333347 throw new IllegalStateException ("ByteBuffer compress failed" );
334348 }
335349 } catch (Exception e ) {
350+ throw new RuntimeException (e );
336351 }
337352
338353 try {
@@ -343,6 +358,7 @@ private static void testByteBuffer(FuzzedDataProvider data) {
343358 ByteBuffer directDst = ByteBuffer .allocateDirect (Snappy .maxCompressedLength (input .length ));
344359 Snappy .compress (directSrc , directDst );
345360 } catch (Exception e ) {
361+ throw new RuntimeException (e );
346362 }
347363 }
348364}
0 commit comments