From d8e311ad2a748b3d5e12c8ccc995715f7361e681 Mon Sep 17 00:00:00 2001 From: gmantele <gmantele@ari.uni-heidelberg.de> Date: Wed, 17 Sep 2014 20:11:20 +0200 Subject: [PATCH] [TAP] Fix bug: test NULL before formatting a string/text (for an XML document). --- src/tap/formatter/VOTableFormat.java | 2 +- src/tap/resource/Availability.java | 3 ++- src/tap/resource/TAP.java | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/tap/formatter/VOTableFormat.java b/src/tap/formatter/VOTableFormat.java index d5e07c8..ab2e76b 100644 --- a/src/tap/formatter/VOTableFormat.java +++ b/src/tap/formatter/VOTableFormat.java @@ -220,7 +220,7 @@ public class VOTableFormat implements OutputFormat { out.newLine(); // Indicate that the query has been successfully processed: [REQUIRED] - out.write("<INFO name=\"QUERY_STATUS\" value=\"ERROR\">" + VOSerializer.formatText(message) + "</INFO>"); + out.write("<INFO name=\"QUERY_STATUS\" value=\"ERROR\">" + (message == null ? "" : VOSerializer.formatText(message)) + "</INFO>"); out.newLine(); // Append the PROVIDER information (if any): [OPTIONAL] diff --git a/src/tap/resource/Availability.java b/src/tap/resource/Availability.java index fc10f97..003db0a 100644 --- a/src/tap/resource/Availability.java +++ b/src/tap/resource/Availability.java @@ -123,7 +123,8 @@ public class Availability implements TAPResource, VOSIResource { // reason/description of the (non-)availability: pw.print("\t<note>"); - pw.print(VOSerializer.formatText(service.getAvailability())); + if (service.getAvailability() != null) + pw.print(VOSerializer.formatText(service.getAvailability())); pw.println("</note>"); pw.println("</availability>"); diff --git a/src/tap/resource/TAP.java b/src/tap/resource/TAP.java index 696d80a..cc45b25 100644 --- a/src/tap/resource/TAP.java +++ b/src/tap/resource/TAP.java @@ -415,7 +415,7 @@ public class TAP implements VOSIResource { // TAP access: xml.append("\t<interface role=\"std\" xsi:type=\"vs:ParamHTTP\">\n"); - xml.append("\t\t<accessURL use=\"base\">").append(VOSerializer.formatText(getAccessURL())).append("</accessURL>\n"); + xml.append("\t\t<accessURL use=\"base\">").append((getAccessURL() == null) ? "" : VOSerializer.formatText(getAccessURL())).append("</accessURL>\n"); xml.append("\t</interface>\n"); // Language description: @@ -678,7 +678,7 @@ public class TAP implements VOSIResource { // Write the error in the response and return the appropriate HTTP status code: errorWriter.writeError(t, response, request, reqID, owner, resourceName); // Log the error: - getLogger().logHttp(LogLevel.ERROR, response, reqID, owner, "HTTP " + response.getStatus() + " - Can not complete the execution of the TAP resource \"" + resourceName + "\", because: " + t.getMessage(), t); + getLogger().logHttp(LogLevel.ERROR, response, reqID, owner, "HTTP " + response.getStatus() + " - Can not complete the execution of the TAP resource \"" + resourceName + "\"!", t); }finally{ // Notify the queue of the asynchronous jobs that a new connection is available: if (resourceName.equalsIgnoreCase(Sync.RESOURCE_NAME) && service.getFactory().countFreeConnections() >= 1) -- GitLab