Author: tfischer
Date: Sat Nov 18 04:11:30 2006
New Revision: 476497
URL: http://svn.apache.org/viewvc?view=rev&rev=476497
Log:
Fixed a synchronisation issue in the getDateString() method of postgresql:
removed instance variable of SimpleDateFormat and replaced by local
instantiation.
According to the docs, SimpleDateFormat is not threadsafe and thus must either
be
instantiated locally or access must be synchronized.
Modified:
db/torque/runtime/trunk/src/java/org/apache/torque/adapter/DB.java
db/torque/runtime/trunk/src/java/org/apache/torque/adapter/DBPostgres.java
db/torque/site/trunk/xdocs/changes.xml
Modified: db/torque/runtime/trunk/src/java/org/apache/torque/adapter/DB.java
URL:
http://svn.apache.org/viewvc/db/torque/runtime/trunk/src/java/org/apache/torque/adapter/DB.java?view=diff&rev=476497&r1=476496&r2=476497
==============================================================================
--- db/torque/runtime/trunk/src/java/org/apache/torque/adapter/DB.java
(original)
+++ db/torque/runtime/trunk/src/java/org/apache/torque/adapter/DB.java Sat Nov
18 04:11:30 2006
@@ -41,6 +41,10 @@
* transparent swapping of databases is theoretically supported with
* <i>zero code changes</i> and minimal configuration file
* modifications.
+ *
+ * All database adapters need to be thread safe, as they are instantiated
+ * only once fore a gviven configured database and may be accessed
+ * simultaneously from several threads.
*
* <p>Torque uses the driver class name to find the right adapter.
* A JDBC driver corresponding to your adapter must be added to the properties
Modified:
db/torque/runtime/trunk/src/java/org/apache/torque/adapter/DBPostgres.java
URL:
http://svn.apache.org/viewvc/db/torque/runtime/trunk/src/java/org/apache/torque/adapter/DBPostgres.java?view=diff&rev=476497&r1=476496&r2=476497
==============================================================================
--- db/torque/runtime/trunk/src/java/org/apache/torque/adapter/DBPostgres.java
(original)
+++ db/torque/runtime/trunk/src/java/org/apache/torque/adapter/DBPostgres.java
Sat Nov 18 04:11:30 2006
@@ -21,6 +21,7 @@
import java.sql.Connection;
import java.sql.SQLException;
+import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
@@ -45,14 +46,11 @@
/** A specialized date format for PostgreSQL. */
private static final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";
- private SimpleDateFormat sdf = null;
-
/**
* Empty constructor.
*/
protected DBPostgres()
{
- sdf = new SimpleDateFormat(DATE_FORMAT);
}
/**
@@ -204,10 +202,11 @@
*/
public String getDateString(Date date)
{
+ DateFormat df = new SimpleDateFormat(DATE_FORMAT);
StringBuffer dateBuf = new StringBuffer();
char delim = getStringDelimiter();
dateBuf.append(delim);
- dateBuf.append(sdf.format(date));
+ dateBuf.append(df.format(date));
dateBuf.append(delim);
return dateBuf.toString();
}
Modified: db/torque/site/trunk/xdocs/changes.xml
URL:
http://svn.apache.org/viewvc/db/torque/site/trunk/xdocs/changes.xml?view=diff&rev=476497&r1=476496&r2=476497
==============================================================================
--- db/torque/site/trunk/xdocs/changes.xml (original)
+++ db/torque/site/trunk/xdocs/changes.xml Sat Nov 18 04:11:30 2006
@@ -31,6 +31,10 @@
<body>
<release version="3.2.1-dev" date="in SVN">
+ <action type="fix" dev="tfischer">
+ Fixed a synchronisation issue in the getDateString() method in
+ the database adapter for postgresql.
+ </action>
<action type="add" dev="tfischer" issue="TORQUE-44" due-to="Greg Monroe">
The Column names TABLE_NAME and DATABASE_NAME are now legal column
names.
</action>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]