Skip to content

Commit

Permalink
TEIID-2427 improving the processing exception message and minor clean
Browse files Browse the repository at this point in the history
ups
  • Loading branch information
shawkins committed Mar 11, 2013
1 parent 3e07f29 commit a70c619
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 13 deletions.
Expand Up @@ -228,7 +228,7 @@ public void setSourceRequired(boolean value) {

/**
* Flag that indicates if a underlying source connection required for this execution factory to return metadata
* @return {@link Boolean#TRUE} if required, null if possibly required, or {@link Boolean#FALSE} if not required
* @return true if required
*/
public boolean isSourceRequiredForMetadata() {
if (sourceRequiredForMetadata == null) {
Expand Down
Expand Up @@ -396,7 +396,7 @@ public void run() {
public ResultsFuture<ResultsMessage> processCursorRequest(long reqID,
int batchFirst, int fetchSize) throws TeiidProcessingException {
if (LogManager.isMessageToBeRecorded(LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
LogManager.logDetail(LogConstants.CTX_DQP, "DQP process cursor request from " + batchFirst); //$NON-NLS-1$
LogManager.logDetail(LogConstants.CTX_DQP, "DQP process cursor request", batchFirst, fetchSize); //$NON-NLS-1$
}
DQPWorkContext workContext = DQPWorkContext.getWorkContext();
ResultsFuture<ResultsMessage> resultsFuture = new ResultsFuture<ResultsMessage>();
Expand Down
Expand Up @@ -343,12 +343,22 @@ private void handleThrowable(Throwable e) {
}
StackTraceElement[] elems = cause.getStackTrace();
Object elem = null;
if (elems.length > 0) {
elem = cause.getStackTrace()[0];
} else {
elem = cause.getMessage();
String causeMsg = cause.getMessage();
if (elems.length > 0) {
StackTraceElement ste = cause.getStackTrace()[0];
if (ste.getLineNumber() > 0 && ste.getFileName() != null) {
elem = ste.getFileName() + ":" + ste.getLineNumber(); //$NON-NLS-1$
} else {
elem = ste;
}
String msg = e.getMessage();
if (causeMsg != null && cause != e && !msg.contains(causeMsg)) {
elem = "'" + causeMsg + "' " + elem; //$NON-NLS-1$ //$NON-NLS-2$
}
} else if (cause != e && causeMsg != null) {
elem = "'" + cause.getMessage() + "'"; //$NON-NLS-1$ //$NON-NLS-2$
}
String msg = QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30020, e.getMessage(), requestID, e.getClass().getName(), elem);
String msg = QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30020, e.getMessage(), requestID, e.getClass().getSimpleName(), elem);
if (LogManager.isMessageToBeRecorded(LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
LogManager.logWarning(LogConstants.CTX_DQP, e, msg);
} else {
Expand Down
2 changes: 1 addition & 1 deletion engine/src/main/resources/org/teiid/query/i18n.properties
Expand Up @@ -860,7 +860,7 @@ TEIID30006=The maxActivePlan {0} setting should never be greater than the max pr

TEIID30028=Failed to properly rollback autowrap transaction properly
TEIID30019=Unexpected exception for request {0}
TEIID30020=Processing exception ''{0}'' for request {1}. Exception type {2} thrown from {3}.
TEIID30020=Processing exception for request {1} ''{0}''. Originally {2} {3}.
stack_info=\ Enable more detailed logging to see the entire stacktrace.

# #query (018.005)
Expand Down
Expand Up @@ -32,8 +32,8 @@
import java.util.concurrent.ExecutionException;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;

import javax.resource.spi.work.Work;

Expand Down Expand Up @@ -164,11 +164,11 @@ public void run() {

@Test public void testFailingWork() throws Exception {
ThreadReuseExecutor pool = new ThreadReuseExecutor("test", 5); //$NON-NLS-1$
final AtomicInteger count = new AtomicInteger();
final Semaphore signal = new Semaphore(1);
pool.execute(new Work() {
@Override
public void run() {
count.getAndIncrement();
signal.release();
throw new RuntimeException();
}

Expand All @@ -177,8 +177,7 @@ public void release() {

}
});
Thread.sleep(100);
assertEquals(1, count.get());
assertTrue(signal.tryAcquire(2, TimeUnit.SECONDS));
}

@Test public void testPriorities() throws Exception {
Expand Down

0 comments on commit a70c619

Please sign in to comment.