From: gmungoc Date: Wed, 6 Jun 2018 10:07:28 +0000 (+0100) Subject: JAL-3020 limit cache size; handle applet exception X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=e31d010863ff0cb2ad9804cf6a2e3a8d388cb07c;p=jalview.git JAL-3020 limit cache size; handle applet exception --- 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)