pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Concurrency issue in EscapedFunctions
2+ messages / 2 participants
[nested] [flat]

* Concurrency issue in EscapedFunctions
@ 2010-05-01 16:59 Pierre Queinnec <pierre.queinnec@zenika.com>
  2010-08-10 18:19 ` Re: Concurrency issue in EscapedFunctions Kris Jurka <books@ejurka.com>
  0 siblings, 1 reply; 2+ messages in thread

From: Pierre Queinnec @ 2010-05-01 16:59 UTC (permalink / raw)
  To: pgsql-jdbc

[sending again as it never got delivered to the ML]

Hi,

It seems that there's a concurrency initialization issue in 
o.p.jdbc2.EscapedFunctions. I've attached a tentative fix for this.
BTW, thanks a lot Kris for the commits on my previous patches!

Cheers,
--
Pierre Queinnec
CTO - Zenika
http://www.zenika.com

Attachments:

EscapedFunctions.diff (text/plain, 2.3K) download Index: org/postgresql/jdbc2/EscapedFunctions.java =================================================================== RCS file: /cvsroot/jdbc/pgjdbc/org/postgresql/jdbc2/EscapedFunctions.java,v retrieving revision 1.12 diff -c -r1.12 EscapedFunctions.java *** org/postgresql/jdbc2/EscapedFunctions.java 16 Nov 2008 12:14:06 -0000 1.12 --- org/postgresql/jdbc2/EscapedFunctions.java 1 May 2010 15:40:10 -0000 *************** *** 116,138 **** /** storage for functions implementations */ ! private static Map functionMap = null; ! /** * get Method object implementing the given function * @param functionName name of the searched function * @return a Method object or null if not found */ public static Method getFunction(String functionName){ - if (functionMap==null){ - Method[] arrayMeths = EscapedFunctions.class.getDeclaredMethods(); - functionMap = new HashMap(arrayMeths.length*2); - for (int i=0;i<arrayMeths.length;i++){ - Method meth = arrayMeths[i]; - if (meth.getName().startsWith("sql")) - functionMap.put(meth.getName().toLowerCase(Locale.US),meth); - } - } return (Method) functionMap.get("sql"+functionName.toLowerCase(Locale.US)); } --- 116,143 ---- /** storage for functions implementations */ ! private static Map functionMap; ! ! static { ! initializeFunctionMap(); ! } ! ! private static void initializeFunctionMap() { ! Method[] arrayMeths = EscapedFunctions.class.getDeclaredMethods(); ! functionMap = new HashMap(arrayMeths.length*2); ! for (int i=0;i<arrayMeths.length;i++){ ! Method meth = arrayMeths[i]; ! if (meth.getName().startsWith("sql")) ! functionMap.put(meth.getName().toLowerCase(Locale.US),meth); ! } ! } ! /** * get Method object implementing the given function * @param functionName name of the searched function * @return a Method object or null if not found */ public static Method getFunction(String functionName){ return (Method) functionMap.get("sql"+functionName.toLowerCase(Locale.US)); }
^ permalink raw reply [nested|flat] 2+ messages in thread

* Re: Concurrency issue in EscapedFunctions
  2010-05-01 16:59 Concurrency issue in EscapedFunctions Pierre Queinnec <pierre.queinnec@zenika.com>
@ 2010-08-10 18:19 ` Kris Jurka <books@ejurka.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Kris Jurka @ 2010-08-10 18:19 UTC (permalink / raw)
  To: Pierre Queinnec <pierre.queinnec@zenika.com>; +Cc: pgsql-jdbc



On Sat, 1 May 2010, Pierre Queinnec wrote:

> It seems that there's a concurrency initialization issue in 
> o.p.jdbc2.EscapedFunctions. I've attached a tentative fix for this.

Applied.  Thanks.

Kris Jurka



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2010-08-10 18:19 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2010-05-01 16:59 Concurrency issue in EscapedFunctions Pierre Queinnec <pierre.queinnec@zenika.com>
2010-08-10 18:19 ` Kris Jurka <books@ejurka.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox