fix: Fix NullPointerException in initFrameProcessorPlugin if plugin is not found (#2454)

* fix: fix the null exception

* Add `Nullable` and `NonNull` annotations

---------

Co-authored-by: Marc Rousavy <me@mrousavy.com>
This commit is contained in:
Amir Hossein Shekari 2024-01-30 13:22:42 +03:30 committed by GitHub
parent d9a301100f
commit 02bc8a979c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 3 deletions

View File

@ -36,7 +36,7 @@ public class FrameProcessorPluginRegistry {
@DoNotStrip @DoNotStrip
@Keep @Keep
public static FrameProcessorPlugin getPlugin(String name, VisionCameraProxy proxy, Map<String, Object> options) { public static @Nullable FrameProcessorPlugin getPlugin(String name, VisionCameraProxy proxy, Map<String, Object> options) {
Log.i(TAG, "Looking up Frame Processor Plugin \"" + name + "\"..."); Log.i(TAG, "Looking up Frame Processor Plugin \"" + name + "\"...");
PluginInitializer initializer = Plugins.get(name); PluginInitializer initializer = Plugins.get(name);
if (initializer == null) { if (initializer == null) {
@ -48,6 +48,6 @@ public class FrameProcessorPluginRegistry {
} }
public interface PluginInitializer { public interface PluginInitializer {
FrameProcessorPlugin initializePlugin(@NonNull VisionCameraProxy proxy, @Nullable Map<String, Object> options); @NonNull FrameProcessorPlugin initializePlugin(@NonNull VisionCameraProxy proxy, @Nullable Map<String, Object> options);
} }
} }

View File

@ -71,7 +71,7 @@ class VisionCameraProxy(context: ReactApplicationContext) {
@DoNotStrip @DoNotStrip
@Keep @Keep
fun initFrameProcessorPlugin(name: String, options: Map<String, Any>): FrameProcessorPlugin = fun initFrameProcessorPlugin(name: String, options: Map<String, Any>): FrameProcessorPlugin? =
FrameProcessorPluginRegistry.getPlugin(name, this, options) FrameProcessorPluginRegistry.getPlugin(name, this, options)
// private C++ funcs // private C++ funcs