httplite: fix Java 1.3 API violations found by Animal Sniffer now that plugin is properly configured in pom

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1233736 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/httplite/core/src/main/java/org/apache/felix/httplite/osgi/Activator.java b/httplite/core/src/main/java/org/apache/felix/httplite/osgi/Activator.java
index 8974c24..ea5e997 100644
--- a/httplite/core/src/main/java/org/apache/felix/httplite/osgi/Activator.java
+++ b/httplite/core/src/main/java/org/apache/felix/httplite/osgi/Activator.java
@@ -93,9 +93,8 @@
     {
         Dictionary props = new Properties();
 
-        props.put(HttpConstants.SERVICE_PROPERTY_KEY_HTTP_ENABLE, Boolean.toString(true));
-        props.put(HttpConstants.SERVICE_PROPERTY_KEY_HTTPS_ENABLE,
-            Boolean.toString(false));
+        props.put(HttpConstants.SERVICE_PROPERTY_KEY_HTTP_ENABLE, "true");
+        props.put(HttpConstants.SERVICE_PROPERTY_KEY_HTTPS_ENABLE, "false");
         props.put(HttpConstants.SERVICE_PROPERTY_KEY_HTTP_PORT, Integer.toString(port));
 
         return props;
diff --git a/httplite/core/src/main/java/org/apache/felix/httplite/server/Server.java b/httplite/core/src/main/java/org/apache/felix/httplite/server/Server.java
index cef90fb..ad728c0 100644
--- a/httplite/core/src/main/java/org/apache/felix/httplite/server/Server.java
+++ b/httplite/core/src/main/java/org/apache/felix/httplite/server/Server.java
@@ -323,9 +323,10 @@
         Socket socket;
 
         m_logger.log(Logger.LOG_DEBUG, "Waiting for connections.");
+        boolean socketConnected = true;
 
         // Now listen for connections until interrupted.
-        while (m_serverSocket.isBound() && !m_serverSocket.isClosed())
+        while (socketConnected)
         {
             try
             {
@@ -349,6 +350,7 @@
             }
             catch (IOException ex)
             {
+                socketConnected = false;
             	if (!m_stopping)
             	{
 	                m_logger.log(Logger.LOG_ERROR,
diff --git a/httplite/core/src/main/java/org/apache/felix/httplite/servlet/HttpServletRequestImpl.java b/httplite/core/src/main/java/org/apache/felix/httplite/servlet/HttpServletRequestImpl.java
index a1c9d9a..811d2bd 100644
--- a/httplite/core/src/main/java/org/apache/felix/httplite/servlet/HttpServletRequestImpl.java
+++ b/httplite/core/src/main/java/org/apache/felix/httplite/servlet/HttpServletRequestImpl.java
@@ -82,7 +82,8 @@
     private final Map m_headers = new HashMap();
     private final Socket m_socket;
     private Cookie[] m_cookies;
-    private final Locale m_locale = new Locale( System.getProperty( "user.language" ) );
+    //TODO: Make locale static and perhaps global to the service.
+    private final Locale m_locale = new Locale( System.getProperty( "user.language" ), System.getProperty( "user.country" ) );
     private Map m_attributes;
     private final ServiceRegistrationResolver m_resolver;
     private String m_servletPath;
@@ -97,7 +98,7 @@
      * the body.
      */
     private byte[] m_requestBody = null;
-    private final static String m_encoding = "UTF-8";
+    //private final static String m_encoding = "UTF-8";
     private final Logger m_logger;
     private String m_queryString;
     /**
@@ -658,7 +659,7 @@
      */
     public String getRemoteAddr()
     {
-        return getSocket().getRemoteSocketAddress().toString();
+        return getSocket().getInetAddress().getHostAddress();
     }
 
 
@@ -668,7 +669,7 @@
 
     public String getRemoteHost()
     {
-        return getSocket().getRemoteSocketAddress().toString();
+        return getSocket().getInetAddress().getHostName();
     }
 
 
@@ -783,9 +784,9 @@
 
             List cookieList = new ArrayList();
 
-            for ( Iterator i = Arrays.asList( splitString( cookieHeader, ';' ) ).iterator(); i.hasNext(); )
+            for ( Iterator i = Arrays.asList( splitString( cookieHeader, ";" ) ).iterator(); i.hasNext(); )
             {
-                String[] nvp = splitString( i.next().toString(), '=' );
+                String[] nvp = splitString( i.next().toString(), "=" );
 
                 if ( nvp.length != 2 )
                 {
@@ -1062,14 +1063,16 @@
      */
     private void parseParameterString( final String queryString, final Map params ) throws UnsupportedEncodingException
     {
-        String[] parameters = splitString( queryString, '&' );
+        String[] parameters = splitString( queryString, "&" );
+        
         for ( Iterator i = Arrays.asList( parameters ).iterator(); i.hasNext(); )
         {
-            String[] nva = splitString( i.next().toString(), '=' );
+            String[] nva = splitString( i.next().toString(), "=" );
 
             if ( nva.length == 2 )
             {
-                params.put( URLDecoder.decode( nva[0].trim(), m_encoding ), nva[1].trim() );
+                //Deprecated method decode() intentionally used for Java 1.3 compatibility.
+                params.put( URLDecoder.decode( nva[0].trim() ), nva[1].trim() );
             }
         }
     }
@@ -1149,14 +1152,14 @@
      * @return array of substrings
      * @throws IllegalArgumentException if instr parameter is null.
      */
-    private static String[] splitString( String instr, char separator )
+    private static String[] splitString( String instr, String separator )
     {
 		if ( instr == null )
         {
             throw new IllegalArgumentException( "Input string must not be null." );
         }
 
-	    StringTokenizer tokenizer = new StringTokenizer(instr, Character.toString(separator));
+	    StringTokenizer tokenizer = new StringTokenizer(instr, separator);
         int length = tokenizer.countTokens();
 		String[] str_array = new String[length];
         for ( int i = 0; i < length; i++ )
diff --git a/httplite/core/src/main/java/org/apache/felix/httplite/servlet/HttpServletResponseImpl.java b/httplite/core/src/main/java/org/apache/felix/httplite/servlet/HttpServletResponseImpl.java
index 6f97b98..cd733ab 100644
--- a/httplite/core/src/main/java/org/apache/felix/httplite/servlet/HttpServletResponseImpl.java
+++ b/httplite/core/src/main/java/org/apache/felix/httplite/servlet/HttpServletResponseImpl.java
@@ -25,7 +25,6 @@
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.io.PrintWriter;
-import java.io.UnsupportedEncodingException;
 import java.net.HttpURLConnection;
 import java.net.URLEncoder;
 import java.text.SimpleDateFormat;
@@ -56,7 +55,8 @@
     private ByteArrayOutputStream m_buffer;
     private final Map m_headers = new HashMap();
     private String m_characterEncoding = "UTF-8";
-    private Locale m_locale = new Locale(System.getProperty("user.language"));
+    //TODO: Make locale static and perhaps global to the service.
+    private Locale m_locale = new Locale(System.getProperty("user.language"), System.getProperty( "user.country" ));
     private boolean m_getOutputStreamCalled = false;
     private boolean m_getWriterCalled = false;
     private ServletOutputStreamImpl m_servletOutputStream;
@@ -505,15 +505,9 @@
      * @see javax.servlet.http.HttpServletResponse#encodeUrl(java.lang.String)
      */
     public String encodeUrl(final String url)
-    {
-        try
-        {
-            return URLEncoder.encode(url, m_characterEncoding);
-        }
-        catch (UnsupportedEncodingException e)
-        {
-            return url;
-        }
+    {      
+        //Deprecated method used for Java 1.3 compatibility.
+        return URLEncoder.encode(url);       
     }
 
     /* (non-Javadoc)