Obsolete
Status Update
Comments
pr...@google.com <pr...@google.com> #2
Can you share a public handler that produce this error?
ma...@rjgodoy.com.ar <ma...@rjgodoy.com.ar> #3
This is likely caused by FileReadChannel.read() returning 0 instead of -1 after the channel reaches end-of-stream, which is in violation of the ReadableByteChannel [1] contract (i.e. "returns the number of bytes read, possibly zero, or -1 if the channel has reached end-of-stream"). Hence the wrapper InputStream provided by java.nio.channels.Channels fails to detect the end of stream.
[1]http://docs.oracle.com/javase/1.4.2/docs/api/java/nio/channels/ReadableByteChannel.html#read(java.nio.ByteBuffer)
Note that it is "the number of bytes read" what may be "possibly zero"; and -1 is returned when the channel has reached end-of-stream. Zero does not signal the end of stream ("A read operation ... might not read any bytes at all").
As a workaround, you could either read the blob into a ByteBuffer (and then create a ByteArrayInputStream from the buffer) or implement a ReadableByteChannel wrapper that signals the end-of-stream by returning -1 after blobInfo.getSize() bytes have been read.
This issue causes the attached code fragment to fail, if run on a large blob.
972800 972800
1945600 972800
2918400 972800
3891200 972800
4864000 972800
5836800 972800
6809600 972800
7533952 724352
7533952 0
7533952 0
7533952 0
(etc, read is never -1)
[1]
Note that it is "the number of bytes read" what may be "possibly zero"; and -1 is returned when the channel has reached end-of-stream. Zero does not signal the end of stream ("A read operation ... might not read any bytes at all").
As a workaround, you could either read the blob into a ByteBuffer (and then create a ByteArrayInputStream from the buffer) or implement a ReadableByteChannel wrapper that signals the end-of-stream by returning -1 after blobInfo.getSize() bytes have been read.
This issue causes the attached code fragment to fail, if run on a large blob.
972800 972800
1945600 972800
2918400 972800
3891200 972800
4864000 972800
5836800 972800
6809600 972800
7533952 724352
7533952 0
7533952 0
7533952 0
(etc, read is never -1)
js...@google.com <js...@google.com> #4
To be sure that we can focus on the most important issues reported, we are doing a cleanup of the issue tracker.
As this issue has not been updated in over six months and has a low vote count, it will be closed. If this issue still affects you, please open a new issue and we’ll take a look.
We have moved to a new issue tracking system athttps://issuetracker.google.com/savedsearches/559750 . The new system will allow us to better triage and respond to incoming issues.
As this issue has not been updated in over six months and has a low vote count, it will be closed. If this issue still affects you, please open a new issue and we’ll take a look.
We have moved to a new issue tracking system at
Description
I am trying to read a text file from the blostore like this:
[code]
AppEngineFile file = new AppEngineFile(AppEngineFile.FileSystem.BLOBSTORE, blobKey.getKeyString());
FileReadChannel frc = fileService.openReadChannel(file, false);
BufferedReader reader = new BufferedReader(Channels.newReader(frc, "UTF8"));
String line = "";
while ((line = reader.readLine()) != null) {
// do stuff
}
reader.close();
frc.close();
[/code]
In some cases readline() generates the exception below. Url to systematically produce the exception:
java.io.IOException
at com.google.appengine.api.files.FileServiceImpl.translateException(FileServiceImpl.java:617)
at com.google.appengine.api.files.FileServiceImpl.makeSyncCall(FileServiceImpl.java:590)
at com.google.appengine.api.files.FileServiceImpl.read(FileServiceImpl.java:539)
at com.google.appengine.api.files.FileServiceImpl.read(FileServiceImpl.java:410)
at com.google.appengine.api.files.FileReadChannelImpl.read(FileReadChannelImpl.java:73)
at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:272)
at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:324)
at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:176)
at java.io.BufferedReader.fill(BufferedReader.java:153)
at java.io.BufferedReader.readLine(BufferedReader.java:316)
at java.io.BufferedReader.readLine(BufferedReader.java:379)
at cri.domodentweb.server.admintasks.ImportPLFromCSVTask.doGet(ImportPLFromCSVTask.java:114)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
at cri.domodentweb.server.servlets.GWTCacheControlFilter.doFilter(GWTCacheControlFilter.java:41)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.utils.servlet.ParseBlobUploadFilter.doFilter(ParseBlobUploadFilter.java:102)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.runtime.jetty.SaveSessionFilter.doFilter(SaveSessionFilter.java:35)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
at com.google.apphosting.runtime.jetty.AppVersionHandlerMap.handle(AppVersionHandlerMap.java:249)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923)
at com.google.apphosting.runtime.jetty.RpcRequestParser.parseAvailable(RpcRequestParser.java:76)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at com.google.apphosting.runtime.jetty.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:135)
at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.run(JavaRuntime.java:477)
at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:449)
at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:455)
at com.google.tracing.TraceContext.runInContext(TraceContext.java:695)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:333)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:325)
at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:453)
at com.google.apphosting.runtime.ThreadGroupPool$PoolEntry.run(ThreadGroupPool.java:251)
at java.lang.Thread.run(Thread.java:679)
Caused by: com.google.apphosting.api.ApiProxy$ApplicationException: ApplicationError: 10:
at java.lang.Thread.getStackTrace(Thread.java:1495)
at com.google.apphosting.runtime.ApiProxyImpl.doSyncCall(ApiProxyImpl.java:237)
at com.google.apphosting.runtime.ApiProxyImpl.access$000(ApiProxyImpl.java:68)
at com.google.apphosting.runtime.ApiProxyImpl$1.run(ApiProxyImpl.java:182)
at com.google.apphosting.runtime.ApiProxyImpl$1.run(ApiProxyImpl.java:180)
at java.security.AccessController.doPrivileged(Native Method)
at com.google.apphosting.runtime.ApiProxyImpl.makeSyncCall(ApiProxyImpl.java:180)
at com.google.apphosting.runtime.ApiProxyImpl.makeSyncCall(ApiProxyImpl.java:68)
at com.google.apphosting.api.ApiProxy.makeSyncCall(ApiProxy.java:101)
at com.google.apphosting.api.ApiProxy.makeSyncCall(ApiProxy.java:50)
at com.google.appengine.api.files.FileServiceImpl.makeSyncCall(FileServiceImpl.java:586)
... 44 more
Caused by: com.google.apphosting.api.ApiProxy$ApplicationException: ApplicationError: 10:
at com.google.apphosting.runtime.ApiProxyImpl$AsyncApiFuture.failure(ApiProxyImpl.java:546)
at com.google.net.rpc3.client.RpcStub$RpcCallbackDispatcher$1.runInContext(RpcStub.java:784)
at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:455)
at com.google.tracing.TraceContext.runInContext(TraceContext.java:695)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:333)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:325)
at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:453)
at com.google.net.rpc3.client.RpcStub$RpcCallbackDispatcher.rpcFinished(RpcStub.java:824)
at com.google.net.rpc3.client.RpcStub$RpcCallbackDispatcher.failure(RpcStub.java:815)
at com.google.net.rpc3.impl.client.RpcClientInternalContext.runCallbacks(RpcClientInternalContext.java:895)
at com.google.net.rpc3.impl.client.RpcClientInternalContext.finishRpcAndNotifyApp(RpcClientInternalContext.java:798)
at com.google.net.rpc3.impl.client.RpcNetChannel.afterFinishingActiveRpc(RpcNetChannel.java:1059)
at com.google.net.rpc3.impl.client.RpcNetChannel.finishRpc(RpcNetChannel.java:907)
at com.google.net.rpc3.impl.client.RpcNetChannel.handleResponse(RpcNetChannel.java:2255)
at com.google.net.rpc3.impl.client.RpcNetChannel.messageReceived(RpcNetChannel.java:2062)
at com.google.net.rpc3.impl.client.RpcNetChannel.access$2000(RpcNetChannel.java:143)
at com.google.net.rpc3.impl.client.RpcNetChannel$TransportCallback.receivedMessage(RpcNetChannel.java:3117)
at com.google.net.rpc3.impl.client.RpcChannelTransportData$TransportCallback.receivedMessage(RpcChannelTransportData.java:599)
at com.google.net.rpc3.impl.wire.RpcBaseTransport.receivedMessage(RpcBaseTransport.java:417)
at com.google.net.rpc3.impl.wire.RpcClientTcpTransport.parseOneMessage(RpcClientTcpTransport.java:750)
at com.google.net.rpc3.impl.wire.RpcClientTcpTransport.parseMessages(RpcClientTcpTransport.java:634)
at com.google.net.rpc3.impl.wire.RpcClientTcpTransport.access$100(RpcClientTcpTransport.java:37)
at com.google.net.rpc3.impl.wire.RpcClientTcpTransport$1.dataReceived(RpcClientTcpTransport.java:295)
at com.google.net.async3.SocketConnection.handleNetworkReadEvent(SocketConnection.java:900)
at com.google.net.async3.SocketConnection.access$400(SocketConnection.java:43)
at com.google.net.async3.SocketConnection$NetworkReadHandlerImpl.run(SocketConnection.java:929)
at com.google.net.eventmanager.AbstractFutureTask$Sync.innerRun(AbstractFutureTask.java:260)
at com.google.net.eventmanager.AbstractFutureTask.run(AbstractFutureTask.java:121)
at com.google.net.eventmanager.EventManagerImpl.runTask(EventManagerImpl.java:578)
at com.google.net.eventmanager.EventManagerImpl.internalRunWorkerLoop(EventManagerImpl.java:1002)
at com.google.net.eventmanager.EventManagerImpl.runWorkerLoop(EventManagerImpl.java:884)
at com.google.net.eventmanager.WorkerThreadInfo.runWorkerLoop(WorkerThreadInfo.java:136)
at com.google.net.eventmanager.EventManagerImpl$WorkerThread.run(EventManagerImpl.java:1855)