AbstractServletInputStream

AbstractServletInputStream

最近将一个Java项目从spring-boot 1.3.0更新到了1.4.0,使用的是tomcat-embed-core 8.0.28,现在在使用tomcat-embed-core 8.5的最新版本的Spring Boot中缺少AbstractServletInputStream。 4。该类的替代品/替代品是什么?

这是旧的代码块,希望对我的情况有所帮助:

public class MultiReadHttpServletRequest extends HttpServletRequestWrapper {
    ...
    public class CachedServletInputStream extends AbstractServletInputStream {
        private ByteArrayInputStream input;

        public CachedServletInputStream() {
            input = new ByteArrayInputStream(cachedBytes.toByteArray());
        }

        /**
        * Returns true. This stream is always ready.
        */
        @Override
        protected boolean doIsReady() throws IOException {
            return true;
        }

        /**
         * Reads the next set of bytes into the byte array.
         */
        @Override
        protected int doRead(boolean b, byte[] bytes, int i, int i1) throws IOException {
            return input.read(bytes, i, i1);
        }

       /**
        * Closes this stream. This does not affect any other streams that are dependent
        * on the cached content.
        */
        @Override
        protected void doClose() throws IOException {
            input.close();
        }
    }
}

最佳答案

您可以使用CoyoteInputStream代替AbstractServletInputStream

关于java - 在tomcat-embed-core 8.5.4上缺少AbstractServletInputStream,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/38681794/

10-11 10:48