Skip to content

Commit

Permalink
Cleanup RestProxy code (#43503)
Browse files Browse the repository at this point in the history
  • Loading branch information
alzimmermsft authored Dec 20, 2024
1 parent e0e27c4 commit 6c1394d
Show file tree
Hide file tree
Showing 6 changed files with 436 additions and 523 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,10 @@
import java.io.InputStream;
import java.util.Objects;

import static io.clientcore.core.implementation.http.rest.RestProxyUtils.bodyTooLarge;
import static io.clientcore.core.implementation.http.rest.RestProxyUtils.bodyTooSmall;

/**
* An {@link InputStream} decorator that tracks the number of bytes read from an inner {@link InputStream} and throws
* an exception if the number of bytes read doesn't match what was expected.
*
* <p>
* This implementation assumes that reader is going to read until EOF.
*/
final class LengthValidatingInputStream extends InputStream {
Expand Down Expand Up @@ -112,9 +109,9 @@ private void validateLength(int readSize) {
if (readSize == -1) {
// If the inner InputStream has reached termination validate that the read bytes matches what was expected.
if (position > expectedReadSize) {
throw new IllegalStateException(bodyTooLarge(position, expectedReadSize));
throw new IllegalStateException(RestProxyImpl.bodyTooLarge(position, expectedReadSize));
} else if (position < expectedReadSize) {
throw new IllegalStateException(bodyTooSmall(position, expectedReadSize));
throw new IllegalStateException(RestProxyImpl.bodyTooSmall(position, expectedReadSize));
}
} else {
position += readSize;
Expand Down

This file was deleted.

Loading

0 comments on commit 6c1394d

Please sign in to comment.