1

My production android app throws this exception. When I analysed crittercism I noticed that many of my async tasks were not completing. They were hanging on

ClientSession.java:361

responseMessage = (AMessageStrategy) objectInputStream.readObject();

and

ClientSession.java:321

objectInputStream = new ObjectInputStream(new BufferedInputStream(inputStream));.

Did some research on SO and found this link. But did not find any SO question that links RejectedExecution with a Hang issue. Hence this question.

org.apache.harmony.luni.platform.OSNetworkSystem.read(Native Method)
dalvik.system.BlockGuard$WrappedNetworkSystem.read(BlockGuard.java:273)
org.apache.harmony.luni.net.PlainSocketImpl.read(PlainSocketImpl.java:461)
org.apache.harmony.luni.net.SocketInputStream.read(SocketInputStream.java:85)
org.apache.harmony.luni.net.SocketInputStream.read(SocketInputStream.java:65)
java.io.BufferedInputStream.fillbuf(BufferedInputStream.java:140)
java.io.BufferedInputStream.read(BufferedInputStream.java:324)
java.io.DataInputStream.readToBuff(DataInputStream.java:159)
java.io.DataInputStream.readShort(DataInputStream.java:375)
java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:2365)
java.io.ObjectInputStream.<init>(ObjectInputStream.java:433)
com.mcruiseon.common.communication.ClientSession$SendQueue.<init>(ClientSession.java:321)

org.apache.harmony.luni.platform.OSNetworkSystem.read(Native Method)    
dalvik.system.BlockGuard$WrappedNetworkSystem.read(BlockGuard.java:273)
org.apache.harmony.luni.net.PlainSocketImpl.read(PlainSocketImpl.java:461)
org.apache.harmony.luni.net.SocketInputStream.read(SocketInputStream.java:85)
org.apache.harmony.luni.net.SocketInputStream.read(SocketInputStream.java:65)
java.io.BufferedInputStream.fillbuf(BufferedInputStream.java:140)
java.io.BufferedInputStream.read(BufferedInputStream.java:225)
java.io.FilterInputStream.read(FilterInputStream.java:115)
java.io.ObjectInputStream.checkReadPrimitiveTypes(ObjectInputStream.java:466)
java.io.ObjectInputStream.readNonPrimitiveContent(ObjectInputStream.java:899)
java.io.ObjectInputStream.readObject(ObjectInputStream.java:2262)
java.io.ObjectInputStream.readObject(ObjectInputStream.java:2217)
com.mcruiseon.common.communication.ClientSession$SendQueue.run(ClientSession.java:361)

I have

  • flush just after outputstream create
  • creating outputstream before inputstream
  • flushing just after write

Still I get the hang, its a random error that occurred 2 months after getting the product on production. Any ideas people ?

Community
  • 1
  • 1
Siddharth
  • 9,349
  • 16
  • 86
  • 148

2 Answers2

0

If you are doing an donwload on adapter to get one image on each position (in a list), maybe you are repeating on a loop until 128 threads on the Asynctask. sorry my bad english.

Siddharth
  • 9,349
  • 16
  • 86
  • 148
lucasddaniel
  • 1,779
  • 22
  • 22
0

On the client, I was creating new sockets without closing the older ones. These sockets were pile'in on. After about 128 sockets android max's out and throws this Exception.

I created a timeout and closed old sockets on inactivity.

Siddharth
  • 9,349
  • 16
  • 86
  • 148