From: Pierre Queinnec <pierre.queinnec@zenika.com>
To: pgsql-jdbc@postgresql.org
Subject: Concurrency issue in EscapedFunctions
Date: Sat, 01 May 2010 18:59:14 +0200
Message-ID: <4BDC5DE2.7070402@zenika.com> (raw)
[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.comAttachments: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));
}
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: pierre.queinnec@zenika.com
Subject: Re: Concurrency issue in EscapedFunctions
In-Reply-To: <4BDC5DE2.7070402@zenika.com>
References: <4BDC5DE2.7070402@zenika.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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