Commit b40638f4 authored by gmantele's avatar gmantele
Browse files

[TAP,UWS] Small log corrections (for Thread logs, display the thread name...

[TAP,UWS] Small log corrections (for Thread logs, display the thread name rather than the ID ; the job id was forgotten in the log of CHANGE_PHASE ; build a UWSException with the given throwable message as message ; in log TAP for the event EXECUTING, the memory address of the ADQLQuery object was displayed rather than of the ADQL query expression ; display the stack trace of the SQLException.getNextException() when calling logDB)
parent 262525ff
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -530,7 +530,7 @@ public class ADQLExecutor {
	 */
	protected TableIterator executeADQL(final ADQLQuery adql) throws InterruptedException, TAPException{
		// Log the start of execution:
		logger.logTAP(LogLevel.INFO, report, "EXECUTING", "Executing ADQL: " + adql.toString().replaceAll("(\t|\r?\n)+", " "), null);
		logger.logTAP(LogLevel.INFO, report, "EXECUTING", "Executing ADQL: " + adql.toADQL().replaceAll("(\t|\r?\n)+", " "), null);

		// Execute the ADQL query:
		TableIterator result = dbConn.executeQuery(adql);
+12 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ package tap.log;

import java.io.OutputStream;
import java.io.PrintWriter;
import java.sql.SQLException;

import tap.TAPExecutionReport;
import tap.TAPSyncJob;
@@ -88,7 +89,18 @@ public class DefaultTAPLog extends DefaultUWSLog implements TAPLog {

	@Override
	public void logDB(final LogLevel level, final DBConnection connection, final String event, final String message, final Throwable error){
		// log the main given error:
		log(level, "DB", event, (connection != null ? connection.getID() : null), message, error);

		/* Some SQL exceptions (like BatchUpdateException) have a next exception which provides more information.
		 * Here, the stack trace of the next exception is also logged:
		 */
		if (error != null && error instanceof SQLException && ((SQLException)error).getNextException() != null){
			PrintWriter out = getOutput(level, "DB");
			out.println("[NEXT EXCEPTION]");
			((SQLException)error).getNextException().printStackTrace(out);
			out.flush();
		}
	}

	@Override
+2 −2
Original line number Diff line number Diff line
@@ -139,7 +139,7 @@ public class UWSException extends Exception {
	 * @param t			The thrown (and so caught) exception.
	 */
	public UWSException(int httpError, Throwable t){
		this(httpError, t, null, null);
		this(httpError, t, (t != null) ? t.getMessage() : null, null);
	}

	/**
@@ -151,7 +151,7 @@ public class UWSException extends Exception {
	 * @param type		Type of the error (FATAL or TRANSIENT). <i>Note: If NULL, it will be considered as FATAL.</i>
	 */
	public UWSException(int httpError, Throwable t, ErrorType type){
		this(httpError, t, null, type);
		this(httpError, t, (t != null) ? t.getMessage() : null, type);
	}

	/**
+1 −1
Original line number Diff line number Diff line
@@ -575,7 +575,7 @@ public class UWSJob extends SerializableUWSObject {
			ExecutionPhase oldPhase = phase.getPhase();
			phase.setPhase(p, force);

			getLogger().logJob(LogLevel.INFO, this, "CHANGE_PHASE", "The job \"\" goes from " + oldPhase + " to " + p, null);
			getLogger().logJob(LogLevel.INFO, this, "CHANGE_PHASE", "The job \"" + getJobId() + "\" goes from " + oldPhase + " to " + p, null);

			// Notify the execution manager:
			if (phase.isFinished() && getJobList() != null)