Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjfogell2006-02-06 12:40:47 -0500
committerjfogell2006-02-06 12:40:47 -0500
commitccd988bbab917bffab77a86ac4e5ca05689b23e5 (patch)
tree9fc25d07349523d5b757d6a47e797bbe7215ec03
parent57f62dc5268846fb59aa63bbc7cd8b13e5529bd6 (diff)
downloadrt.equinox.bundles-ccd988bbab917bffab77a86ac4e5ca05689b23e5.tar.gz
rt.equinox.bundles-ccd988bbab917bffab77a86ac4e5ca05689b23e5.tar.xz
rt.equinox.bundles-ccd988bbab917bffab77a86ac4e5ca05689b23e5.zip
removed compile warnings per bug #125844v20060206
-rw-r--r--bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/Activator.java6
-rw-r--r--bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/Http.java11
-rw-r--r--bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/HttpConfiguration.java4
-rw-r--r--bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/HttpDate.java13
-rw-r--r--bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/HttpListener.java7
-rw-r--r--bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/HttpService.java24
-rw-r--r--bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/HttpThread.java12
-rw-r--r--bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/HttpThreadPool.java17
-rw-r--r--bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/LogTracker.java1
-rw-r--r--bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/ResourceRegistration.java6
-rw-r--r--bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/ResourceUnavailableException.java4
-rw-r--r--bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/SecureAction.java12
-rw-r--r--bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/StaticDataReader.java15
-rw-r--r--bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/URI.java3
-rw-r--r--bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/servlet/HttpServletRequestImpl.java43
-rw-r--r--bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/servlet/HttpServletResponseImpl.java14
-rw-r--r--bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/servlet/HttpSessionContextImpl.java3
-rw-r--r--bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/servlet/HttpSessionImpl.java8
-rw-r--r--bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/servlet/RequestDispatcherImpl.java11
-rw-r--r--bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/servlet/ServletContextImpl.java11
-rw-r--r--bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/socket/https/HttpsServerSocket.java2
21 files changed, 119 insertions, 108 deletions
diff --git a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/Activator.java b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/Activator.java
index 6f456a74..013288d5 100644
--- a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/Activator.java
+++ b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/Activator.java
@@ -25,12 +25,6 @@ public class Activator implements BundleActivator {
private Http http = null;
- /** Need to have a public default constructor so that the BundleActivator
- * can be instantiated by Class.newInstance().
- */
- public Activator() {
- }
-
/**
* Required by BundleActivator Interface.
*/
diff --git a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/Http.java b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/Http.java
index b1d18b71..0d74aa0e 100644
--- a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/Http.java
+++ b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/Http.java
@@ -19,6 +19,7 @@ import org.eclipse.equinox.socket.ServerSocketInterface;
import org.eclipse.equinox.socket.https.HttpsServerSocket;
import org.eclipse.osgi.util.NLS;
import org.osgi.framework.BundleContext;
+import org.osgi.service.log.LogService;
public class Http {
public static final boolean DEBUG = false;
@@ -153,7 +154,7 @@ public class Http {
if (Http.DEBUG) {
System.out.println(message);
- log.log(log.LOG_DEBUG, message);
+ log.log(LogService.LOG_DEBUG, message);
}
}
@@ -162,7 +163,7 @@ public class Http {
System.out.println(message);
t.printStackTrace(System.out);
- log.log(log.LOG_DEBUG, message, t);
+ log.log(LogService.LOG_DEBUG, message, t);
}
}
@@ -172,7 +173,7 @@ public class Http {
t.printStackTrace(System.out);
}
- log.log(log.LOG_ERROR, message, t);
+ log.log(LogService.LOG_ERROR, message, t);
}
public void logInfo(String message) {
@@ -180,7 +181,7 @@ public class Http {
System.out.println(message);
}
- log.log(log.LOG_INFO, message);
+ log.log(LogService.LOG_INFO, message);
}
public void logWarning(String message, Throwable t) {
@@ -189,7 +190,7 @@ public class Http {
t.printStackTrace(System.out);
}
- log.log(log.LOG_WARNING, message, t);
+ log.log(LogService.LOG_WARNING, message, t);
}
protected ServerSocketInterface createSSLServerSocket(int port, int backlog, InetAddress address) throws IOException {
diff --git a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/HttpConfiguration.java b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/HttpConfiguration.java
index 2ec3105b..b65baa00 100644
--- a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/HttpConfiguration.java
+++ b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/HttpConfiguration.java
@@ -40,7 +40,7 @@ public class HttpConfiguration implements ManagedService, ManagedServiceFactory
/** Hashtable of HttpListener object configured by the ConfigurationAdmin
* Configuration PID (String) => HttpListener object
*/
- private Hashtable configuredListeners;
+ Hashtable configuredListeners;
protected Http http;
@@ -558,7 +558,7 @@ public class HttpConfiguration implements ManagedService, ManagedServiceFactory
priority = ((Integer) property).intValue();
- if ((priority < HttpThread.MIN_PRIORITY) || (priority > HttpThread.MAX_PRIORITY)) {
+ if ((priority < Thread.MIN_PRIORITY) || (priority > Thread.MAX_PRIORITY)) {
throw new ConfigurationException(key, "must be one of the Thread defined priorities"); //$NON-NLS-1$
}
}
diff --git a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/HttpDate.java b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/HttpDate.java
index 8f4c198a..dc9693f6 100644
--- a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/HttpDate.java
+++ b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/HttpDate.java
@@ -240,9 +240,8 @@ public class HttpDate {
time.set(year, month, day, hour, min, sec);
return;
} catch (NumberFormatException e) {
- }
-
- valid = false;
+ valid = false;
+ }
}
protected void parseRFC1036(String str) {
@@ -299,11 +298,9 @@ public class HttpDate {
}
time.set(year, month, day, hour, min, sec);
- return;
} catch (NumberFormatException e) {
+ valid = false;
}
-
- valid = false;
}
protected void parseRFC1123(String str) {
@@ -356,11 +353,11 @@ public class HttpDate {
}
time.set(year, month, day, hour, min, sec);
- return;
} catch (NumberFormatException e) {
+ valid = false;
}
- valid = false;
+
}
/**
diff --git a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/HttpListener.java b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/HttpListener.java
index e0169b25..c96f672b 100644
--- a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/HttpListener.java
+++ b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/HttpListener.java
@@ -8,4 +8,9 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-package org.eclipse.equinox.http; import java.io.IOException; import java.net.InetAddress; import java.net.Socket; import java.util.*; import javax.servlet.Servlet; import javax.servlet.ServletException; import org.eclipse.equinox.http.servlet.*; import org.eclipse.equinox.socket.ServerSocketInterface; import org.eclipse.equinox.socket.SocketInterface; import org.eclipse.osgi.util.NLS; import org.osgi.framework.*; import org.osgi.service.http.HttpContext; import org.osgi.service.http.NamespaceException; public class HttpListener extends Thread implements ServiceFactory { protected Http http; /** ServerSocket upon which this listener operates */ protected volatile ServerSocketInterface serverSocket; /** Controlling HttpConfiguration object */ protected HttpConfiguration configuration; /** if true this thread must terminate */ protected volatile boolean running; protected ServiceRegistration service; private String httpsvcClass = "org.osgi.service.http.HttpService"; //$NON-NLS-1$ protected Hashtable registrations; /** Mapping of HttpContext => ServletContextImpl */ protected Hashtable servletContexts; protected int socketTimeout; protected Object lock = new Object(); /** * Constructor. * */ protected HttpListener(Http http, HttpConfiguration configuration, Dictionary properties) throws IOException { this.http = http; this.configuration = configuration; registrations = new Hashtable(51); //initialize servletContext Hashtable servletContexts = new Hashtable(15); setProperties(properties); start(); } /** * Returns true if this thread has been closed. * @return boolean */ public boolean isClosed() { return (!running); } /** * Close this thread. */ public void close() { running = false; try { setProperties(null); } catch (IOException e) { /* this will not occur when calling with null */ } servletContexts = null; } /* * ---------------------------------------------------------------------- * ServiceFactory Interface implementation * ---------------------------------------------------------------------- */ public Object getService(Bundle bundle, ServiceRegistration reg) { return (new HttpService(this, bundle)); } public void ungetService(Bundle bundle, ServiceRegistration reg, Object service) { ((HttpService) service).destroy(); } public synchronized void setProperties(Dictionary properties) throws IOException { ServerSocketInterface oldServerSocket = serverSocket; if (properties != null) { String address = (String) properties.get(HttpConfiguration.keyHttpAddress); int port = ((Integer) (properties.get(HttpConfiguration.keyHttpPort))).intValue(); String scheme = (String) properties.get(HttpConfiguration.keyHttpScheme); socketTimeout = ((Integer) (properties.get(HttpConfiguration.keyHttpTimeout))).intValue() * 1000; if ("ALL".equalsIgnoreCase(address)) { //$NON-NLS-1$ address = null; } if ((serverSocket == null) || (port != serverSocket.getLocalPort()) || !scheme.equals(serverSocket.getScheme())) { serverSocket = configuration.createServerSocket(address, port, scheme); closeServerSocket(oldServerSocket); } else if ((serverSocket.getAddress() != null && !serverSocket.getAddress().equals(address)) || (serverSocket.getAddress() == null && address != null)) { serverSocket = null; closeServerSocket(oldServerSocket); serverSocket = configuration.createServerSocket(address, port, scheme); synchronized (lock) { lock.notify(); } } if (service == null) { service = http.context.registerService(httpsvcClass, this, properties); } else { service.setProperties(properties); } } else { serverSocket = null; closeServerSocket(oldServerSocket); service.unregister(); service = null; } } protected Object getProperty(String key) { return service.getReference().getProperty(key); } private void closeServerSocket(ServerSocketInterface oldServerSocket) { if (oldServerSocket != null) { try { try { Socket phonyClient = new Socket(InetAddress.getByName(oldServerSocket.getAddress()), oldServerSocket.getLocalPort()); phonyClient.close(); } catch (IOException e) { http.logWarning(HttpMsg.HTTP_UNEXPECTED_IOEXCEPTION, e); } } finally { try { oldServerSocket.close(); } catch (IOException e) { http.logWarning(HttpMsg.HTTP_UNEXPECTED_IOEXCEPTION, e); } } configuration.pool.recallThreads(); } } public void run() { running = true; while (running) { SocketInterface socket = null; try { if (serverSocket == null) { if (running) { try { synchronized (lock) { lock.wait(5000); } } catch (InterruptedException e) { } if (serverSocket == null) { running = false; continue; } } else { continue; } } ServerSocketInterface serverSocket = this.serverSocket; socket = serverSocket.acceptSock(); if (serverSocket != this.serverSocket) /* socket changed while we were waiting */ { try { socket.close(); } catch (IOException e) { } socket = null; } } catch (IOException e) { if (serverSocket != null) { http.logError(NLS.bind(HttpMsg.HTTP_ACCEPT_SOCKET_EXCEPTION, new Integer(serverSocket.getLocalPort())), e); } } if (socket != null) { HttpThread thread = configuration.pool.getThread(); if (thread != null) { thread.handleConnection(this, socket, socketTimeout); } else { try { socket.close(); } catch (Exception e) { } } } } } protected void handleConnection(SocketInterface socket) throws IOException, ServletException { /* Create the servlet request and response objects */ HttpServletResponseImpl response = new HttpServletResponseImpl(socket, http); HttpServletRequestImpl request = new HttpServletRequestImpl(socket, http, response); /* After the request and response objects are successfully created, * we enter a try/finally block to ensure that the response is * always closed. */ try { //Get the URI from socket String uri = request.getRequestURI(); //Get Registration object associated with the request Registration registration = getRegistration(uri); while (registration != null) { try { if (registration.getHttpContext().handleSecurity(request, response)) { //Service Request registration.service(request, response); } return; } catch (ResourceUnavailableException e) { uri = reduceURI(uri); if (uri == null) { registration = null; } else { registration = getRegistration(uri); } } } if (registration == null) { if (Http.DEBUG) { http.logDebug("File " + request.getRequestURI() + //$NON-NLS-1$ " not found -- No Registration object"); //$NON-NLS-1$ } response.sendError(response.SC_NOT_FOUND); } } finally { response.close(); /* close (and flush) the response output */ } } protected ResourceRegistration registerResources(Bundle bundle, String alias, String name, HttpContext httpContext) throws NamespaceException { synchronized (registrations) { if (Http.DEBUG) { http.logDebug("HttpService -- Registering Resource -- Alias = " + //$NON-NLS-1$ alias + " Name = " + name); //$NON-NLS-1$ } checkAlias(alias); //check to see if name is valid int length = name.length(); if (length > 1) { //we need to allow "/" and "" if (name.endsWith("/")) //$NON-NLS-1$ { throw new IllegalArgumentException(NLS.bind(HttpMsg.HTTP_RESOURCE_NAME_INVALID_EXCEPTION, name)); } } checkNamespace(alias); ResourceRegistration registration = new ResourceRegistration(bundle, alias, name, httpContext, http); registrations.put(alias, registration); return (registration); } } private void checkAlias(String alias) { //check to see if the alias is valid if (!alias.equals("/")) //$NON-NLS-1$ { //so one can register at "/" if (!alias.startsWith("/") || alias.endsWith("/")) //$NON-NLS-1$ //$NON-NLS-2$ { throw new IllegalArgumentException(NLS.bind(HttpMsg.HTTP_ALIAS_INVALID_EXCEPTION, alias)); } } } protected ServletRegistration registerServlet(Bundle bundle, String alias, Servlet servlet, Dictionary initparams, HttpContext httpContext) throws ServletException, NamespaceException { synchronized (registrations) { if (Http.DEBUG) { http.logDebug("HttpService -- Registering Servlet -- Alias = " + alias); //$NON-NLS-1$ } checkAlias(alias); checkNamespace(alias); if (servlet == null) { throw new NullPointerException(HttpMsg.HTTP_SERVLET_NULL_EXCEPTION); } if (http.servlets.contains(servlet)) { throw new ServletException(HttpMsg.HTTP_SERVLET_ALREADY_REGISTERED_EXCEPTION); } /* Determine the ServletContext */ ServletContextImpl servletContext = getServletContext(httpContext); //Create registration object ServletRegistration registration = new ServletRegistration(bundle, alias, servlet, httpContext, servletContext); //call servlet's init() method try { servlet.init(new ServletConfigImpl(servletContext, initparams)); } catch (ServletException e) { ungetServletContext(httpContext); throw e; } catch (Throwable t) { ungetServletContext(httpContext); throw new ServletException(HttpMsg.HTTP_SERVET_INIT_EXCEPTION, t); } http.servlets.addElement(servlet); registrations.put(alias, registration); return (registration); } } protected void unregister(Bundle bundle, String alias) throws IllegalArgumentException { synchronized (registrations) { Registration registration = (Registration) registrations.get(alias); if (registration != null) { //this is to prevent other bundles from unregistering a bundle's resource/servlet if (registration.getBundle() != bundle) { registration = null; } } removeRegistration(registration); } } protected HttpContext createDefaultHttpContext(Bundle bundle) { return (new DefaultHttpContext(bundle, http.securityTracker)); } protected ServletContextImpl getServletContext(HttpContext httpContext) { /* Determine the ServletContext */ ServletContextImpl servletContext = (ServletContextImpl) servletContexts.get(httpContext); if (servletContext == null) { servletContext = new ServletContextImpl(http, this, httpContext); servletContexts.put(httpContext, servletContext); } servletContext.incrUseCount(); return (servletContext); } protected void ungetServletContext(HttpContext httpContext) { ServletContextImpl servletContext = (ServletContextImpl) servletContexts.get(httpContext); if (servletContext != null) { int useCount = servletContext.decrUseCount(); if (useCount <= 0) { servletContexts.remove(httpContext); } } } protected void destroyBundle(Bundle bundle) { if (registrations != null) { if (Http.DEBUG) { http.logDebug("Removing bundle " + bundle + //$NON-NLS-1$ " from HttpListener"); //$NON-NLS-1$ } synchronized (registrations) { Enumeration e = registrations.elements(); while (e.hasMoreElements()) { Registration reg = (Registration) e.nextElement(); if (bundle == reg.getBundle()) { removeRegistration(reg); } } } } } private void checkNamespace(String uri) throws NamespaceException { // If alias already exists in master resource table, // throw NamespaceException if (registrations.get(uri) != null) { throw new NamespaceException(NLS.bind(HttpMsg.HTTP_ALIAS_ALREADY_REGISTERED_EXCEPTION, uri)); } } public Registration getRegistration(String uri) { synchronized (registrations) { while (uri != null) { Registration reg = (Registration) registrations.get(uri); if (reg != null) { return (reg); } uri = reduceURI(uri); } return (null); } } /** * Reduce the input URI per the HttpService spec. * * @param uri input URI to be reduced. * @return Reduced URI or null if no further reduction possible. */ private String reduceURI(String uri) { if (uri.equals("/")) //$NON-NLS-1$ { return (null); } int index = uri.lastIndexOf('/'); if (index < 0) { return (null); } if (index == 0) { return ("/"); //$NON-NLS-1$ } return (uri.substring(0, index)); } /** * Must be called while holding the registrations lock * */ private void removeRegistration(Registration registration) { if (registration == null) { throw new IllegalArgumentException(HttpMsg.HTTP_ALIAS_UNREGISTER_EXCEPTION); } registrations.remove(registration.getAlias()); if (registration instanceof ServletRegistration) { Servlet servlet = ((ServletRegistration) registration).getServlet(); http.servlets.removeElement(servlet); } // BUGBUG Must not call servlet.destroy while it is processing requests! // Servlet 2.2 Section 3.3.4 registration.destroy(); if (registration instanceof ServletRegistration) { ungetServletContext(registration.getHttpContext()); } } } \ No newline at end of file
+package org.eclipse.equinox.http; import java.io.IOException; import java.net.InetAddress; import java.net.Socket; import java.util.*; import javax.servlet.Servlet; import javax.servlet.ServletException; import javax.servlet.http.HttpServletResponse;
+
+import org.eclipse.equinox.http.servlet.*; import org.eclipse.equinox.socket.ServerSocketInterface; import org.eclipse.equinox.socket.SocketInterface; import org.eclipse.osgi.util.NLS; import org.osgi.framework.*; import org.osgi.service.http.HttpContext; import org.osgi.service.http.NamespaceException; public class HttpListener extends Thread implements ServiceFactory { protected Http http; /** ServerSocket upon which this listener operates */ protected volatile ServerSocketInterface serverSocket; /** Controlling HttpConfiguration object */ protected HttpConfiguration configuration; /** if true this thread must terminate */ protected volatile boolean running; protected ServiceRegistration service; private String httpsvcClass = "org.osgi.service.http.HttpService"; //$NON-NLS-1$ protected Hashtable registrations; /** Mapping of HttpContext => ServletContextImpl */ protected Hashtable servletContexts; protected int socketTimeout; protected Object lock = new Object(); /** * Constructor. * */ protected HttpListener(Http http, HttpConfiguration configuration, Dictionary properties) throws IOException { this.http = http; this.configuration = configuration; registrations = new Hashtable(51); //initialize servletContext Hashtable servletContexts = new Hashtable(15); setProperties(properties); start(); } /** * Returns true if this thread has been closed. * @return boolean */ public boolean isClosed() { return (!running); } /** * Close this thread. */ public void close() { running = false; try { setProperties(null); } catch (IOException e) { /* this will not occur when calling with null */ } servletContexts = null; } /* * ---------------------------------------------------------------------- * ServiceFactory Interface implementation * ---------------------------------------------------------------------- */ public Object getService(Bundle bundle, ServiceRegistration reg) { return (new HttpService(this, bundle)); } public void ungetService(Bundle bundle, ServiceRegistration reg, Object httpService) { ((HttpService) httpService).destroy(); } public synchronized void setProperties(Dictionary properties) throws IOException { ServerSocketInterface oldServerSocket = serverSocket; if (properties != null) { String address = (String) properties.get(HttpConfiguration.keyHttpAddress); int port = ((Integer) (properties.get(HttpConfiguration.keyHttpPort))).intValue(); String scheme = (String) properties.get(HttpConfiguration.keyHttpScheme); socketTimeout = ((Integer) (properties.get(HttpConfiguration.keyHttpTimeout))).intValue() * 1000; if ("ALL".equalsIgnoreCase(address)) { //$NON-NLS-1$ address = null; } if ((serverSocket == null) || (port != serverSocket.getLocalPort()) || !scheme.equals(serverSocket.getScheme())) { serverSocket = configuration.createServerSocket(address, port, scheme); closeServerSocket(oldServerSocket); } else if ((serverSocket.getAddress() != null && !serverSocket.getAddress().equals(address)) || (serverSocket.getAddress() == null && address != null)) { serverSocket = null; closeServerSocket(oldServerSocket); serverSocket = configuration.createServerSocket(address, port, scheme); synchronized (lock) { lock.notify(); } } if (service == null) { service = http.context.registerService(httpsvcClass, this, properties); } else { service.setProperties(properties); } } else { serverSocket = null; closeServerSocket(oldServerSocket); service.unregister(); service = null; } } protected Object getProperty(String key) { return service.getReference().getProperty(key); } private void closeServerSocket(ServerSocketInterface oldServerSocket) { if (oldServerSocket != null) { try { try { Socket phonyClient = new Socket(InetAddress.getByName(oldServerSocket.getAddress()), oldServerSocket.getLocalPort()); phonyClient.close(); } catch (IOException e) { http.logWarning(HttpMsg.HTTP_UNEXPECTED_IOEXCEPTION, e); } } finally { try { oldServerSocket.close(); } catch (IOException e) { http.logWarning(HttpMsg.HTTP_UNEXPECTED_IOEXCEPTION, e); } } configuration.pool.recallThreads(); } } public void run() { running = true; while (running) { SocketInterface socket = null; try { if (serverSocket == null) { if (running) { try { synchronized (lock) { lock.wait(5000); } } catch (InterruptedException e) {
+ // ignore and check exit condition } if (serverSocket == null) { running = false; continue; } } else { continue; } } ServerSocketInterface tempServerSocket = this.serverSocket; socket = tempServerSocket.acceptSock(); if (tempServerSocket != this.serverSocket) /* socket changed while we were waiting */ { try { socket.close(); } catch (IOException e) {
+ // TODO: consider logging } socket = null; } } catch (IOException e) { if (serverSocket != null) { http.logError(NLS.bind(HttpMsg.HTTP_ACCEPT_SOCKET_EXCEPTION, new Integer(serverSocket.getLocalPort())), e); } } if (socket != null) { HttpThread thread = configuration.pool.getThread(); if (thread != null) { thread.handleConnection(this, socket, socketTimeout); } else { try { socket.close(); } catch (Exception e) {
+ // TODO: consider logging } } } } } protected void handleConnection(SocketInterface socket) throws IOException, ServletException { /* Create the servlet request and response objects */ HttpServletResponseImpl response = new HttpServletResponseImpl(socket, http); HttpServletRequestImpl request = new HttpServletRequestImpl(socket, http, response); /* After the request and response objects are successfully created, * we enter a try/finally block to ensure that the response is * always closed. */ try { //Get the URI from socket String uri = request.getRequestURI(); //Get Registration object associated with the request Registration registration = getRegistration(uri); while (registration != null) { try { if (registration.getHttpContext().handleSecurity(request, response)) { //Service Request registration.service(request, response); } return; } catch (ResourceUnavailableException e) { uri = reduceURI(uri); if (uri == null) { registration = null; } else { registration = getRegistration(uri); } } } if (registration == null) { if (Http.DEBUG) { http.logDebug("File " + request.getRequestURI() + //$NON-NLS-1$ " not found -- No Registration object"); //$NON-NLS-1$ } response.sendError(HttpServletResponse.SC_NOT_FOUND); } } finally { response.close(); /* close (and flush) the response output */ } } protected ResourceRegistration registerResources(Bundle bundle, String alias, String name, HttpContext httpContext) throws NamespaceException { synchronized (registrations) { if (Http.DEBUG) { http.logDebug("HttpService -- Registering Resource -- Alias = " + //$NON-NLS-1$ alias + " Name = " + name); //$NON-NLS-1$ } checkAlias(alias); //check to see if name is valid int length = name.length(); if (length > 1) { //we need to allow "/" and "" if (name.endsWith("/")) //$NON-NLS-1$ { throw new IllegalArgumentException(NLS.bind(HttpMsg.HTTP_RESOURCE_NAME_INVALID_EXCEPTION, name)); } } checkNamespace(alias); ResourceRegistration registration = new ResourceRegistration(bundle, alias, name, httpContext, http); registrations.put(alias, registration); return (registration); } } private void checkAlias(String alias) { //check to see if the alias is valid if (!alias.equals("/")) //$NON-NLS-1$ { //so one can register at "/" if (!alias.startsWith("/") || alias.endsWith("/")) //$NON-NLS-1$ //$NON-NLS-2$ { throw new IllegalArgumentException(NLS.bind(HttpMsg.HTTP_ALIAS_INVALID_EXCEPTION, alias)); } } } protected ServletRegistration registerServlet(Bundle bundle, String alias, Servlet servlet, Dictionary initparams, HttpContext httpContext) throws ServletException, NamespaceException { synchronized (registrations) { if (Http.DEBUG) { http.logDebug("HttpService -- Registering Servlet -- Alias = " + alias); //$NON-NLS-1$ } checkAlias(alias); checkNamespace(alias); if (servlet == null) { throw new NullPointerException(HttpMsg.HTTP_SERVLET_NULL_EXCEPTION); } if (http.servlets.contains(servlet)) { throw new ServletException(HttpMsg.HTTP_SERVLET_ALREADY_REGISTERED_EXCEPTION); } /* Determine the ServletContext */ ServletContextImpl servletContext = getServletContext(httpContext); //Create registration object ServletRegistration registration = new ServletRegistration(bundle, alias, servlet, httpContext, servletContext); //call servlet's init() method try { servlet.init(new ServletConfigImpl(servletContext, initparams)); } catch (ServletException e) { ungetServletContext(httpContext); throw e; } catch (Throwable t) { ungetServletContext(httpContext); throw new ServletException(HttpMsg.HTTP_SERVET_INIT_EXCEPTION, t); } http.servlets.addElement(servlet); registrations.put(alias, registration); return (registration); } } protected void unregister(Bundle bundle, String alias) throws IllegalArgumentException { synchronized (registrations) { Registration registration = (Registration) registrations.get(alias); if (registration != null) { //this is to prevent other bundles from unregistering a bundle's resource/servlet if (registration.getBundle() != bundle) { registration = null; } } removeRegistration(registration); } } protected HttpContext createDefaultHttpContext(Bundle bundle) { return (new DefaultHttpContext(bundle, http.securityTracker)); } protected ServletContextImpl getServletContext(HttpContext httpContext) { /* Determine the ServletContext */ ServletContextImpl servletContext = (ServletContextImpl) servletContexts.get(httpContext); if (servletContext == null) { servletContext = new ServletContextImpl(http, this, httpContext); servletContexts.put(httpContext, servletContext); } servletContext.incrUseCount(); return (servletContext); } protected void ungetServletContext(HttpContext httpContext) { ServletContextImpl servletContext = (ServletContextImpl) servletContexts.get(httpContext); if (servletContext != null) { int useCount = servletContext.decrUseCount(); if (useCount <= 0) { servletContexts.remove(httpContext); } } } protected void destroyBundle(Bundle bundle) { if (registrations != null) { if (Http.DEBUG) { http.logDebug("Removing bundle " + bundle + //$NON-NLS-1$ " from HttpListener"); //$NON-NLS-1$ } synchronized (registrations) { Enumeration e = registrations.elements(); while (e.hasMoreElements()) { Registration reg = (Registration) e.nextElement(); if (bundle == reg.getBundle()) { removeRegistration(reg); } } } } } private void checkNamespace(String uri) throws NamespaceException { // If alias already exists in master resource table, // throw NamespaceException if (registrations.get(uri) != null) { throw new NamespaceException(NLS.bind(HttpMsg.HTTP_ALIAS_ALREADY_REGISTERED_EXCEPTION, uri)); } } public Registration getRegistration(String uri) { synchronized (registrations) { while (uri != null) { Registration reg = (Registration) registrations.get(uri); if (reg != null) { return (reg); } uri = reduceURI(uri); } return (null); } } /** * Reduce the input URI per the HttpService spec. * * @param uri input URI to be reduced. * @return Reduced URI or null if no further reduction possible. */ private String reduceURI(String uri) { if (uri.equals("/")) //$NON-NLS-1$ { return (null); } int index = uri.lastIndexOf('/'); if (index < 0) { return (null); } if (index == 0) { return ("/"); //$NON-NLS-1$ } return (uri.substring(0, index)); } /** * Must be called while holding the registrations lock * */ private void removeRegistration(Registration registration) { if (registration == null) { throw new IllegalArgumentException(HttpMsg.HTTP_ALIAS_UNREGISTER_EXCEPTION); } registrations.remove(registration.getAlias()); if (registration instanceof ServletRegistration) { Servlet servlet = ((ServletRegistration) registration).getServlet(); http.servlets.removeElement(servlet); } // BUGBUG Must not call servlet.destroy while it is processing requests! // Servlet 2.2 Section 3.3.4 registration.destroy(); if (registration instanceof ServletRegistration) { ungetServletContext(registration.getHttpContext()); } } }
diff --git a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/HttpService.java b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/HttpService.java
index 4482bc36..2bc7c333 100644
--- a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/HttpService.java
+++ b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/HttpService.java
@@ -32,42 +32,42 @@ public class HttpService implements org.osgi.service.http.HttpService {
}
public void registerResources(String alias, String name, HttpContext httpContext) throws NamespaceException {
- HttpListener listener = this.listener;
+ HttpListener tempListener = this.listener;
- if (listener != null) {
+ if (tempListener != null) {
if (httpContext == null) {
httpContext = createDefaultHttpContext();
}
- listener.registerResources(bundle, alias, name, httpContext);
+ tempListener.registerResources(bundle, alias, name, httpContext);
}
}
public void registerServlet(String alias, Servlet servlet, java.util.Dictionary initparams, HttpContext httpContext) throws ServletException, NamespaceException, IllegalArgumentException {
- HttpListener listener = this.listener;
+ HttpListener tempListener = this.listener;
- if (listener != null) {
+ if (tempListener != null) {
if (httpContext == null) {
httpContext = createDefaultHttpContext();
}
- listener.registerServlet(bundle, alias, servlet, initparams, httpContext);
+ tempListener.registerServlet(bundle, alias, servlet, initparams, httpContext);
}
}
public void unregister(String alias) throws IllegalArgumentException {
- HttpListener listener = this.listener;
+ HttpListener tempListener = this.listener;
- if (listener != null) {
- listener.unregister(bundle, alias);
+ if (tempListener != null) {
+ tempListener.unregister(bundle, alias);
}
}
public HttpContext createDefaultHttpContext() {
- HttpListener listener = this.listener;
+ HttpListener tempListener = this.listener;
- if (listener != null) {
- return (listener.createDefaultHttpContext(bundle));
+ if (tempListener != null) {
+ return (tempListener.createDefaultHttpContext(bundle));
}
return (null);
diff --git a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/HttpThread.java b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/HttpThread.java
index 70553b98..4df2e92b 100644
--- a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/HttpThread.java
+++ b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/HttpThread.java
@@ -70,6 +70,7 @@ public class HttpThread extends Thread {
try {
socket.close();
} catch (IOException e) {
+ // TODO: consider logging
}
}
}
@@ -91,20 +92,21 @@ public class HttpThread extends Thread {
socket.close();
} catch (IOException e) {
+ // TODO: consider logging
}
}
supportKeepAlive = false;
}
- public synchronized void handleConnection(HttpListener listener, SocketInterface socket, int socketTimeout) {
+ public synchronized void handleConnection(HttpListener listenerParam, SocketInterface socketParam, int socketTimeout) {
if (running) {
- this.listener = listener;
- this.socket = socket;
+ this.listener = listenerParam;
+ this.socket = socketParam;
if (socketTimeout > 0) {
try {
- socket.setSoTimeout(socketTimeout);
+ socketParam.setSoTimeout(socketTimeout);
supportKeepAlive = true;
} catch (SocketException e) {
@@ -139,6 +141,7 @@ public class HttpThread extends Thread {
try {
wait();
} catch (InterruptedException e) {
+ // ignore and check exit condition
}
}
}
@@ -207,6 +210,7 @@ public class HttpThread extends Thread {
socket.close();
} catch (IOException e) {
+ // TODO: consider logging
}
}
diff --git a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/HttpThreadPool.java b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/HttpThreadPool.java
index 5d27fbc0..bcf730dd 100644
--- a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/HttpThreadPool.java
+++ b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/HttpThreadPool.java
@@ -33,7 +33,7 @@ public class HttpThreadPool extends ThreadGroup {
/** number of threads to be terminated when they are returned to the pool */
private int hitCount;
/** Thread allocation number */
- private int number;
+ int number;
/** prevent new threads from readjusting */
private int adjusting = 0;
@@ -177,10 +177,10 @@ public class HttpThreadPool extends ThreadGroup {
* @param priority Thread priority.
*/
public void setPriority(int priority) {
- if ((HttpThread.MIN_PRIORITY <= priority) && (priority <= HttpThread.MAX_PRIORITY)) {
+ if ((Thread.MIN_PRIORITY <= priority) && (priority <= Thread.MAX_PRIORITY)) {
this.priority = priority;
} else {
- throw new IllegalArgumentException(NLS.bind(HttpMsg.HTTP_INVALID_VALUE_RANGE_EXCEPTION, new Object[] {new Integer(HttpThread.MIN_PRIORITY), new Integer(HttpThread.MAX_PRIORITY)}));
+ throw new IllegalArgumentException(NLS.bind(HttpMsg.HTTP_INVALID_VALUE_RANGE_EXCEPTION, new Object[] {new Integer(Thread.MIN_PRIORITY), new Integer(Thread.MAX_PRIORITY)}));
}
}
@@ -240,11 +240,11 @@ public class HttpThreadPool extends ThreadGroup {
}
return (thread);
- } else {
- try {
- wait();
- } catch (InterruptedException e) {
- }
+ }
+ try {
+ wait();
+ } catch (InterruptedException e) {
+ // ignore and check exit condition
}
}
@@ -267,6 +267,7 @@ public class HttpThreadPool extends ThreadGroup {
setDaemon(true);
destroy();
} catch (Exception e) {
+ // TODO: consider logging
}
}
diff --git a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/LogTracker.java b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/LogTracker.java
index 9f743644..112d0560 100644
--- a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/LogTracker.java
+++ b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/LogTracker.java
@@ -79,6 +79,7 @@ public class LogTracker extends ServiceTracker implements LogService {
try {
service.log(reference, level, message, exception);
} catch (Exception e) {
+ // TODO: consider printing to System Error
}
}
}
diff --git a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/ResourceRegistration.java b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/ResourceRegistration.java
index d25bb3e8..73830499 100644
--- a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/ResourceRegistration.java
+++ b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/ResourceRegistration.java
@@ -16,6 +16,7 @@ import java.net.URLConnection;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.*;
+
import org.eclipse.equinox.http.servlet.HttpServletRequestImpl;
import org.eclipse.equinox.http.servlet.HttpServletResponseImpl;
import org.osgi.framework.Bundle;
@@ -26,6 +27,7 @@ import org.osgi.service.http.HttpContext;
*/
public class ResourceRegistration extends HttpServlet implements Registration {
+ private static final long serialVersionUID = -8732464938673729607L;
protected Bundle bundle;
protected HttpContext httpContext;
protected String alias;
@@ -110,7 +112,7 @@ public class ResourceRegistration extends HttpServlet implements Registration {
if (modifiedSince >= 0) {
long modified = conn.getLastModified();
if ((modified > 0) && (modifiedSince >= modified)) {
- response.setStatus(response.SC_NOT_MODIFIED);
+ response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
return;
}
}
@@ -119,7 +121,7 @@ public class ResourceRegistration extends HttpServlet implements Registration {
try {
in = conn.getInputStream();
} catch (IOException ex) {
- response.sendError(response.SC_NOT_FOUND);
+ response.sendError(HttpServletResponse.SC_NOT_FOUND);
return;
}
diff --git a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/ResourceUnavailableException.java b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/ResourceUnavailableException.java
index 25812dcf..f747b3aa 100644
--- a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/ResourceUnavailableException.java
+++ b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/ResourceUnavailableException.java
@@ -11,7 +11,5 @@
package org.eclipse.equinox.http;
public class ResourceUnavailableException extends RuntimeException {
- public ResourceUnavailableException() {
- super();
- }
+ private static final long serialVersionUID = 4662869318092654517L;
} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/SecureAction.java b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/SecureAction.java
index b03ce434..2b884f4f 100644
--- a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/SecureAction.java
+++ b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/SecureAction.java
@@ -54,17 +54,17 @@ public class SecureAction {
if (System.getSecurityManager() == null)
return open(url);
try {
- return (URLConnection) AccessController.doPrivileged(new PrivilegedExceptionAction() {
- public Object run() throws IOException{
- return open(url);
- }
- }, controlContext);
+ return (URLConnection) AccessController.doPrivileged(new PrivilegedExceptionAction() {
+ public Object run() throws IOException {
+ return open(url);
+ }
+ }, controlContext);
} catch(PrivilegedActionException ex) {
throw (IOException) ex.getException();
}
}
- private URLConnection open(final URL url)throws IOException
+ URLConnection open(final URL url)throws IOException
{
URLConnection connection = url.openConnection();
connection.connect(); /* establish connection to check permissions */
diff --git a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/StaticDataReader.java b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/StaticDataReader.java
index 8ce2a4f3..571af8ab 100644
--- a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/StaticDataReader.java
+++ b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/StaticDataReader.java
@@ -91,7 +91,7 @@ public class StaticDataReader {
* @return Default MIME type Hashtable
*/
private Hashtable parseMimeTypes(InputStream in) {
- Hashtable mimeTypes = new Hashtable();
+ Hashtable resultMimeTypes = new Hashtable();
if (in != null) {
try {
@@ -108,7 +108,7 @@ public class StaticDataReader {
String type = tokens.nextToken();
while (tokens.hasMoreTokens()) {
String ext = tokens.nextToken();
- mimeTypes.put(ext.toLowerCase(), type);
+ resultMimeTypes.put(ext.toLowerCase(), type);
}
}
}
@@ -118,18 +118,19 @@ public class StaticDataReader {
try {
in.close();
} catch (IOException e) {
+ // TODO: consider logging
}
}
}
- return (mimeTypes);
+ return (resultMimeTypes);
}
/**
* This method was created in VisualAge.
*/
private Hashtable parseStatusCodes(InputStream in) {
- Hashtable statusCodes = new Hashtable();
+ Hashtable resultStatusCodes = new Hashtable();
if (in != null) {
try {
@@ -145,7 +146,7 @@ public class StaticDataReader {
int space = line.indexOf(' ');
Integer status = new Integer(line.substring(0, space));
String statusPhrase = line.substring(space + 1);
- statusCodes.put(status, statusPhrase);
+ resultStatusCodes.put(status, statusPhrase);
}
}
} catch (Exception e) {
@@ -154,11 +155,12 @@ public class StaticDataReader {
try {
in.close();
} catch (IOException e) {
+ // TODO: consider logging
}
}
}
- return (statusCodes);
+ return (resultStatusCodes);
}
/**
@@ -213,6 +215,7 @@ public class StaticDataReader {
try {
in.close();
} catch (IOException ee) {
+ // TODO: consider logging
}
}
}
diff --git a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/URI.java b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/URI.java
index 0b36e8e6..20e519b9 100644
--- a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/URI.java
+++ b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/URI.java
@@ -13,9 +13,6 @@ package org.eclipse.equinox.http;
import java.io.UnsupportedEncodingException;
public class URI {
- private URI() {
- }
-
/**
* Takes an encoded string and decodes it
* @param input encoded String
diff --git a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/servlet/HttpServletRequestImpl.java b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/servlet/HttpServletRequestImpl.java
index f5870bb9..991c774d 100644
--- a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/servlet/HttpServletRequestImpl.java
+++ b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/servlet/HttpServletRequestImpl.java
@@ -16,6 +16,7 @@ import java.util.*;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletInputStream;
import javax.servlet.http.*;
+
import org.eclipse.equinox.http.*;
import org.eclipse.equinox.socket.SocketInterface;
import org.eclipse.osgi.util.NLS;
@@ -79,23 +80,21 @@ public class HttpServletRequestImpl implements HttpServletRequest {
/**
* Initialize additional request data.
*
- * @param servletPath URI alias for this request
- * @param servletContext ServletContext for this request
+ * @param servletPathParam URI alias for this request
+ * @param servletContextParam ServletContext for this request
*/
- public void init(String servletPath, ServletContextImpl servletContext) {
+ public void init(String servletPathParam, ServletContextImpl servletContextParam) {
// BUGBUG Need to deal with context path
// Servlet 2.2 Section 5.4
- this.servletPath = servletPath;
- this.servletContext = servletContext;
-
- int len = servletPath.length();
+ this.servletPath = servletPathParam;
+ this.servletContext = servletContextParam;
- String pathInfo = reqURI.substring(servletPath.length());
- if ((pathInfo.length() == 0) || pathInfo.equals("/")) //$NON-NLS-1$
+ String tempPathInfo = reqURI.substring(servletPathParam.length());
+ if ((tempPathInfo.length() == 0) || tempPathInfo.equals("/")) //$NON-NLS-1$
{
/* leave as null */
} else {
- this.pathInfo = pathInfo;
+ this.pathInfo = tempPathInfo;
}
if (authType == null) {
@@ -222,7 +221,8 @@ public class HttpServletRequestImpl implements HttpServletRequest {
if (index >= 0) {
Tokenizer tokenizer = new Tokenizer(contentType);
- String mime_type = tokenizer.getToken(";"); //$NON-NLS-1$
+ // TODO: verify next statement. It was String mimetype = tokenizer.getToken(";");
+ tokenizer.getToken(";"); //$NON-NLS-1$
tokenizer.getChar(); /* eat semicolon */
parseloop: while (true) {
@@ -341,9 +341,8 @@ public class HttpServletRequestImpl implements HttpServletRequest {
if (d.isValid()) {
return (d.getAsLong()); // Parsed OK, so get the value as a Long
- } else {
- throw new IllegalArgumentException();
}
+ throw new IllegalArgumentException();
}
return (-1);
@@ -885,11 +884,11 @@ public class HttpServletRequestImpl implements HttpServletRequest {
* @see #getSession
*/
public boolean isRequestedSessionIdValid() {
- HttpSession session = getSession(false); /* get current session, if any */
+ HttpSession currentSession = getSession(false); /* get current session, if any */
- if (session != null) /* if there is a session, see if it the requested session */
+ if (currentSession != null) /* if there is a session, see if it the requested session */
{
- return (session.getId().equals(getRequestedSessionId()));
+ return (currentSession.getId().equals(getRequestedSessionId()));
}
return (false);
@@ -1297,7 +1296,7 @@ public class HttpServletRequestImpl implements HttpServletRequest {
}
try {
- response.sendError(response.SC_REQUEST_ENTITY_TOO_LARGE);
+ response.sendError(HttpServletResponse.SC_REQUEST_ENTITY_TOO_LARGE);
} finally {
response.close();
}
@@ -1410,7 +1409,7 @@ public class HttpServletRequestImpl implements HttpServletRequest {
* @see javax.servlet.ServletRequest#setCharacterEncoding(String)
*/
public void setCharacterEncoding(String env) throws UnsupportedEncodingException, UnsupportedOperationException {
- throw new UnsupportedOperationException(HttpMsg.HTTP_ONLY_SUPPORTS_2_1); //$NON-NLS-1$
+ throw new UnsupportedOperationException(HttpMsg.HTTP_ONLY_SUPPORTS_2_1);
}
/* For compilation only. Will not implement.
@@ -1418,7 +1417,7 @@ public class HttpServletRequestImpl implements HttpServletRequest {
*/
public String getLocalAddr() {
//return(socket.getInetAddress().getLocalHost().getHostAddress());
- throw new UnsupportedOperationException(HttpMsg.HTTP_ONLY_SUPPORTS_2_1); //$NON-NLS-1$
+ throw new UnsupportedOperationException(HttpMsg.HTTP_ONLY_SUPPORTS_2_1);
}
/* For compilation only. Will not implement.
@@ -1426,20 +1425,20 @@ public class HttpServletRequestImpl implements HttpServletRequest {
*/
public String getLocalName() {
//return(socket.getInetAddress().getLocalHost().getHostName());
- throw new UnsupportedOperationException(HttpMsg.HTTP_ONLY_SUPPORTS_2_1); //$NON-NLS-1$
+ throw new UnsupportedOperationException(HttpMsg.HTTP_ONLY_SUPPORTS_2_1);
}
/* For compilation only. Will not implement.
*
*/
public int getLocalPort() {
- throw new UnsupportedOperationException(HttpMsg.HTTP_ONLY_SUPPORTS_2_1); //$NON-NLS-1$
+ throw new UnsupportedOperationException(HttpMsg.HTTP_ONLY_SUPPORTS_2_1);
}
/* For compilation only. Will not implement.
*
*/
public int getRemotePort() {
- throw new UnsupportedOperationException(HttpMsg.HTTP_ONLY_SUPPORTS_2_1); //$NON-NLS-1$
+ throw new UnsupportedOperationException(HttpMsg.HTTP_ONLY_SUPPORTS_2_1);
}
}
diff --git a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/servlet/HttpServletResponseImpl.java b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/servlet/HttpServletResponseImpl.java
index 50949a82..1f88be48 100644
--- a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/servlet/HttpServletResponseImpl.java
+++ b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/servlet/HttpServletResponseImpl.java
@@ -225,6 +225,7 @@ public class HttpServletResponseImpl implements HttpServletResponse {
try {
servletOutputStream.close();
} catch (IOException e) {
+ // TODO: consider logging
}
}
@@ -233,6 +234,7 @@ public class HttpServletResponseImpl implements HttpServletResponse {
try {
socket.close();
} catch (IOException e) {
+ // TODO: consider logging
}
}
}
@@ -292,6 +294,7 @@ public class HttpServletResponseImpl implements HttpServletResponse {
try {
fileEncodingAlias = new OutputStreamWriter(dummy, fileEncoding).getEncoding();
} catch (UnsupportedEncodingException ee) {
+ // TODO: consider logging
}
}
@@ -381,20 +384,20 @@ public class HttpServletResponseImpl implements HttpServletResponse {
throw new IllegalStateException();
}
- String charset = getCharacterEncoding();
+ String encoding = getCharacterEncoding();
- writer = new ServletPrintWriter(servletOutputStream, charset);
+ writer = new ServletPrintWriter(servletOutputStream, encoding);
if (contentType == null) {
// BUGBUG Must not set a default content type.
// Servlet 2.3 Section 5.3
- contentType = "text/plain; charset=" + charset; //$NON-NLS-1$
+ contentType = "text/plain; charset=" + encoding; //$NON-NLS-1$
setHeader("Content-Type", contentType); //$NON-NLS-1$
} else {
if (contentType.toLowerCase().indexOf("charset=") == -1) // 99372 //$NON-NLS-1$
{
- contentType = contentType + "; charset=" + charset; //$NON-NLS-1$
+ contentType = contentType + "; charset=" + encoding; //$NON-NLS-1$
setHeader("Content-Type", contentType); //$NON-NLS-1$
}
@@ -516,7 +519,8 @@ public class HttpServletResponseImpl implements HttpServletResponse {
if (index >= 0) {
Tokenizer tokenizer = new Tokenizer(type);
- String mime_type = tokenizer.getToken(";"); //$NON-NLS-1$
+ // TODO: verify next statement. It was String mimetype = tokenizer.getToken(";");
+ tokenizer.getToken(";"); //$NON-NLS-1$
tokenizer.getChar(); /* eat semicolon */
parseloop: while (true) {
diff --git a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/servlet/HttpSessionContextImpl.java b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/servlet/HttpSessionContextImpl.java
index a71d8ffb..03e9d694 100644
--- a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/servlet/HttpSessionContextImpl.java
+++ b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/servlet/HttpSessionContextImpl.java
@@ -29,9 +29,6 @@ import javax.servlet.http.HttpSessionContext;
*/
public class HttpSessionContextImpl implements HttpSessionContext {
- public HttpSessionContextImpl() {
- }
-
/**
* Returns an enumeration of all of the session IDs in this context.
*
diff --git a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/servlet/HttpSessionImpl.java b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/servlet/HttpSessionImpl.java
index fe153660..32486a68 100644
--- a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/servlet/HttpSessionImpl.java
+++ b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/servlet/HttpSessionImpl.java
@@ -185,9 +185,8 @@ public class HttpSessionImpl implements HttpSession {
if (canExpire) {
return ((int) (maxInactive / 1000L));
- } else {
- return (-1);
}
+ return (-1);
}
/**
@@ -204,10 +203,9 @@ public class HttpSessionImpl implements HttpSession {
} else {
if (interval < 0) {
throw new IllegalArgumentException("negative value"); //$NON-NLS-1$
- } else {
- maxInactive = ((long) interval) * 1000L;
- canExpire = true;
}
+ maxInactive = interval * 1000L;
+ canExpire = true;
}
}
}
diff --git a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/servlet/RequestDispatcherImpl.java b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/servlet/RequestDispatcherImpl.java
index 254deb0a..a89a6ed0 100644
--- a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/servlet/RequestDispatcherImpl.java
+++ b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/servlet/RequestDispatcherImpl.java
@@ -59,6 +59,7 @@ public class RequestDispatcherImpl implements RequestDispatcher {
}
public void sendRedirect(String url) {
+ // do nothing
}
public boolean containsHeader(String header) {
@@ -66,33 +67,43 @@ public class RequestDispatcherImpl implements RequestDispatcher {
}
public void addCookie(Cookie cookie) {
+ // do nothing
}
public void sendError(int errorCode) {
+ // do nothing
}
public void sendError(int errorCode, String error) {
+ // do nothing
}
public void setContentLength(int length) {
+ // do nothing
}
public void setContentType(String contentType) {
+ // do nothing
}
public void setStatus(int status) {
+ // do nothing
}
public void setStatus(int status, String statusPhrase) {
+ // do nothing
}
public void setHeader(String key, String value) {
+ // do nothing
}
public void setIntHeader(String key, int value) {
+ // do nothing
}
public void setDateHeader(String key, long date) {
+ // do nothing
}
/**
diff --git a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/servlet/ServletContextImpl.java b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/servlet/ServletContextImpl.java
index c6e4a778..c26830b0 100644
--- a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/servlet/ServletContextImpl.java
+++ b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/http/servlet/ServletContextImpl.java
@@ -126,8 +126,7 @@ public class ServletContextImpl implements ServletContext {
String mimeType = httpContext.getMimeType(file);
if (mimeType != null)
return (mimeType);
- else
- return (http.getMimeType(file));
+ return (http.getMimeType(file));
}
/**
@@ -263,14 +262,12 @@ public class ServletContextImpl implements ServletContext {
public InputStream getResourceAsStream(String path) {
try {
URL url = httpContext.getResource(path);
- if (url != null) {
+ if (url != null)
return url.openStream();
- } else {
- return null;
- }
} catch (IOException ex) {
- return null;
+ // TODO: consider logging
}
+ return null;
}
/**
diff --git a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/socket/https/HttpsServerSocket.java b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/socket/https/HttpsServerSocket.java
index 59501c38..3cc7e0c6 100644
--- a/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/socket/https/HttpsServerSocket.java
+++ b/bundles/org.eclipse.equinox.http/src/org/eclipse/equinox/socket/https/HttpsServerSocket.java
@@ -137,6 +137,7 @@ public class HttpsServerSocket implements ServerSocketInterface, ServiceTrackerC
}
public void modifiedService(ServiceReference reference, Object service) {
+ // do nothing
}
public synchronized void removedService(ServiceReference reference, Object service) {
@@ -145,6 +146,7 @@ public class HttpsServerSocket implements ServerSocketInterface, ServiceTrackerC
try {
ss.close();
} catch (IOException e) {
+ // TODO: consider logging
}
ss = null;
}

Back to the top