Skip to content

Commit

Permalink
fix: Fix NullPointerException in initFrameProcessorPlugin if plug…
Browse files Browse the repository at this point in the history
…in is not found (#2454)

* fix: fix the null exception

* Add `Nullable` and `NonNull` annotations

---------

Co-authored-by: Marc Rousavy <[email protected]>
  • Loading branch information
vanenshi and mrousavy authored Jan 30, 2024
1 parent d9a3011 commit 02bc8a9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public static void addFrameProcessorPlugin(String name, PluginInitializer plugin

@DoNotStrip
@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 + "\"...");
PluginInitializer initializer = Plugins.get(name);
if (initializer == null) {
Expand All @@ -48,6 +48,6 @@ public static FrameProcessorPlugin getPlugin(String name, VisionCameraProxy prox
}

public interface PluginInitializer {
FrameProcessorPlugin initializePlugin(@NonNull VisionCameraProxy proxy, @Nullable Map<String, Object> options);
@NonNull FrameProcessorPlugin initializePlugin(@NonNull VisionCameraProxy proxy, @Nullable Map<String, Object> options);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class VisionCameraProxy(context: ReactApplicationContext) {

@DoNotStrip
@Keep
fun initFrameProcessorPlugin(name: String, options: Map<String, Any>): FrameProcessorPlugin =
fun initFrameProcessorPlugin(name: String, options: Map<String, Any>): FrameProcessorPlugin? =
FrameProcessorPluginRegistry.getPlugin(name, this, options)

// private C++ funcs
Expand Down

0 comments on commit 02bc8a9

Please sign in to comment.