ASF Bugzilla – Attachment 28897 Details for
Bug 53374
DataSourceFactory does not support commitOnReturn property
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch for the fix.
apache_tomcat_bug_53374.diff (text/plain), 12.38 KB, created by
Suresh Avadhanula
on 2012-06-06 21:01:53 UTC
(
hide
)
Description:
Patch for the fix.
Filename:
MIME Type:
Creator:
Suresh Avadhanula
Created:
2012-06-06 21:01:53 UTC
Size:
12.38 KB
patch
obsolete
>Index: main/java/org/apache/tomcat/jdbc/pool/DataSourceFactory.java >=================================================================== >--- main/java/org/apache/tomcat/jdbc/pool/DataSourceFactory.java (revision 1306946) >+++ main/java/org/apache/tomcat/jdbc/pool/DataSourceFactory.java (working copy) >@@ -20,14 +20,8 @@ > import java.sql.Connection; > import java.util.Hashtable; > import java.util.Properties; >- > import javax.management.ObjectName; >-import javax.naming.Context; >-import javax.naming.InitialContext; >-import javax.naming.Name; >-import javax.naming.NamingException; >-import javax.naming.RefAddr; >-import javax.naming.Reference; >+import javax.naming.*; > import javax.naming.spi.ObjectFactory; > import javax.sql.DataSource; > >@@ -43,14 +37,15 @@ > * <br/> > * Properties available for configuration:<br/> > * <a href="http://commons.apache.org/dbcp/configuration.html">Commons DBCP properties</a><br/> >- *<ol> >- * <li>initSQL - A query that gets executed once, right after the connection is established.</li> >- * <li>testOnConnect - run validationQuery after connection has been established.</li> >- * <li>validationInterval - avoid excess validation, only run validation at most at this frequency - time in milliseconds.</li> >- * <li>jdbcInterceptors - a semicolon separated list of classnames extending {@link JdbcInterceptor} class.</li> >- * <li>jmxEnabled - true of false, whether to register the pool with JMX.</li> >- * <li>fairQueue - true of false, whether the pool should sacrifice a little bit of performance for true fairness.</li> >- *</ol> >+ * <ol> >+ * <li>initSQL - A query that gets executed once, right after the connection is established.</li> >+ * <li>testOnConnect - run validationQuery after connection has been established.</li> >+ * <li>validationInterval - avoid excess validation, only run validation at most at this frequency - time in milliseconds.</li> >+ * <li>jdbcInterceptors - a semicolon separated list of classnames extending {@link JdbcInterceptor} class.</li> >+ * <li>jmxEnabled - true of false, whether to register the pool with JMX.</li> >+ * <li>fairQueue - true of false, whether the pool should sacrifice a little bit of performance for true fairness.</li> >+ * </ol> >+ * > * @author Craig R. McClanahan > * @author Dirk Verbeeck > * @author Filip Hanik >@@ -106,85 +101,90 @@ > protected static final String PROP_USE_EQUALS = "useEquals"; > protected static final String PROP_USE_CON_LOCK = "useLock"; > >- protected static final String PROP_DATASOURCE= "dataSource"; >+ protected static final String PROP_DATASOURCE = "dataSource"; > protected static final String PROP_DATASOURCE_JNDI = "dataSourceJNDI"; > > protected static final String PROP_SUSPECT_TIMEOUT = "suspectTimeout"; > > protected static final String PROP_ALTERNATE_USERNAME_ALLOWED = "alternateUsernameAllowed"; > >+ protected static final String PROP_COMMIT_ON_RETURN = "commitOnReturn"; > >+ > public static final int UNKNOWN_TRANSACTIONISOLATION = -1; > > public static final String OBJECT_NAME = "object_name"; > > > protected static final String[] ALL_PROPERTIES = { >- PROP_DEFAULTAUTOCOMMIT, >- PROP_DEFAULTREADONLY, >- PROP_DEFAULTTRANSACTIONISOLATION, >- PROP_DEFAULTCATALOG, >- PROP_DRIVERCLASSNAME, >- PROP_MAXACTIVE, >- PROP_MAXIDLE, >- PROP_MINIDLE, >- PROP_INITIALSIZE, >- PROP_MAXWAIT, >- PROP_TESTONBORROW, >- PROP_TESTONRETURN, >- PROP_TIMEBETWEENEVICTIONRUNSMILLIS, >- PROP_NUMTESTSPEREVICTIONRUN, >- PROP_MINEVICTABLEIDLETIMEMILLIS, >- PROP_TESTWHILEIDLE, >- PROP_TESTONCONNECT, >- PROP_PASSWORD, >- PROP_URL, >- PROP_USERNAME, >- PROP_VALIDATIONQUERY, >- PROP_VALIDATOR_CLASS_NAME, >- PROP_VALIDATIONINTERVAL, >- PROP_ACCESSTOUNDERLYINGCONNECTIONALLOWED, >- PROP_REMOVEABANDONED, >- PROP_REMOVEABANDONEDTIMEOUT, >- PROP_LOGABANDONED, >- PROP_POOLPREPAREDSTATEMENTS, >- PROP_MAXOPENPREPAREDSTATEMENTS, >- PROP_CONNECTIONPROPERTIES, >- PROP_INITSQL, >- PROP_INTERCEPTORS, >- PROP_JMX_ENABLED, >- PROP_FAIR_QUEUE, >- PROP_USE_EQUALS, >- OBJECT_NAME, >- PROP_ABANDONWHENPERCENTAGEFULL, >- PROP_MAXAGE, >- PROP_USE_CON_LOCK, >- PROP_DATASOURCE, >- PROP_DATASOURCE_JNDI, >- PROP_SUSPECT_TIMEOUT, >- PROP_ALTERNATE_USERNAME_ALLOWED >+ PROP_DEFAULTAUTOCOMMIT, >+ PROP_DEFAULTREADONLY, >+ PROP_DEFAULTTRANSACTIONISOLATION, >+ PROP_DEFAULTCATALOG, >+ PROP_DRIVERCLASSNAME, >+ PROP_MAXACTIVE, >+ PROP_MAXIDLE, >+ PROP_MINIDLE, >+ PROP_INITIALSIZE, >+ PROP_MAXWAIT, >+ PROP_TESTONBORROW, >+ PROP_TESTONRETURN, >+ PROP_TIMEBETWEENEVICTIONRUNSMILLIS, >+ PROP_NUMTESTSPEREVICTIONRUN, >+ PROP_MINEVICTABLEIDLETIMEMILLIS, >+ PROP_TESTWHILEIDLE, >+ PROP_TESTONCONNECT, >+ PROP_PASSWORD, >+ PROP_URL, >+ PROP_USERNAME, >+ PROP_VALIDATIONQUERY, >+ PROP_VALIDATOR_CLASS_NAME, >+ PROP_VALIDATIONINTERVAL, >+ PROP_ACCESSTOUNDERLYINGCONNECTIONALLOWED, >+ PROP_REMOVEABANDONED, >+ PROP_REMOVEABANDONEDTIMEOUT, >+ PROP_LOGABANDONED, >+ PROP_POOLPREPAREDSTATEMENTS, >+ PROP_MAXOPENPREPAREDSTATEMENTS, >+ PROP_CONNECTIONPROPERTIES, >+ PROP_INITSQL, >+ PROP_INTERCEPTORS, >+ PROP_JMX_ENABLED, >+ PROP_FAIR_QUEUE, >+ PROP_USE_EQUALS, >+ OBJECT_NAME, >+ PROP_ABANDONWHENPERCENTAGEFULL, >+ PROP_MAXAGE, >+ PROP_USE_CON_LOCK, >+ PROP_DATASOURCE, >+ PROP_DATASOURCE_JNDI, >+ PROP_SUSPECT_TIMEOUT, >+ PROP_ALTERNATE_USERNAME_ALLOWED, >+ PROP_COMMIT_ON_RETURN >+ > }; > >+ > // -------------------------------------------------- ObjectFactory Methods > > /** > * <p>Create and return a new <code>BasicDataSource</code> instance. If no > * instance can be created, return <code>null</code> instead.</p> > * >- * @param obj The possibly null object containing location or >- * reference information that can be used in creating an object >- * @param name The name of this object relative to <code>nameCtx</code> >- * @param nameCtx The context relative to which the <code>name</code> >- * parameter is specified, or <code>null</code> if <code>name</code> >- * is relative to the default initial context >+ * @param obj The possibly null object containing location or >+ * reference information that can be used in creating an object >+ * @param name The name of this object relative to <code>nameCtx</code> >+ * @param nameCtx The context relative to which the <code>name</code> >+ * parameter is specified, or <code>null</code> if <code>name</code> >+ * is relative to the default initial context > * @param environment The possibly null environment that is used in >- * creating this object >+ * creating this object > * >- * @exception Exception if an exception occurs creating the instance >+ * @throws Exception if an exception occurs creating the instance > */ > @Override > public Object getObjectInstance(Object obj, Name name, Context nameCtx, >- Hashtable<?,?> environment) throws Exception { >+ Hashtable<?, ?> environment) throws Exception { > > // We only know how to deal with <code>javax.naming.Reference</code>s > // that specify a class name of "javax.sql.DataSource" >@@ -206,7 +206,7 @@ > } > > if (!ok) { >- log.warn(ref.getClassName()+" is not a valid class name/type for this JNDI factory."); >+ log.warn(ref.getClassName() + " is not a valid class name/type for this JNDI factory."); > return null; > } > >@@ -221,7 +221,7 @@ > } > } > >- return createDataSource(properties,nameCtx,XA); >+ return createDataSource(properties, nameCtx, XA); > } > > public static PoolConfiguration parsePoolProperties(Properties properties) { >@@ -402,11 +402,11 @@ > poolProperties.setDbProperties(new Properties()); > } > >- if (poolProperties.getUsername()!=null) { >- poolProperties.getDbProperties().setProperty("user",poolProperties.getUsername()); >+ if (poolProperties.getUsername() != null) { >+ poolProperties.getDbProperties().setProperty("user", poolProperties.getUsername()); > } >- if (poolProperties.getPassword()!=null) { >- poolProperties.getDbProperties().setProperty("password",poolProperties.getPassword()); >+ if (poolProperties.getPassword() != null) { >+ poolProperties.getDbProperties().setProperty("password", poolProperties.getPassword()); > } > > value = properties.getProperty(PROP_INITSQL); >@@ -476,6 +476,11 @@ > poolProperties.setAlternateUsernameAllowed(Boolean.parseBoolean(value)); > } > >+ value = properties.getProperty(PROP_COMMIT_ON_RETURN); >+ if (value != null) { >+ poolProperties.setCommitOnReturn(Boolean.parseBoolean(value)); >+ } >+ > return poolProperties; > } > >@@ -484,17 +489,19 @@ > * given properties. > * > * @param properties the datasource configuration properties >+ * > * @throws Exception if an error occurs creating the data source > */ > public DataSource createDataSource(Properties properties) throws Exception { >- return createDataSource(properties,null,false); >+ return createDataSource(properties, null, false); > } >- public DataSource createDataSource(Properties properties,Context context, boolean XA) throws Exception { >+ >+ public DataSource createDataSource(Properties properties, Context context, boolean XA) throws Exception { > PoolConfiguration poolProperties = DataSourceFactory.parsePoolProperties(properties); >- if (poolProperties.getDataSourceJNDI()!=null && poolProperties.getDataSource()==null) { >+ if (poolProperties.getDataSourceJNDI() != null && poolProperties.getDataSource() == null) { > performJNDILookup(context, poolProperties); > } >- org.apache.tomcat.jdbc.pool.DataSource dataSource = XA? >+ org.apache.tomcat.jdbc.pool.DataSource dataSource = XA ? > new org.apache.tomcat.jdbc.pool.XADataSource(poolProperties) : > new org.apache.tomcat.jdbc.pool.DataSource(poolProperties); > //initialise the pool itself >@@ -506,35 +513,38 @@ > public void performJNDILookup(Context context, PoolConfiguration poolProperties) { > Object jndiDS = null; > try { >- if (context!=null) { >+ if (context != null) { > jndiDS = context.lookup(poolProperties.getDataSourceJNDI()); > } else { > log.warn("dataSourceJNDI property is configued, but local JNDI context is null."); > } > } catch (NamingException e) { >- log.debug("The name \""+poolProperties.getDataSourceJNDI()+"\" can not be found in the local context."); >+ log.debug("The name \"" + poolProperties.getDataSourceJNDI() + "\" can not be found in the local context."); > } >- if (jndiDS==null) { >+ if (jndiDS == null) { > try { > context = new InitialContext(); > jndiDS = context.lookup(poolProperties.getDataSourceJNDI()); > } catch (NamingException e) { >- log.warn("The name \""+poolProperties.getDataSourceJNDI()+"\" can not be found in the InitialContext."); >+ log.warn("The name \"" + poolProperties.getDataSourceJNDI() + "\" can not be found in the InitialContext."); > } > } >- if (jndiDS!=null) { >+ if (jndiDS != null) { > poolProperties.setDataSource(jndiDS); > } > } > > /** > * <p>Parse properties from the string. Format of the string must be [propertyName=property;]*<p> >+ * > * @param propText >+ * > * @return Properties >+ * > * @throws Exception > */ > protected static Properties getProperties(String propText) { >- return PoolProperties.getProperties(propText,null); >+ return PoolProperties.getProperties(propText, null); > } > > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 53374
:
28897
|
28898