-
Notifications
You must be signed in to change notification settings - Fork 73
MLE-27304 Small cleanup for Polaris #1913
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,13 +1,9 @@ | ||||||
| /* | ||||||
| * Copyright (c) 2010-2025 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved. | ||||||
| * Copyright (c) 2010-2026 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved. | ||||||
| */ | ||||||
| package com.marklogic.client.impl; | ||||||
|
|
||||||
| import java.io.File; | ||||||
| import java.io.InputStream; | ||||||
| import java.io.OutputStream; | ||||||
| import java.io.PrintStream; | ||||||
| import java.io.Reader; | ||||||
| import java.io.*; | ||||||
|
|
||||||
| import org.slf4j.Logger; | ||||||
| import org.slf4j.LoggerFactory; | ||||||
|
|
@@ -117,4 +113,127 @@ public void close() { | |||||
| enabled = false; | ||||||
| } | ||||||
|
|
||||||
| // Moved here in the 8.2 release to make it obvious it's only used by RequestLoggerImpl. It is only used by the | ||||||
| // copyContent method in RequestLoggerImpl. So while Polaris rightfully complains about the thread safety issues of | ||||||
| // this class, it is only used in a single thread context and so the thread safety issues are not a problem. | ||||||
| private static class InputStreamTee extends InputStream { | ||||||
| private InputStream in; | ||||||
| private OutputStream tee; | ||||||
| private long max = 0; | ||||||
| private long sent = 0; | ||||||
|
|
||||||
| public InputStreamTee(InputStream in, OutputStream tee, long max) { | ||||||
| super(); | ||||||
| this.in = in; | ||||||
| this.tee = tee; | ||||||
| this.max = max; | ||||||
| } | ||||||
|
|
||||||
| @Override | ||||||
| public int read() throws IOException { | ||||||
| if (in == null) return -1; | ||||||
|
|
||||||
| if (sent >= max) return in.read(); | ||||||
|
|
||||||
| int b = in.read(); | ||||||
| if (b == -1) { | ||||||
| cleanupTee(); | ||||||
| return b; | ||||||
| } | ||||||
|
|
||||||
| if (max == Long.MAX_VALUE) { | ||||||
| tee.write(b); | ||||||
| return b; | ||||||
| } | ||||||
|
|
||||||
| tee.write(b); | ||||||
|
|
||||||
| sent++; | ||||||
| if (sent == max) cleanupTee(); | ||||||
|
|
||||||
| return b; | ||||||
| } | ||||||
|
|
||||||
| @Override | ||||||
| public int read(byte[] b) throws IOException { | ||||||
| if (in == null) return -1; | ||||||
|
|
||||||
| if (sent >= max) return in.read(b); | ||||||
|
|
||||||
| return readTee(b, 0, in.read(b)); | ||||||
| } | ||||||
|
|
||||||
| @Override | ||||||
| public int read(byte[] b, int off, int len) throws IOException { | ||||||
| if (in == null) return -1; | ||||||
|
|
||||||
| if (sent >= max) return in.read(b, off, len); | ||||||
|
|
||||||
| return readTee(b, 0, in.read(b, off, len)); | ||||||
|
||||||
| return readTee(b, 0, in.read(b, off, len)); | |
| return readTee(b, off, in.read(b, off, len)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The newly added inner class uses tab indentation, while the rest of RequestLoggerImpl uses spaces. This makes the file inconsistent and can cause style/lint failures; please re-indent this block to match the existing spacing in the file.