From 3d2487151bca23cf5f0cc037850e362b4ee696de Mon Sep 17 00:00:00 2001 From: gmantele <gmantele@ari.uni-heidelberg.de> Date: Fri, 17 Oct 2014 15:35:21 +0200 Subject: [PATCH] [UWS] Correct the way the URL interpreter is used: at initilization with a HttpServletRequest, the full URL until the base URI should be saved + In UWSService, the used URL interpreter was a class attribute, which is a bad thing (this object is shared by several threads). --- src/uws/service/UWSService.java | 5 ++++- src/uws/service/UWSUrl.java | 12 ++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/uws/service/UWSService.java b/src/uws/service/UWSService.java index 01acdeb..a766e96 100644 --- a/src/uws/service/UWSService.java +++ b/src/uws/service/UWSService.java @@ -482,6 +482,8 @@ public class UWSService implements UWS { this.urlInterpreter = urlInterpreter; if (name == null && urlInterpreter != null) name = urlInterpreter.getUWSName(); + if (this.urlInterpreter != null) + this.urlInterpreter.setUwsURI(null); } /** @@ -1048,7 +1050,7 @@ public class UWSService implements UWS { JobOwner user = null; try{ - if (urlInterpreter == null){ + if (this.urlInterpreter == null){ // Initialize the URL interpreter if not already done: setUrlInterpreter(new UWSUrl(request)); @@ -1057,6 +1059,7 @@ public class UWSService implements UWS { } // Update the UWS URL interpreter: + UWSUrl urlInterpreter = new UWSUrl(this.urlInterpreter); urlInterpreter.load(request); // Identify the user: diff --git a/src/uws/service/UWSUrl.java b/src/uws/service/UWSUrl.java index 78e46cf..5b0cea9 100644 --- a/src/uws/service/UWSUrl.java +++ b/src/uws/service/UWSUrl.java @@ -17,7 +17,7 @@ package uws.service; * along with UWSLibrary. If not, see <http://www.gnu.org/licenses/>. * * Copyright 2012,2014 - UDS/Centre de Données astronomiques de Strasbourg (CDS), - * Astronomishes Rechen Institut (ARI) + * Astronomisches Rechen Institut (ARI) */ import java.io.Serializable; @@ -110,11 +110,15 @@ public class UWSUrl implements Serializable { * @see #extractBaseURI(HttpServletRequest) */ public UWSUrl(HttpServletRequest request) throws NullPointerException{ + // Extract the base URI: String uri = extractBaseURI(request); if (uri == null) throw new NullPointerException("The extracted base UWS URI is NULL!"); + else + baseURI = normalizeURI(uri); - baseURI = normalizeURI(uri); + // Load the rest of the request: + load(request); } /** @@ -503,9 +507,9 @@ public class UWSUrl implements Serializable { public final void setUwsURI(String uwsURI){ if (uwsURI == null || uwsURI.trim().length() == 0) this.uwsURI = null; - else{ + else this.uwsURI = uwsURI.trim(); - } + loadUwsURI(); updateRequestURL(); } -- GitLab