@@ -52,7 +52,7 @@ public static AccountConfigurationCache getInstance() {
5252 * Thread-safe with double-check locking.
5353 *
5454 * @param dataActor DataActor instance to fetch data if refresh is needed
55- * @return AccountConfig containing account settings and API collections
55+ * @return AccountConfig containing account settings and API collections, or default config with redact=false if cache fails
5656 */
5757 public AccountConfig getConfig (DataActor dataActor ) {
5858 long currentTime = System .currentTimeMillis ();
@@ -67,9 +67,31 @@ public AccountConfig getConfig(DataActor dataActor) {
6767 }
6868 }
6969
70+ if (cachedConfig == null ) {
71+ logger .errorAndAddToDb ("getConfig returning null - cache refresh failed, returning default config with redact=false" );
72+ return getDefaultConfig ();
73+ }
74+
7075 return cachedConfig ;
7176 }
7277
78+ /**
79+ * Returns a default AccountConfig with redaction disabled.
80+ * Used as fallback when cache refresh fails.
81+ *
82+ * @return Default AccountConfig with accountId=0, isRedacted=false, and empty collections
83+ */
84+ private AccountConfig getDefaultConfig () {
85+ return new AccountConfig (
86+ 0 , // accountId
87+ false , // isRedacted = false (as requested)
88+ new ArrayList <>(), // empty apiCollections
89+ new ArrayList <>(), // empty apiInfos
90+ new HashMap <>(), // empty apiCollectionUrlTemplates
91+ new HashMap <>() // empty apiInfoUrlToMethods
92+ );
93+ }
94+
7395 /**
7496 * Force refresh the cache with fresh data from database.
7597 * If refresh fails, keeps the old cache (graceful degradation).
@@ -78,7 +100,16 @@ private void refreshConfig(DataActor dataActor) {
78100 try {
79101 logger .infoAndAddToDb ("Refreshing account configuration cache" );
80102 AccountSettings accountSettings = dataActor .fetchAccountSettings ();
81- logger .infoAndAddToDb ("Fetched accountSettings in configuration cache" );
103+
104+ logger .infoAndAddToDb ("Fetched accountSettings in configuration cache. accountSettings is null: " + (accountSettings == null ));
105+
106+ if (accountSettings == null ) {
107+ logger .errorAndAddToDb ("fetchAccountSettings returned null. Cannot refresh cache" );
108+ return ;
109+ }
110+
111+ logger .infoAndAddToDb ("AccountSettings ID: " + accountSettings .getId ());
112+
82113 List <ApiCollection > apiCollections = new ArrayList <>();
83114 if (accountSettings .getId () != 1758179941 ) {
84115 apiCollections = dataActor .fetchAllApiCollections ();
0 commit comments