Получение IOException Буфер Back Back заполнен при попытке разархивировать значение String с помощью ZipInputStream - PullRequest
6 голосов
/ 13 апреля 2010

Я пытаюсь распаковать строковое значение.
Но я получаю java.io.IOException: Push back buffer is full:

public byte[] unzipArray(String stringToUnzip) {
            byte[] inputByteArray = Base64.decode(stringToUnzip);
            ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(
                        inputByteArray);
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();

            ZipInputStream zipInputStream = new ZipInputStream(byteArrayInputStream);

            try {
                  ZipEntry theEntry = zipInputStream.getNextEntry();
            } catch (IOException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
            }
            byte[] buffer = new byte[2048];
            int size = 2048;

            while (true) {
                  try {
                        size = zipInputStream.read(buffer, 0, buffer.length);
                  } catch (IOException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                  }
                  if (size > 0) {
                        byteArrayOutputStream.write(buffer, 0, size);
                  } else {
                        break;
                  }
            }
            return byteArrayOutputStream.toByteArray();
      }

Трассировка стека исключений:

java.io.IOException: Push back buffer is full
                at java.io.PushbackInputStream.unread(Unknown Source)
                at java.util.zip.ZipInputStream.readEnd(Unknown Source)
                at java.util.zip.ZipInputStream.read(Unknown Source)
                at com.ZipHelper.unzipArray(ZipHelper.java:55)
                ......
                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
                at java.lang.reflect.Method.invoke(Unknown Source)
                at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:168)
                at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:67)
                at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:259)
                at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:133)
                at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:83)
                at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:133)
                at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:71)
                at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:990)
                at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:941)
                at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:932)
                at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:384)
                at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:451)
                at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:632)
                at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
                at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:530)
                at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:427)
                at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119)
                at org.eclipse.jetty.server.session.SessionHandler.handle(SessionHandler.java:182)
                at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:933)
                at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:362)
                at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:867)
                at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
                at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:113)
                at org.eclipse.jetty.server.Server.handle(Server.java:334)
                at org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:559)
                at org.eclipse.jetty.server.HttpConnection$RequestHandler.content(HttpConnection.java:1007)
                at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:747)
                at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:209)
                at org.eclipse.jetty.server.HttpConnection.handle(HttpConnection.java:406)
                at org.eclipse.jetty.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:462)
                at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:436)
                at java.lang.Thread.run(Unknown Source)
...