@@ -34,7 +34,7 @@ public class ReadLimitedInputStream extends InputStream {
3434
3535 private int bytesRead ;
3636
37- private Function <Integer , HTTPProcessingException > exceptionMessageFunction ;
37+ private Function <Integer , HTTPProcessingException > exceptionFunction ;
3838
3939 private int maximumBytesToRead = -1 ;
4040
@@ -62,7 +62,7 @@ public int read(byte[] b, int off, int len) throws IOException {
6262 bytesRead += read ;
6363
6464 if (bytesRead > maximumBytesToRead ) {
65- throw exceptionMessageFunction .apply (maximumBytesToRead );
65+ throw exceptionFunction .apply (maximumBytesToRead );
6666 }
6767
6868 return read ;
@@ -79,13 +79,14 @@ public int read() throws IOException {
7979 }
8080
8181 public void setMaximumBytesToRead (Long expectedLength , int maximumBytesToRead ,
82- Function <Integer , HTTPProcessingException > exceptionMessageFunction ) {
83- Objects .requireNonNull (exceptionMessageFunction );
82+ Function <Integer , HTTPProcessingException > exceptionFunction ) {
83+ Objects .requireNonNull (exceptionFunction );
84+ this .bytesRead = 0 ;
8485 this .maximumBytesToRead = maximumBytesToRead ;
85- this .exceptionMessageFunction = exceptionMessageFunction ;
86+ this .exceptionFunction = exceptionFunction ;
8687
8788 if (expectedLength != null && expectedLength > maximumBytesToRead ) {
88- throw exceptionMessageFunction .apply (maximumBytesToRead );
89+ throw exceptionFunction .apply (maximumBytesToRead );
8990 }
9091 }
9192}
0 commit comments