[teiid-commits] teiid SVN: r4180 - in trunk: engine/src/main/java/org/teiid/query/util and 1 other directory.

teiid-commits at lists.jboss.org teiid-commits at lists.jboss.org
Fri Jun 15 07:45:16 EDT 2012


Author: shawkins
Date: 2012-06-15 07:45:16 -0400 (Fri, 15 Jun 2012)
New Revision: 4180

Modified:
   trunk/api/src/main/java/org/teiid/CommandContext.java
   trunk/engine/src/main/java/org/teiid/query/util/CommandContext.java
Log:
TEIID-2073 adding a public call to add warnings via the commandcontext

Modified: trunk/api/src/main/java/org/teiid/CommandContext.java
===================================================================
--- trunk/api/src/main/java/org/teiid/CommandContext.java	2012-06-15 02:39:19 UTC (rev 4179)
+++ trunk/api/src/main/java/org/teiid/CommandContext.java	2012-06-15 11:45:16 UTC (rev 4180)
@@ -23,6 +23,7 @@
 package org.teiid;
 
 import java.io.Serializable;
+import java.sql.Statement;
 import java.util.Map;
 import java.util.TimeZone;
 
@@ -31,6 +32,7 @@
 import org.teiid.adminapi.DataPolicy;
 import org.teiid.adminapi.Session;
 import org.teiid.adminapi.VDB;
+import org.teiid.jdbc.TeiidSQLWarning;
 
 /**
  * Context information for the currently executing command.
@@ -156,5 +158,12 @@
 	 * @return
 	 */
 	ClassLoader getVDBClassLoader();
+	
+	/**
+     * Add an exception as a warning.  The exception will be wrapped by a {@link TeiidSQLWarning} for the client. 
+     * The warnings can be consumed through the {@link Statement#getWarnings()} method.  
+     * @param ex
+     */
+    void addWarning(Exception ex);
 
 }

Modified: trunk/engine/src/main/java/org/teiid/query/util/CommandContext.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/util/CommandContext.java	2012-06-15 02:39:19 UTC (rev 4179)
+++ trunk/engine/src/main/java/org/teiid/query/util/CommandContext.java	2012-06-15 11:45:16 UTC (rev 4180)
@@ -39,7 +39,6 @@
 import org.teiid.api.exception.query.QueryProcessingException;
 import org.teiid.common.buffer.BufferManager;
 import org.teiid.core.TeiidComponentException;
-import org.teiid.core.TeiidException;
 import org.teiid.core.util.ArgCheck;
 import org.teiid.core.util.ExecutorUtils;
 import org.teiid.core.util.LRUCache;
@@ -773,17 +772,24 @@
         if (globalState.warnings == null) {
             return null;
         }
-        List<Exception> copied = globalState.warnings;
-        globalState.warnings = null;
-        return copied;
+        synchronized (this.globalState) {
+            List<Exception> copied = globalState.warnings;
+            globalState.warnings = null;
+            return copied;
+		}
     }
     
-    public void addWarning(TeiidException warning) {
-        if (globalState.warnings == null) {
-        	globalState.warnings = new ArrayList<Exception>(1);
-        }
+    public void addWarning(Exception warning) {
+    	if (warning == null) {
+    		return;
+    	}
+    	synchronized (this.globalState) {
+            if (globalState.warnings == null) {
+            	globalState.warnings = new ArrayList<Exception>(1);
+            }
+            globalState.warnings.add(warning);
+		}
         LogManager.logInfo(LogConstants.CTX_DQP, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31105, warning.getMessage()));
-        globalState.warnings.add(warning);
     }
 
 }



More information about the teiid-commits mailing list