Repository: apache/dubbo
File: dubbo-remoting/dubbo-remoting-http12/src/main/java/org/apache/dubbo/remoting/http12/message/LengthFieldStreamingDecoder.java (Java)

Code before:
        public int read() throws IOException {
            if (remaining <= 0) {
                return -1;
            }
            int result = super.read();
            if (result != -1) {
                remaining--;
            }
            return result;
        }

        @Override
        public int read(byte[] b, int off, int len) throws IOException {
            if (remaining <= 0) {
                return -1;
            }
            int toRead = Math.min(len, remaining);
            int result = super.read(b, off, toRead);
            if (result > 0) {
                remaining -= result;
            }
            return result;
        }

        @Override
        public int available() throws IOException {
            return Math.min(super.available(), remaining);
        }

        @Override
        public synchronized void mark(int readlimit) {
            // Force readlimit to be at least the remaining message length.
            // This ensures mark is always valid within the bounded stream,
            // regardless of what readlimit is passed by the deserializer (e.g., Hessian2).
            super.mark(Math.max(readlimit, limit));
            markedRemaining = remaining;
        }

        @Override
        public synchronized void reset() throws IOException {
            super.reset();
            // Restore the remaining count to the value at mark time
            remaining = markedRemaining;
        }
    }

    private boolean hasEnoughBytes() {
        return requiredLength - accumulate.available() <= 0;
    }

    protected static int bytesToInt(byte[] bytes) {

Review comment (suggestion):
Method 'available' overrides a synchronized method in [java.io.BufferedInputStream](1) but is not synchronized.
```suggestion
        public synchronized int available() throws IOException {
```

Code after:
        public synchronized int read() throws IOException {
            if (remaining <= 0) {
                return -1;
            }
            int result = super.read();
            if (result != -1) {
                remaining--;
            }
            return result;
        }

        @Override
        public synchronized int read(byte[] b, int off, int len) throws IOException {
            if (remaining <= 0) {
                return -1;
            }
            int toRead = Math.min(len, remaining);
            int result = super.read(b, off, toRead);
            if (result > 0) {
                remaining -= result;
            }
            return result;
        }

        @Override
        public synchronized int available() throws IOException {
            return Math.min(super.available(), remaining);
        }

        @Override
        public synchronized void mark(int readlimit) {
            // Force readlimit to be at least the remaining message length.
            // This ensures mark is always valid within the bounded stream,
            // regardless of what readlimit is passed by the deserializer (e.g., Hessian2).
            super.mark(Math.max(readlimit, limit));
            markedRemaining = remaining;
        }

        @Override
        public synchronized void reset() throws IOException {
            super.reset();
            // Restore the remaining count to the value at mark time
            remaining = markedRemaining;
        }
    }

    private boolean hasEnoughBytes() {
        return requiredLength - accumulate.available() <= 0;
    }

    protected static int bytesToInt(byte[] bytes) {