{"record":{"id":"505ad790e803368d","repo":"DrKLO/Telegram","slug":"unexpected-error-creating-extractor","errorCode":null,"errorMessage":"Unexpected error creating extractor","messagePattern":"Unexpected error creating extractor","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"TMessagesProj/src/main/java/com/google/android/exoplayer2/extractor/DefaultExtractorsFactory.java","lineNumber":520,"sourceCode":"    @Nullable\n    private Constructor<? extends Extractor> extractorConstructor;\n\n    public ExtensionLoader(ConstructorSupplier constructorSupplier) {\n      this.constructorSupplier = constructorSupplier;\n      extensionLoaded = new AtomicBoolean(false);\n    }\n\n    @Nullable\n    public Extractor getExtractor(Object... constructorParams) {\n      @Nullable\n      Constructor<? extends Extractor> extractorConstructor = maybeLoadExtractorConstructor();\n      if (extractorConstructor == null) {\n        return null;\n      }\n      try {\n        return extractorConstructor.newInstance(constructorParams);\n      } catch (Exception e) {\n        throw new IllegalStateException(\"Unexpected error creating extractor\", e);\n      }\n    }\n\n    @Nullable\n    private Constructor<? extends Extractor> maybeLoadExtractorConstructor() {\n      synchronized (extensionLoaded) {\n        if (extensionLoaded.get()) {\n          return extractorConstructor;\n        }\n        try {\n          return constructorSupplier.getConstructor();\n        } catch (ClassNotFoundException e) {\n          // Expected if the app was built without the extension.\n        } catch (Exception e) {\n          // The extension is present, but instantiation failed.\n          throw new RuntimeException(\"Error instantiating extension\", e);\n        }\n        extensionLoaded.set(true);","sourceCodeStart":502,"sourceCodeEnd":538,"githubUrl":"https://github.com/DrKLO/Telegram/blob/45ab8f4308496e1f01026a97fcdb0d58a5274474/TMessagesProj/src/main/java/com/google/android/exoplayer2/extractor/DefaultExtractorsFactory.java#L502-L538","documentation":"DefaultExtractorsFactory.ExtensionLoader.getExtractor() reflectively instantiates an extension Extractor via Constructor.newInstance(constructorParams). Any exception thrown by the extension's constructor (or by newInstance itself, e.g. wrong arg types) is wrapped and rethrown as IllegalStateException. The extension class was found; only its instantiation blew up.","triggerScenarios":"Calling extractors factory methods that resolve an extension extractor (e.g. FLAC, Opus) and the resolved Extractor constructor throws - because constructorParams do not match the constructor's expected types, or the constructor does I/O/static-init that fails.","commonSituations":"Passing constructor flags (e.g. constant Mode flags) the extension constructor does not accept; an extension whose static initializer fails; a version skew between the ExoPlayer core and the extension.","solutions":["Inspect the wrapped cause (the IllegalStateException's cause) to find the real failure.","Ensure the constructorParams passed to the factory match the extension Extractor's constructor signature.","Use matching core/extension versions; rebuild the extension against the current core."],"exampleFix":"// before - passing a param the extension ctor does not accept\nfactory.getExtractor(SomeUnsupportedFlag.class);\n\n// after - pass the documented Extractor flag constants the ctor expects\nfactory.getExtractor(Extractor.FLAG_ENABLE_CONSTANT_BITRATE_SEEKING);","handlingStrategy":"try-catch","validationCode":"// Verify the constructor-params match what the extension Extractor expects before asking for it.\n// (e.g. FLAC/Opus extractors take an int flags arg from Extractor.FLAG_*)\nif (!(constructorParams instanceof Integer)) {\n  // pass Extractor.FLAG_* ints only\n}","typeGuard":null,"tryCatchPattern":"try {\n  Extractor ex = extensionLoader.getExtractor(constructorParams);\n} catch (IllegalStateException e) {\n  Throwable cause = e.getCause();\n  // inspect cause: wrong arg types -> fix factory call; static init failure -> fix extension\n}","preventionTips":["Pass only the documented Extractor flag constants as constructorParams.","Keep extension and ExoPlayer core versions aligned.","Inspect the wrapped cause of IllegalStateException before guessing."],"tags":["exoplayer","extractor","reflection","classloading"],"backgroundTag":null,"analyzedSha":"45ab8f4308496e1f01026a97fcdb0d58a5274474","analyzedAt":"2026-08-14T05:19:30.815Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}