{"record":{"id":"da250d935565c156","repo":"MuntashirAkon/AppManager","slug":"e","errorCode":null,"errorMessage":"${e}","messagePattern":"\\$\\{e\\}","errorType":"exception","errorClass":"org.xmlpull.v1.XmlPullParserException","httpStatus":null,"severity":"error","filePath":"libcore/compat/src/main/java/io/github/muntashirakon/compat/xml/BinaryXmlPullParser.java","lineNumber":115,"sourceCode":"        mAttributes = new Attribute[8];\n        for (int i = 0; i < mAttributes.length; i++) {\n            mAttributes[i] = new Attribute();\n        }\n\n        try {\n            final byte[] magic = new byte[4];\n            mIn.readFully(magic);\n            if (!Arrays.equals(magic, PROTOCOL_MAGIC_VERSION_0)) {\n                throw new IOException(\"Unexpected magic \" + bytesToHexString(magic));\n            }\n\n            // We're willing to immediately consume a START_DOCUMENT if present,\n            // but we're okay if it's missing\n            if (peekNextExternalToken() == START_DOCUMENT) {\n                consumeToken();\n            }\n        } catch (IOException e) {\n            throw new XmlPullParserException(e.toString());\n        }\n    }\n\n    @Override\n    public void setInput(Reader in) throws XmlPullParserException {\n        throw new UnsupportedOperationException();\n    }\n\n    @Override\n    public int next() throws XmlPullParserException, IOException {\n        while (true) {\n            final int token = nextToken();\n            switch (token) {\n                case START_TAG:\n                case END_TAG:\n                case END_DOCUMENT:\n                    return token;\n                case TEXT:","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/MuntashirAkon/AppManager/blob/0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5/libcore/compat/src/main/java/io/github/muntashirakon/compat/xml/BinaryXmlPullParser.java#L97-L133","documentation":"During setInput, reading the magic header or consuming the optional START_DOCUMENT token can raise an IOException (bad magic, short stream, corrupted data). setInput translates any such IOException into an XmlPullParserException whose message is the exception's toString(), so parsers following the XmlPullParser contract get the right exception type.","triggerScenarios":"setInput(InputStream, String) when the underlying stream throws IOException while reading the 4-byte magic or the first token: empty stream, truncated file, closed/broken stream, or unexpected magic.","commonSituations":"Passing an already-consumed or closed stream; feeding a zero-byte or truncated binary XML file; network/socket streams cut off mid-header; wrong file handed to the parser.","solutions":["Catch XmlPullParserException and inspect its message/cause to identify the underlying IOException.","Verify the stream is open, positioned at the start, and contains a complete binary XML document.","Log the embedded exception (e.getMessage()) — it is the original IOException's toString()."],"exampleFix":"// before\nparser.setInput(is, null); // throws XmlPullParserException(\"java.io.EOFException\") with no context\n// after\ntry {\n    parser.setInput(is, null);\n} catch (XmlPullParserException e) {\n    Log.e(TAG, \"Failed to read binary XML header\", e);\n}","handlingStrategy":"try-catch","validationCode":"File f = new File(path);\nif (!f.isFile() || f.length() < 4) throw new IOException(\"Not a binary XML file: \" + path);","typeGuard":null,"tryCatchPattern":"try {\n    parser.setInput(is, null);\n} catch (XmlPullParserException e) {\n    // e's message is the wrapped IOException's toString(); log and recover\n    Log.e(TAG, \"Binary XML header read failed\", e);\n}","preventionTips":["Verify the stream is open and unread before setInput.","Check file size is at least the 4-byte magic before parsing.","Handle truncated/corrupt inputs explicitly at the IO layer."],"tags":["xml","ioexception","parse-error","stream"],"backgroundTag":"file-read-failed","analyzedSha":"0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5","analyzedAt":"2026-09-12T14:03:37.243Z","contentChangedAt":"2026-09-12T14:03:37.243Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}