From e31d010863ff0cb2ad9804cf6a2e3a8d388cb07c Mon Sep 17 00:00:00 2001 From: gmungoc Date: Wed, 6 Jun 2018 11:07:28 +0100 Subject: [PATCH] JAL-3020 limit cache size; handle applet exception --- .../datamodel/features/FeatureAttributes.java | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/jalview/datamodel/features/FeatureAttributes.java b/src/jalview/datamodel/features/FeatureAttributes.java index 833c704..64a13d7 100644 --- a/src/jalview/datamodel/features/FeatureAttributes.java +++ b/src/jalview/datamodel/features/FeatureAttributes.java @@ -34,6 +34,7 @@ public class FeatureAttributes /* * default value if property is not specified + * (selected VCF/VEP terms which have 'categorical' value ranges) */ private static final String CACHED_ATTS_DEFAULT = "AS_FilterStatus,clinical_significance,consequence_type," + "CSQ:Consequence,CSQ:CLIN_SIG,CSQ:DOMAIN,CSQ:IMPACT"; @@ -43,6 +44,11 @@ public class FeatureAttributes */ private static final String TERM_DELIMITERS = ",&"; + /* + * defensive limit to number of attribute values cached per attribute + */ + private static final int MAX_ATT_VALS = 30; + private static FeatureAttributes instance = new FeatureAttributes(); /* @@ -225,10 +231,12 @@ public class FeatureAttributes { terms = new HashSet<>(); } + int count = terms.size(); StringTokenizer st = new StringTokenizer(value, TERM_DELIMITERS); - while (st.hasMoreTokens()) + while (st.hasMoreTokens() && count < MAX_ATT_VALS) { terms.add(st.nextToken().trim()); + count++; } } @@ -341,7 +349,14 @@ public class FeatureAttributes */ public static List getFieldMatchers(String key, String def) { - String pref = Cache.getDefault(key, def); + String pref = def; + try + { + // temporary for applet: handle class loading errors... + pref = Cache.getDefault(key, def); + } catch (Throwable t) + { + } List patterns = new ArrayList<>(); String[] tokens = pref.split(","); for (String token : tokens) -- 1.7.10.2