1

Basically I'm helping a friend of mine out,

There's a disconnection error with his game (runescape private server) and there's an error that keeps being thrown, which is

DataInputStream.readFully(Unknown Source)

at Client.streamLoaderForName(Client.java:7343)

I read some things up on using while(in.available() > 0), but I don't know where it'd be placed. This is the method where the error occurs

    private CacheArchive streamLoaderForName(int i, String s, String s1, int j, int k)
{
    byte abyte0[] = null;
    int l = 5;
    try
    {
        if(cacheIndices[0] != null)
            abyte0 = cacheIndices[0].get(i);
    }
    catch(Exception _ex) { }
    if(abyte0 != null)
    {
        CacheArchive streamLoader = new CacheArchive(abyte0);
        return streamLoader;
    }
    int j1 = 0;
    while(abyte0 == null)
    {
        String s2 = "Unknown error";
        setLoadingText(k, "Requesting " + s);
        Object obj = null;
        try
        {
            int k1 = 0;
            DataInputStream datainputstream = jaggrabRequest(s1 + j);
            byte[] abyte1 = new byte[6];
            datainputstream.readFully(abyte1, 0, 6);
            Stream stream = new Stream(abyte1);
            stream.currentOffset = 3;
            int i2 = stream.read3Bytes() + 6;
            int j2 = 6;
            abyte0 = new byte[i2];
            System.arraycopy(abyte1, 0, abyte0, 0, 6);

            while(j2 < i2) 
            {
                int l2 = i2 - j2;
                if(l2 > 1000)
                    l2 = 1000;
                int j3 = datainputstream.read(abyte0, j2, l2);
                if(j3 < 0)
                {
                    s2 = "Length error: " + j2 + "/" + i2;
                    throw new IOException("EOF");
                }
                j2 += j3;
                int k3 = (j2 * 100) / i2;
                k1 = k3;
            }
            datainputstream.close();
            try
            {
                if(cacheIndices[0] != null)
                    cacheIndices[0].put(abyte0.length, abyte0, i);
            }
            catch(Exception _ex)
            {
                cacheIndices[0] = null;
            }
        }
        catch(IOException ioexception)
        {
            ioexception.printStackTrace();
            if(s2.equals("Unknown error"))
                s2 = "Connection error";
            abyte0 = null;
        }
        catch(NullPointerException _ex)
        {
            s2 = "Null error";
            abyte0 = null;
        }
        catch(ArrayIndexOutOfBoundsException _ex)
        {
            s2 = "Bounds error";
            abyte0 = null;
        }
        catch(Exception _ex)
        {
            s2 = "Unexpected error";
            abyte0 = null;
        }
        if(abyte0 == null)
        {
            for(int l1 = l; l1 > 0; l1--)
            {
                if(j1 >= 3)
                {
                    setLoadingText(k, "Game updated - please reload page");
                    l1 = 10;
                } else
                {
                    setLoadingText(k, s2 + " - Retrying in " + l1);
                }
                try
                {
                    Thread.sleep(1000L);
                }
                catch(Exception _ex) { }
            }

            l *= 2;
            if(l > 60)
                l = 60;
        }

    }

    CacheArchive streamLoader_1 = new CacheArchive(abyte0);
    return streamLoader_1;
}

I can't seem to find out where to do any placements or how to fix this error. By the way, the line that's 7343, is

datainputstream.readFully(abyte1, 0, 6);  

Also sorry for the poor thread, I don't know how to write it up properly on this.

Nivas
  • 308
  • 1
  • 6
  • 20
Snooperal
  • 11
  • 2
  • You said to read exactly 6 bytes, but the stream does not contain enough bytes to fulfill your request. – M. Prokhorov Dec 15 '17 at 12:49
  • Do you think you could evaluate on that? How would I go about changing it so this crash doesn't happen? -edit Also the crash only happens once in a while, it doesn't do it every time. So I'm not sure what all it would have to do with that – Snooperal Dec 15 '17 at 12:54
  • That would depend on what actually happens in "once in a while" branch of your program. – M. Prokhorov Dec 15 '17 at 13:03
  • Maybe I am missing something but it looks like a `EOFException` is _always_ thrown and caught, eventually breaking the `while`-loop. If you use `while(in.available() > 0)` it can be placed anywhere after input-stream creation and before reading. – Würgspaß Dec 15 '17 at 13:31
  • I tried placing while(in.available() > 0) under byte[] abyte1 = new byte[6]; is that a good placement for it? What would you recommend would be a good place? (I know it was said anywhere after input stream creation and before reading, but I want opinions) And I'm not getting any errors, but like I said it doesn't happen regularly. It's just obnoxious for when it does happen, and does anybody know what it would mean for it to do it but not be at all consistent about it? Thank you guys for replying, by the way. – Snooperal Dec 15 '17 at 14:15

0 Answers0