Skip to content

Commit 9cacdc7

Browse files
committed
add debug condition
1 parent 65e67e2 commit 9cacdc7

1 file changed

Lines changed: 16 additions & 7 deletions

File tree

objectcache/src/main/java/com/myntra/objectcache/ObjectCache.java

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
import java.util.regex.Matcher;
1313
import java.util.regex.Pattern;
1414

15+
import com.myntra.objectcache.BuildConfig;
16+
1517
/**
1618
* @author mario
1719
*/
@@ -33,7 +35,8 @@ public static ObjectCache cacheInstance(File cacheDir, String folder, int appVer
3335
try {
3436
objectCache.cache = DiskLruCache.open(file, appVersion, 1, SIZE);
3537
} catch (IOException e) {
36-
e.printStackTrace();
38+
if(BuildConfig.DEBUG)
39+
e.printStackTrace();
3740
}
3841
return objectCache;
3942
}
@@ -44,7 +47,8 @@ public static ObjectCache cacheInstance(File cacheDir, String folder, int appVer
4447
try {
4548
objectCache.cache = DiskLruCache.open(file, appVersion, 1, size);
4649
} catch (IOException e) {
47-
e.printStackTrace();
50+
if(BuildConfig.DEBUG)
51+
e.printStackTrace();
4852
}
4953
return objectCache;
5054
}
@@ -59,7 +63,8 @@ public void write(String key, Object object, long expiry) {
5963
cache.flush();
6064
editor.commit();
6165
} catch (IOException e) {
62-
e.printStackTrace();
66+
if(BuildConfig.DEBUG)
67+
e.printStackTrace();
6368
}
6469
}
6570

@@ -80,7 +85,8 @@ public <T> T fetch(String key, Class<T> classOfT) {
8085
}
8186
}
8287
} catch (Exception e) {
83-
e.printStackTrace();
88+
if(BuildConfig.DEBUG)
89+
e.printStackTrace();
8490
}
8591
return null;
8692
}
@@ -95,7 +101,8 @@ public <T> T fetchEvenIfExpired(String key, Class<T> classOfT) {
95101
return gson.fromJson(entryJson.getAsJsonObject(Entry.VALUE), classOfT);
96102
}
97103
} catch (IOException e) {
98-
e.printStackTrace();
104+
if(BuildConfig.DEBUG)
105+
e.printStackTrace();
99106
}
100107
return null;
101108
}
@@ -110,7 +117,8 @@ public Boolean hasExpired(String key) {
110117
return entry.hasExpired();
111118
}
112119
} catch (IOException e) {
113-
e.printStackTrace();
120+
if(BuildConfig.DEBUG)
121+
e.printStackTrace();
114122
}
115123
return null;
116124
}
@@ -120,7 +128,8 @@ public boolean remove(String key) {
120128
try {
121129
return cache.remove(key);
122130
} catch (IOException e) {
123-
e.printStackTrace();
131+
if(BuildConfig.DEBUG)
132+
e.printStackTrace();
124133
}
125134
return false;
126135
}

0 commit comments

Comments
 (0)