Skip to content

Commit f788b76

Browse files
committed
fix: add null safety to NeedBeanCondition for test isolation
NeedBeanCondition.matches() NPEs when Args is reset between test methods. Add null checks for storage, dbEngine, and dbBackupConfig.
1 parent 0dcc818 commit f788b76

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

framework/src/main/java/org/tron/core/db/backup/NeedBeanCondition.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@ public class NeedBeanCondition implements Condition {
99

1010
@Override
1111
public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
12-
return ("ROCKSDB".equals(Args.getInstance().getStorage().getDbEngine().toUpperCase()))
12+
if (Args.getInstance() == null || Args.getInstance().getStorage() == null
13+
|| Args.getInstance().getStorage().getDbEngine() == null
14+
|| Args.getInstance().getDbBackupConfig() == null) {
15+
return false;
16+
}
17+
return "ROCKSDB".equalsIgnoreCase(Args.getInstance().getStorage().getDbEngine())
1318
&& Args.getInstance().getDbBackupConfig().isEnable() && !Args.getInstance().isWitness();
1419
}
1520
}

0 commit comments

Comments
 (0)