@@ -36,8 +36,8 @@ public class CommonUtil {
3636 public static final short UNDEFINED_NODE = -1 ;
3737 private static final String _8220 = String .valueOf ((char ) 8220 );
3838
39- private static Map <Collection .Key , Coll > members ;
40- private static BIF GetApplicationSettings ;
39+ private static volatile Map <Collection .Key , Coll > members ;
40+ private static final Object membersLock = new Object () ;
4141
4242 public static String unwrap (String str ) {
4343 if (str == null ) return "" ;
@@ -156,31 +156,34 @@ else if (res.isDirectory()) {
156156
157157 public static Map <Collection .Key , Coll > getMembers (PageContext pc ) throws PageException {
158158 if (members == null ) {
159- Cast cast = CFMLEngineFactory .getInstance ().getCastUtil ();
160- members = new HashMap <Collection .Key , Coll >();
161- ConfigWeb config = pc .getConfig ();
162- Object [] flds = getFLDs (config , 1 );
163- Map funcs ;
164- Iterator it ;
165- Object func ;
166- String [] names ;
167- boolean chaining ;
168- BIF bif ;
169- Coll coll ;
170- for (int i = 0 ; i < flds .length ; i ++) {
171- funcs = getFunctions (flds [i ]);
172- it = funcs .values ().iterator ();
173- while (it .hasNext ()) {
174- func = it .next ();
175- if (getMemberType (func ) == Image .TYPE_IMAGE ) {
176- names = getMemberNames (func );
177- if (names != null && names .length > 0 ) {
178- coll = new Coll (getBIF (func ), getMemberChaining (func ));
179- for (String name : names ) {
180- members .put (cast .toKey (name ), coll );
159+ synchronized (membersLock ) {
160+ if (members == null ) {
161+ Cast cast = CFMLEngineFactory .getInstance ().getCastUtil ();
162+ Map <Collection .Key , Coll > local = new HashMap <>();
163+ ConfigWeb config = pc .getConfig ();
164+ Object [] flds = getFLDs (config , 1 );
165+ Map funcs ;
166+ Iterator it ;
167+ Object func ;
168+ String [] names ;
169+ Coll coll ;
170+ for (int i = 0 ; i < flds .length ; i ++) {
171+ funcs = getFunctions (flds [i ]);
172+ it = funcs .values ().iterator ();
173+ while (it .hasNext ()) {
174+ func = it .next ();
175+ if (getMemberType (func ) == Image .TYPE_IMAGE ) {
176+ names = getMemberNames (func );
177+ if (names != null && names .length > 0 ) {
178+ coll = new Coll (getBIF (func ), getMemberChaining (func ));
179+ for (String name : names ) {
180+ local .put (cast .toKey (name ), coll );
181+ }
182+ }
181183 }
182184 }
183185 }
186+ members = local ;
184187 }
185188 }
186189 }
@@ -268,22 +271,34 @@ public static void close(ImageInputStream iis) {
268271 }
269272 }
270273
274+ private static Method getCustomMethod ;
275+
271276 public static Set <String > getCoders (StringBuilder sb , PageContext pc ) {
272277 Set <String > result = null ;
273278 try {
274279 CFMLEngine eng = CFMLEngineFactory .getInstance ();
275280 if (pc == null ) pc = eng .getThreadPageContext ();
276281 if (pc == null ) return null ;
277- if (GetApplicationSettings == null ) {
278- GetApplicationSettings = eng .getClassUtil ().loadBIF (pc , "lucee.runtime.functions.system.GetApplicationSettings" );
282+
283+ Object ac = pc .getApplicationContext ();
284+ if (ac == null ) return null ;
285+
286+ // read this.image from ApplicationContext via getCustom(Key)
287+ Object o = null ;
288+ if (getCustomMethod == null || getCustomMethod .getDeclaringClass () != ac .getClass ()) {
289+ try {
290+ getCustomMethod = ac .getClass ().getMethod ("getCustom" , new Class [] { Collection .Key .class });
291+ }
292+ catch (NoSuchMethodException e ) {
293+ return null ;
294+ }
279295 }
280- Struct sct = ( Struct ) GetApplicationSettings .invoke (pc , new Object [] { Boolean . TRUE });
281- Object o = sct . get ( "image" , null );
296+ o = getCustomMethod .invoke (ac , new Object [] { eng . getCastUtil (). toKey ( "image" ) });
297+
282298 if (o instanceof Struct ) {
283299 Struct image = (Struct ) o ;
284- // type
285300 o = image .get ("coder" , null );
286- if (o == null ) image .get ("coders" , null );
301+ if (o == null ) o = image .get ("coders" , null );
287302
288303 if (o != null && eng .getDecisionUtil ().isCastableToArray (o )) {
289304 String [] coders = eng .getListUtil ().toStringArray (eng .getCastUtil ().toArray (o ));
@@ -295,7 +310,6 @@ public static Set<String> getCoders(StringBuilder sb, PageContext pc) {
295310 }
296311 }
297312 }
298-
299313 }
300314 catch (Exception e ) {
301315 Coder .log (pc );
0 commit comments