@@ -14,7 +14,7 @@ public class Zstd {
14
14
15
15
/**
16
16
* Note: This enum controls features which are conditionally beneficial.
17
- * Zstd typically will make a final decision on whether or not to enable the
17
+ * Zstd typically will make a final decision on whether to enable the
18
18
* feature ({@link AUTO}), but setting the switch to {@link ENABLE} or
19
19
* {@link DISABLE} allows for force enabling/disabling the feature.
20
20
*/
@@ -633,7 +633,7 @@ public static long decompressDirectByteBufferFastDict(ByteBuffer dst, int dstOff
633
633
* @param srcPosition offset of the compressed frame inside the src buffer
634
634
* @param srcSize length of the compressed data inside the src buffer
635
635
* @return the number of bytes of the compressed frame
636
- * negative if there is an error decoding the frame header
636
+ * @throws ZstdException if there is an error decoding the frame
637
637
*/
638
638
public static long findFrameCompressedSize (byte [] src , int srcPosition , int srcSize ) {
639
639
if (srcPosition >= src .length ) {
@@ -642,7 +642,13 @@ public static long findFrameCompressedSize(byte[] src, int srcPosition, int srcS
642
642
if (srcPosition + srcSize > src .length ) {
643
643
throw new ArrayIndexOutOfBoundsException (srcPosition + srcSize );
644
644
}
645
- return findFrameCompressedSize0 (src , srcPosition , srcSize );
645
+
646
+ long size = findFrameCompressedSize0 (src , srcPosition , srcSize );
647
+ if (Zstd .isError (size )) {
648
+ throw new ZstdException (size );
649
+ }
650
+
651
+ return size ;
646
652
}
647
653
648
654
private static native long findFrameCompressedSize0 (byte [] src , int srcPosition , int srcSize );
@@ -824,7 +830,7 @@ public static long getFrameContentSize(byte[] src) {
824
830
@ Deprecated
825
831
public static long decompressedSize (byte [] src ) {
826
832
return decompressedSize (src , 0 );
827
- };
833
+ }
828
834
829
835
/**
830
836
* Return the original size of a compressed buffer (if known)
@@ -1684,9 +1690,9 @@ public static int decompress(ByteBuffer dstBuff, ByteBuffer srcBuff, ZstdDictDec
1684
1690
* </p>
1685
1691
* @param dict the dictionary used in the compression
1686
1692
* @param originalSize the maximum size of the uncompressed data
1687
- * @return A newly-allocated ByteBuffer containing the decompressed data. The position() of this buffer will be 0,
1688
- * and the limit() will be the size of the decompressed data. In other words the buffer is ready to be used for
1689
- * reading. Note that this is different behavior from the other decompress() overload which takes as a parameter
1693
+ * @return A newly-allocated ByteBuffer containing the decompressed data. The position() of this buffer will be 0,
1694
+ * and the limit() will be the size of the decompressed data. In other words the buffer is ready to be used for
1695
+ * reading. Note that this is different behavior from the other decompress() overload which takes as a parameter
1690
1696
* the destination ByteBuffer.
1691
1697
*/
1692
1698
public static ByteBuffer decompress (ByteBuffer srcBuff , ZstdDictDecompress dict , int originalSize ) {
0 commit comments