Skip to content

Commit

Permalink
fix(android): add try catch for vfs processor chain get
Browse files Browse the repository at this point in the history
  • Loading branch information
siguangli2018 committed Nov 4, 2024
1 parent ebd4841 commit 718cc9c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
1 change: 1 addition & 0 deletions modules/vfs/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,6 @@ android {

dependencies {
compileOnly project(path: ':pool')
compileOnly project(path: ':hippy-support')
implementation deps.annotation
}
23 changes: 21 additions & 2 deletions modules/vfs/android/src/main/java/com/tencent/vfs/VfsManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,16 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.tencent.mtt.hippy.utils.LogUtils;
import com.tencent.vfs.ResourceDataHolder.RequestFrom;
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;

public class VfsManager {

private static final String TAG = "VfsManager";

@NonNull
private final CopyOnWriteArrayList<Processor> mProcessorChain;
private int mId;
Expand Down Expand Up @@ -118,7 +121,15 @@ private void traverseForward(@NonNull final ResourceDataHolder holder, final boo
int index = holder.index + 1;
if (index < mProcessorChain.size()) {
holder.index = index;
Processor processor = mProcessorChain.get(index);
Processor processor = null;
try {
processor = mProcessorChain.get(index);
} catch (IndexOutOfBoundsException e) {
LogUtils.e(TAG, "traverseForward get index " + index + " processor exception: " + e.getMessage());
}
if (processor == null) {
return;
}
if (isSync) {
boolean goBack = processor.handleRequestSync(holder);
if (goBack) {
Expand Down Expand Up @@ -158,7 +169,15 @@ private void traverseGoBack(@NonNull final ResourceDataHolder holder, final bool
int index = holder.index - 1;
if (index >= 0 && index < mProcessorChain.size()) {
holder.index = index;
Processor processor = mProcessorChain.get(index);
Processor processor = null;
try {
processor = mProcessorChain.get(index);
} catch (IndexOutOfBoundsException e) {
LogUtils.e(TAG, "traverseGoBack get index " + index + " processor exception: " + e.getMessage());
}
if (processor == null) {
return;
}
if (isSync) {
processor.handleResponseSync(holder);
traverseGoBack(holder, true);
Expand Down

0 comments on commit 718cc9c

Please sign in to comment.