Commit 25a783a8 authored by Grégory Mantelet's avatar Grégory Mantelet
Browse files

[TAP] Fix intermixed VOTable documents in synchronous mode.

Fix #52
parent 30dc11cb
Loading
Loading
Loading
Loading
+37 −20
Original line number Original line Diff line number Diff line
@@ -16,7 +16,8 @@ package tap.formatter;
 * You should have received a copy of the GNU Lesser General Public License
 * You should have received a copy of the GNU Lesser General Public License
 * along with TAPLibrary.  If not, see <http://www.gnu.org/licenses/>.
 * along with TAPLibrary.  If not, see <http://www.gnu.org/licenses/>.
 *
 *
 * Copyright 2014-2015 - Astronomisches Rechen Institut (ARI)
 * Copyright 2014-2020 - UDS/Centre de Données astronomiques de Strasbourg (CDS)
 *                       Astronomisches Rechen Institut (ARI)
 */
 */


import java.io.IOException;
import java.io.IOException;
@@ -35,21 +36,24 @@ import uk.ac.starlink.table.StoragePolicy;
/**
/**
 * Format any given query (table) result into FITS.
 * Format any given query (table) result into FITS.
 *
 *
 * @author Gr&eacute;gory Mantelet (ARI)
 * @author Gr&eacute;gory Mantelet (CDS;ARI)
 * @version 2.1 (11/2015)
 * @version 2.4 (08/2020)
 * @since 2.0
 * @since 2.0
 */
 */
public class FITSFormat implements OutputFormat {
public class FITSFormat implements OutputFormat {


	/** The {@link ServiceConnection} to use (for the log and to have some information about the service (particularly: name, description). */
	/** The {@link ServiceConnection} to use (for the log and to have some
	 * information about the service (particularly: name, description). */
	protected final ServiceConnection service;
	protected final ServiceConnection service;


	/**
	/**
	 * Creates a FITS formatter.
	 * Creates a FITS formatter.
	 *
	 *
	 * @param service	The service to use (for the log and to have some information about the service (particularly: name, description).
	 * @param service	The service to use (for the log and to have some
	 *               	information about the service (particularly: name,
	 *               	description).
	 *
	 *
	 * @throws NullPointerException	If the given service connection is <code>null</code>.
	 * @throws NullPointerException	If the given service connection is NULL.
	 */
	 */
	public FITSFormat(final ServiceConnection service) throws NullPointerException {
	public FITSFormat(final ServiceConnection service) throws NullPointerException {
		if (service == null)
		if (service == null)
@@ -87,7 +91,20 @@ public class FITSFormat implements OutputFormat {
		LimitedStarTable table = new LimitedStarTable(result, colInfos, execReport.parameters.getMaxRec(), thread);
		LimitedStarTable table = new LimitedStarTable(result, colInfos, execReport.parameters.getMaxRec(), thread);


		// Copy the table on disk (or in memory if the table is short):
		// Copy the table on disk (or in memory if the table is short):
		StarTable copyTable = StoragePolicy.PREFER_DISK.copyTable(table);
		StarTable copyTable;
		try {
			copyTable = StoragePolicy.PREFER_DISK.copyTable(table);
		} catch(IOException ioe) {
			/* In case of time out, LimitedStarTable makes copyTable to stop by
			 * throwing an IOException. In such case, this IOException has to be
			 * interpreted as a normal interruption: */
			if (thread.isInterrupted())
				throw new InterruptedException();
			/* Otherwise, the error has to be managed properly (so, wrap it
			 * inside a TAPException): */
			else
				throw new TAPException("Unexpected error while formatting the result!", ioe);
		}


		if (thread.isInterrupted())
		if (thread.isInterrupted())
			throw new InterruptedException();
			throw new InterruptedException();
+268 −155

File changed.

Preview size limit exceeded, changes collapsed.