Return-Path: X-Original-To: apmail-db-derby-commits-archive@www.apache.org Delivered-To: apmail-db-derby-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4254810285 for ; Thu, 29 Aug 2013 19:08:01 +0000 (UTC) Received: (qmail 26527 invoked by uid 500); 29 Aug 2013 19:08:01 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 26460 invoked by uid 500); 29 Aug 2013 19:07:58 -0000 Mailing-List: contact derby-commits-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: "Derby Development" List-Id: Delivered-To: mailing list derby-commits@db.apache.org Received: (qmail 26436 invoked by uid 99); 29 Aug 2013 19:07:57 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 29 Aug 2013 19:07:57 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 29 Aug 2013 19:07:54 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 4F242238888A; Thu, 29 Aug 2013 19:07:33 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1518766 - in /db/derby/code/trunk/java: client/org/apache/derby/jdbc/ClientBaseDataSourceRoot.java testing/org/apache/derbyTesting/functionTests/tests/derbynet/ClientSideSystemPropertiesTest.java Date: Thu, 29 Aug 2013 19:07:33 -0000 To: derby-commits@db.apache.org From: kmarsden@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20130829190733.4F242238888A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: kmarsden Date: Thu Aug 29 19:07:32 2013 New Revision: 1518766 URL: http://svn.apache.org/r1518766 Log: DERBY-5553 System property for client tracing -Dderby.client.traceDirectory does not work with XADataSource Modified: db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientBaseDataSourceRoot.java db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/ClientSideSystemPropertiesTest.java Modified: db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientBaseDataSourceRoot.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientBaseDataSourceRoot.java?rev=1518766&r1=1518765&r2=1518766&view=diff ============================================================================== --- db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientBaseDataSourceRoot.java (original) +++ db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientBaseDataSourceRoot.java Thu Aug 29 19:07:32 2013 @@ -425,7 +425,7 @@ public abstract class ClientBaseDataSour Attribute.CLIENT_JVM_PROPERTY_PREFIX + Attribute.CLIENT_TRACE_DIRECTORY); - if (traceDirectoryString == null) { + if (traceDirectoryString == null && properties != null) { return properties.getProperty(Attribute.CLIENT_TRACE_DIRECTORY); } else { return traceDirectoryString; @@ -989,12 +989,15 @@ public abstract class ClientBaseDataSour traceLevelString = readSystemProperty(Attribute.CLIENT_JVM_PROPERTY_PREFIX + Attribute.CLIENT_TRACE_LEVEL); - if (traceLevelString == null) { + if (traceLevelString == null && properties != null) { traceLevelString = properties.getProperty(Attribute.CLIENT_TRACE_LEVEL); } - - return parseInt(traceLevelString, propertyDefault_traceLevel); + if (traceLevelString != null ) { + return parseInt(traceLevelString, propertyDefault_traceLevel); + } else { + return propertyDefault_traceLevel; + } } synchronized public void setTraceLevel(int traceLevel) { @@ -1060,6 +1063,22 @@ public abstract class ClientBaseDataSour private void updateDataSourceValues(Properties prop) throws SqlException { + // DERBY-5553. System properties derby.client.traceDirectory + // and derby.client.traceLevel do not work for ClientXADataSource + // or ClientConnectionPoolDataSource + // Trace level and trace directory will be read from system + // properties if they are not specified in the Properties + // argument, so we check for them first to avoid getting cut + // off by the (prop == null) check below. + String traceDir = getTraceDirectory(prop); + if (traceDir != null) { + setTraceDirectory(traceDir); + } + + int traceLevel = getTraceLevel(prop); + if (traceLevel != propertyDefault_traceLevel) { + setTraceLevel(traceLevel); + } if (prop == null) { return; } @@ -1073,9 +1092,6 @@ public abstract class ClientBaseDataSour if (prop.containsKey(Attribute.CLIENT_TRACE_FILE)) { setTraceFile(getTraceFile(prop)); } - if (prop.containsKey(Attribute.CLIENT_TRACE_DIRECTORY)) { - setTraceDirectory(getTraceDirectory(prop)); - } if (prop.containsKey(Attribute.CLIENT_TRACE_APPEND)) { setTraceFileAppend(getTraceFileAppend(prop)); } Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/ClientSideSystemPropertiesTest.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/ClientSideSystemPropertiesTest.java?rev=1518766&r1=1518765&r2=1518766&view=diff ============================================================================== --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/ClientSideSystemPropertiesTest.java (original) +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/ClientSideSystemPropertiesTest.java Thu Aug 29 19:07:32 2013 @@ -23,11 +23,17 @@ package org.apache.derbyTesting.function import java.io.File; import java.security.AccessController; +import java.sql.Connection; import java.util.Properties; +import javax.sql.PooledConnection; +import javax.sql.XAConnection; + import junit.framework.Test; import org.apache.derbyTesting.junit.BaseJDBCTestCase; +import org.apache.derbyTesting.junit.J2EEDataSource; +import org.apache.derbyTesting.junit.JDBCDataSource; import org.apache.derbyTesting.junit.SystemPropertyTestSetup; import org.apache.derbyTesting.junit.TestConfiguration; @@ -38,7 +44,44 @@ public class ClientSideSystemPropertiesT * because we have set the system properties to enable client side * tracing. */ public void testConnection() throws Exception { - getConnection().setAutoCommit(false); + Connection conn = openDefaultConnection(); + conn.setAutoCommit(false); + checkTraceFileIsPresent(); + conn.rollback(); + conn.close(); + } + + public void testClientDataSourceConnection() throws Exception { + Connection conn = JDBCDataSource.getDataSource().getConnection(); + conn.setAutoCommit(false); + checkTraceFileIsPresent(); + conn.rollback(); + conn.close(); + } + + public void testClientCPDataSourceConnection() throws Exception { + PooledConnection pconn = J2EEDataSource.getConnectionPoolDataSource(). + getPooledConnection(); + Connection conn = pconn.getConnection(); + conn.setAutoCommit(false); + checkTraceFileIsPresent(); + conn.rollback(); + conn.close(); + pconn.close(); + } + + public void testClientXADataSourceConnection() throws Exception { + XAConnection xaconn = J2EEDataSource.getXADataSource(). + getXAConnection(); + Connection conn = xaconn.getConnection(); + conn.setAutoCommit(false); + checkTraceFileIsPresent(); + conn.close(); + xaconn.close(); + } + + + private void checkTraceFileIsPresent() { //Make sure the connection above created a trace file. This check is //made in the privilege block below by looking inside the //trace Directory and making sure the file count is greater than 0. @@ -74,7 +117,7 @@ public class ClientSideSystemPropertiesT File tempFile; for (;fileCounter