{"record":{"id":"a8fbed532430cf43","repo":"koral--/android-gif-drawable","slug":"inputstream-does-not-support-marking","errorCode":null,"errorMessage":"InputStream does not support marking","messagePattern":"InputStream does not support marking","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"android-gif-drawable/src/main/java/pl/droidsonroids/gif/GifInfoHandle.java","lineNumber":55,"sourceCode":"\tGifInfoHandle(FileDescriptor fileDescriptor) throws GifIOException {\n\t\tgifInfoPtr = openFileDescriptor(fileDescriptor, 0, true);\n\t}\n\n\tGifInfoHandle(byte[] bytes) throws GifIOException {\n\t\tgifInfoPtr = openByteArray(bytes);\n\t}\n\n\tGifInfoHandle(ByteBuffer buffer) throws GifIOException {\n\t\tgifInfoPtr = openDirectByteBuffer(buffer);\n\t}\n\n\tGifInfoHandle(String filePath) throws GifIOException {\n\t\tgifInfoPtr = openFile(filePath);\n\t}\n\n\tGifInfoHandle(InputStream stream) throws GifIOException {\n\t\tif (!stream.markSupported()) {\n\t\t\tthrow new IllegalArgumentException(\"InputStream does not support marking\");\n\t\t}\n\t\tgifInfoPtr = openStream(stream);\n\t}\n\n\tGifInfoHandle(AssetFileDescriptor afd) throws IOException {\n\t\ttry {\n\t\t\tgifInfoPtr = openFileDescriptor(afd.getFileDescriptor(), afd.getStartOffset(), false);\n\t\t} finally {\n\t\t\ttry {\n\t\t\t\tafd.close();\n\t\t\t} catch (IOException ignored) {\n\t\t\t\t//no-op\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate static long openFileDescriptor(FileDescriptor fileDescriptor, long offset, boolean closeOriginalDescriptor) throws GifIOException {\n\t\tfinal int nativeFileDescriptor;","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/koral--/android-gif-drawable/blob/26ff795f78b7fe8bbaf375a947b2bda95fc58e3d/android-gif-drawable/src/main/java/pl/droidsonroids/gif/GifInfoHandle.java#L37-L73","documentation":"The GifInfoHandle(InputStream) constructor requires the stream to support mark/reset because the native decoder needs to read the stream multiple times. If stream.markSupported() returns false, an IllegalArgumentException('InputStream does not support marking') is thrown.","triggerScenarios":"Passing a non-marking InputStream such as a raw Socket InputStream, System.in, or a stream wrapped in something that disables marking into new GifInfoHandle(stream) or GifDrawableBuilder.from(stream).","commonSituations":"Streaming a GIF directly from a network socket or decoded HTTP body without buffering; wrapping streams in classes that drop mark support.","solutions":["Wrap the stream in a BufferedInputStream (markSupported() is true) before passing it in.","Buffer the stream contents into a byte array (or ByteArrayInputStream) first and pass that instead.","Prefer a file/asset/Uri source where possible so no marking requirement applies."],"exampleFix":"// before\ngifDrawable = new GifDrawableBuilder().from(socket.getInputStream()).build();\n// after\ngifDrawable = new GifDrawableBuilder().from(new BufferedInputStream(socket.getInputStream())).build();","handlingStrategy":"validation","validationCode":"if (stream.markSupported()) { gifDrawable = new GifDrawableBuilder().from(stream).build(); } else { gifDrawable = new GifDrawableBuilder().from(new BufferedInputStream(stream)).build(); }","typeGuard":null,"tryCatchPattern":"try { d = new GifDrawableBuilder().from(stream).build(); } catch (IllegalArgumentException e) { d = new GifDrawableBuilder().from(new BufferedInputStream(stream)).build(); }","preventionTips":["Wrap arbitrary InputStreams in BufferedInputStream by default","Never pass raw socket or System.in streams directly","Prefer file/asset sources when available"],"tags":["android","io","inputstream"],"backgroundTag":"incompatible-source-type","analyzedSha":"26ff795f78b7fe8bbaf375a947b2bda95fc58e3d","analyzedAt":"2026-09-10T14:37:11.595Z","contentChangedAt":"2026-09-10T14:37:11.595Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}