Repository: tomee
Updated Branches:
  refs/heads/master 26770ac8b -> 87beb070d


Finals


Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/cf2e1138
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/cf2e1138
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/cf2e1138

Branch: refs/heads/master
Commit: cf2e113838a898bc866cb79823bd0022eade0fe5
Parents: 26770ac
Author: AndyGee <andy...@gmx.de>
Authored: Thu Dec 3 03:18:10 2015 +0100
Committer: AndyGee <andy...@gmx.de>
Committed: Thu Dec 3 03:18:10 2015 +0100

----------------------------------------------------------------------
 .../openejb/server/httpd/HttpResponseImpl.java  | 112 +++++++++----------
 1 file changed, 56 insertions(+), 56 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/cf2e1138/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpResponseImpl.java
----------------------------------------------------------------------
diff --git 
a/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpResponseImpl.java
 
b/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpResponseImpl.java
index 180e3e2..cb73dcf 100644
--- 
a/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpResponseImpl.java
+++ 
b/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/HttpResponseImpl.java
@@ -33,8 +33,8 @@ import java.io.InputStream;
 import java.io.OutputStream;
 import java.io.PrintWriter;
 import java.net.URLConnection;
-import java.util.Arrays;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.Locale;
 import java.util.Map;
@@ -99,7 +99,7 @@ public class HttpResponseImpl implements HttpResponse {
     private String encoding = "UTF-8";
     private Locale locale = Locale.getDefault();
 
-    protected void setRequest(HttpRequestImpl request) {
+    protected void setRequest(final HttpRequestImpl request) {
         this.request = request;
     }
 
@@ -109,68 +109,68 @@ public class HttpResponseImpl implements HttpResponse {
      * @param name  the name of the header
      * @param value the value of the header
      */
-    public void setHeader(String name, String value) {
+    public void setHeader(final String name, final String value) {
         headers.put(name, value);
     }
 
     @Override
-    public void setIntHeader(String s, int i) {
+    public void setIntHeader(final String s, final int i) {
         headers.put(s, Integer.toString(i));
     }
 
     @Override
-    public void setStatus(int i) {
+    public void setStatus(final int i) {
         setCode(i);
     }
 
     @Override
-    public void setStatus(int i, String s) {
+    public void setStatus(final int i, final String s) {
         setCode(i);
         setStatusMessage(s);
     }
 
     @Override
-    public void addCookie(Cookie cookie) {
+    public void addCookie(final Cookie cookie) {
         headers.put(cookie.getName(), cookie.getValue());
     }
 
     @Override
-    public void addDateHeader(String s, long l) {
+    public void addDateHeader(final String s, final long l) {
         headers.put(s, Long.toString(l));
     }
 
     @Override
-    public void addHeader(String s, String s1) {
+    public void addHeader(final String s, final String s1) {
         headers.put(s, s1);
     }
 
     @Override
-    public void addIntHeader(String s, int i) {
+    public void addIntHeader(final String s, final int i) {
         setIntHeader(s, i);
     }
 
     @Override
-    public boolean containsHeader(String s) {
+    public boolean containsHeader(final String s) {
         return headers.containsKey(s);
     }
 
     @Override
-    public String encodeURL(String s) {
+    public String encodeURL(final String s) {
         return toEncoded(s);
     }
 
     @Override
-    public String encodeRedirectURL(String s) {
+    public String encodeRedirectURL(final String s) {
         return toEncoded(s);
     }
 
     @Override
-    public String encodeUrl(String s) {
+    public String encodeUrl(final String s) {
         return toEncoded(s);
     }
 
     @Override
-    public String encodeRedirectUrl(String s) {
+    public String encodeRedirectUrl(final String s) {
         return encodeRedirectURL(s);
     }
 
@@ -180,7 +180,7 @@ public class HttpResponseImpl implements HttpResponse {
      * @param name The name of the header
      * @return the value of the header
      */
-    public String getHeader(String name) {
+    public String getHeader(final String name) {
         return headers.get(name);
     }
 
@@ -190,8 +190,8 @@ public class HttpResponseImpl implements HttpResponse {
     }
 
     @Override
-    public Collection<String> getHeaders(String s) {
-        return Arrays.asList(headers.get(s));
+    public Collection<String> getHeaders(final String s) {
+        return Collections.singletonList(headers.get(s));
     }
 
     @Override
@@ -200,12 +200,12 @@ public class HttpResponseImpl implements HttpResponse {
     }
 
     @Override
-    public void sendError(int i) throws IOException {
+    public void sendError(final int i) throws IOException {
         setCode(i);
     }
 
     @Override
-    public void sendError(int i, String s) throws IOException {
+    public void sendError(final int i, final String s) throws IOException {
         setCode(i);
         setStatusMessage(s);
     }
@@ -227,7 +227,7 @@ public class HttpResponseImpl implements HttpResponse {
     }
 
     @Override
-    public void setDateHeader(String s, long l) {
+    public void setDateHeader(final String s, final long l) {
         addDateHeader(s, l);
     }
 
@@ -281,7 +281,7 @@ public class HttpResponseImpl implements HttpResponse {
      *
      * @param code the code to be sent to the browser
      */
-    public void setCode(int code) {
+    public void setCode(final int code) {
         this.code = code;
         commited = true;
     }
@@ -300,12 +300,12 @@ public class HttpResponseImpl implements HttpResponse {
      *
      * @param type the type to be sent to the browser (i.e. "text/html")
      */
-    public void setContentType(String type) {
+    public void setContentType(final String type) {
         setHeader("Content-Type", type);
     }
 
     @Override
-    public void setLocale(Locale loc) {
+    public void setLocale(final Locale loc) {
         locale = loc;
     }
 
@@ -328,7 +328,7 @@ public class HttpResponseImpl implements HttpResponse {
      *
      * @param responseString the response string
      */
-    public void setResponseString(String responseString) {
+    public void setResponseString(final String responseString) {
         this.responseString = responseString;
     }
 
@@ -345,17 +345,17 @@ public class HttpResponseImpl implements HttpResponse {
     }
 
     @Override
-    public void setBufferSize(int i) {
+    public void setBufferSize(final int i) {
         // no-op
     }
 
     @Override
-    public void setCharacterEncoding(String s) {
+    public void setCharacterEncoding(final String s) {
         encoding = s;
     }
 
     @Override
-    public void setContentLength(int i) {
+    public void setContentLength(final int i) {
         // no-op
     }
 
@@ -371,7 +371,7 @@ public class HttpResponseImpl implements HttpResponse {
      * @param code           the code to be sent to the browser
      * @param responseString the response string to be sent to the browser
      */
-    public void reset(int code, String responseString) {
+    public void reset(final int code, final String responseString) {
         setCode(code);
         setResponseString(responseString);
         initBody();
@@ -396,7 +396,7 @@ public class HttpResponseImpl implements HttpResponse {
      * @param responseString the response string to be sent back
      * @param contentType    the content type to be sent back
      */
-    protected HttpResponseImpl(int code, String responseString, String 
contentType) {
+    protected HttpResponseImpl(final int code, final String responseString, 
final String contentType) {
         this.responseString = responseString;
         this.code = code;
 
@@ -421,7 +421,7 @@ public class HttpResponseImpl implements HttpResponse {
      * @param output the output to send the response to
      * @throws java.io.IOException if an exception is thrown
      */
-    protected void writeMessage(OutputStream output, boolean indent) throws 
IOException {
+    protected void writeMessage(final OutputStream output, final boolean 
indent) throws IOException {
         flushBuffer();
 
         final ByteArrayOutputStream baos = new ByteArrayOutputStream();
@@ -467,7 +467,7 @@ public class HttpResponseImpl implements HttpResponse {
         if (content == null) {
             writer.flush();
             writer.close();
-            int length = sosi.getOutputStream().toByteArray().length;
+            final int length = sosi.getOutputStream().toByteArray().length;
             setHeader("Content-Length", length + "");
         } else {
             setHeader("Content-Length", content.getContentLength() + "");
@@ -497,7 +497,7 @@ public class HttpResponseImpl implements HttpResponse {
      * @param out the output stream to write the response line to
      * @throws java.io.IOException if an exception is thrown
      */
-    private void writeResponseLine(DataOutput out) throws IOException {
+    private void writeResponseLine(final DataOutput out) throws IOException {
         out.writeBytes(HTTP_VERSION);
         out.writeBytes(SP);
         out.writeBytes(code + "");
@@ -514,7 +514,7 @@ public class HttpResponseImpl implements HttpResponse {
      * @param out the output stream to be sent to the browser
      * @throws java.io.IOException if an exception is thrown
      */
-    private void writeHeaders(DataOutput out) throws IOException {
+    private void writeHeaders(final DataOutput out) throws IOException {
         for (final Map.Entry<String, String> entry : headers.entrySet()) {
             out.writeBytes("" + entry.getKey());
             out.writeBytes(CSP);
@@ -530,7 +530,7 @@ public class HttpResponseImpl implements HttpResponse {
      * @param indent format xml
      * @throws java.io.IOException if an exception is thrown
      */
-    private void writeBody(DataOutput out, boolean indent) throws IOException {
+    private void writeBody(final DataOutput out, final boolean indent) throws 
IOException {
         out.writeBytes(CRLF);
         if (content == null) {
             if (indent && OpenEJBHttpServer.isTextXml(headers)) {
@@ -540,8 +540,8 @@ public class HttpResponseImpl implements HttpResponse {
                 out.write(sosi.getOutputStream().toByteArray());
             }
         } else {
-            InputStream in = content.getInputStream();
-            byte buf[] = new byte[1024];
+            final InputStream in = content.getInputStream();
+            final byte[] buf = new byte[1024];
 
             int i;
             while ((i = in.read(buf)) != -1) {
@@ -572,7 +572,7 @@ public class HttpResponseImpl implements HttpResponse {
      * @param message the error message to be sent
      * @return the HttpResponseImpl that this error belongs to
      */
-    protected static HttpResponseImpl createError(String message) {
+    protected static HttpResponseImpl createError(final String message) {
         return createError(message, null);
     }
 
@@ -583,12 +583,12 @@ public class HttpResponseImpl implements HttpResponse {
      * @param t       a Throwable to print a stack trace to
      * @return the HttpResponseImpl that this error belongs to
      */
-    protected static HttpResponseImpl createError(String message, Throwable t) 
{
-        HttpResponseImpl res = new HttpResponseImpl(500, "Internal Server 
Error", "text/html");
+    protected static HttpResponseImpl createError(String message, final 
Throwable t) {
+        final HttpResponseImpl res = new HttpResponseImpl(500, "Internal 
Server Error", "text/html");
         PrintWriter body = null;
         try {
             body = res.getWriter();
-        } catch (IOException e) { // impossible normally
+        } catch (final IOException e) { // impossible normally
             // no-op
         }
 
@@ -602,7 +602,7 @@ public class HttpResponseImpl implements HttpResponse {
         }
 
         if (message != null) {
-            StringTokenizer msg = new StringTokenizer(message, "\n\r");
+            final StringTokenizer msg = new StringTokenizer(message, "\n\r");
 
             while (msg.hasMoreTokens()) {
                 body.print(msg.nextToken());
@@ -614,19 +614,19 @@ public class HttpResponseImpl implements HttpResponse {
             try {
                 body.println("<br><br>");
                 body.println("Stack Trace:<br>");
-                ByteArrayOutputStream baos = new ByteArrayOutputStream();
-                PrintWriter writer = new PrintWriter(baos);
+                final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+                final PrintWriter writer = new PrintWriter(baos);
                 t.printStackTrace(writer);
                 writer.flush();
                 writer.close();
                 message = new String(baos.toByteArray());
-                StringTokenizer msg = new StringTokenizer(message, "\n\r");
+                final StringTokenizer msg = new StringTokenizer(message, 
"\n\r");
 
                 while (msg.hasMoreTokens()) {
                     body.print(msg.nextToken());
                     body.println("<br>");
                 }
-            } catch (Exception e) {
+            } catch (final Exception e) {
             }
         }
 
@@ -642,12 +642,12 @@ public class HttpResponseImpl implements HttpResponse {
      * @param ip the ip that is forbidden
      * @return the HttpResponseImpl that this error belongs to
      */
-    protected static HttpResponseImpl createForbidden(String ip) {
-        HttpResponseImpl res = new HttpResponseImpl(403, "Forbidden", 
"text/html");
+    protected static HttpResponseImpl createForbidden(final String ip) {
+        final HttpResponseImpl res = new HttpResponseImpl(403, "Forbidden", 
"text/html");
         PrintWriter body = null;
         try {
             body = res.getWriter();
-        } catch (IOException e) { // normally impossible
+        } catch (final IOException e) { // normally impossible
             // no-op
         }
 
@@ -670,7 +670,7 @@ public class HttpResponseImpl implements HttpResponse {
      * @param out the ObjectOutputStream to write to
      * @throws java.io.IOException if an exception is thrown
      */
-    private void writeObject(java.io.ObjectOutputStream out) throws 
IOException {
+    private void writeObject(final java.io.ObjectOutputStream out) throws 
IOException {
         /** Response string */
         out.writeObject(responseString);
 
@@ -682,7 +682,7 @@ public class HttpResponseImpl implements HttpResponse {
 
         /** Response body */
         writer.flush();
-        byte[] body = sosi.getOutputStream().toByteArray();
+        final byte[] body = sosi.getOutputStream().toByteArray();
         //System.out.println("[] body "+body.length );
         out.writeObject(body);
     }
@@ -695,7 +695,7 @@ public class HttpResponseImpl implements HttpResponse {
      * @throws ClassNotFoundException if an exception is thrown
      */
     @SuppressWarnings({"unchecked"})
-    private void readObject(java.io.ObjectInputStream in) throws IOException, 
ClassNotFoundException {
+    private void readObject(final java.io.ObjectInputStream in) throws 
IOException, ClassNotFoundException {
         /** Response string */
         this.responseString = (String) in.readObject();
 
@@ -703,12 +703,12 @@ public class HttpResponseImpl implements HttpResponse {
         this.code = in.readInt();
 
         /** Response headers */
-        Map headers = (Map) in.readObject();
+        final Map headers = (Map) in.readObject();
         this.headers.clear();
         this.headers.putAll(headers);
 
         /** Response body */
-        byte[] body = (byte[]) in.readObject();
+        final byte[] body = (byte[]) in.readObject();
         //System.out.println("[] body "+body.length );
         sosi = new ServletByteArrayOutputStream();
         sosi.write(body);
@@ -719,11 +719,11 @@ public class HttpResponseImpl implements HttpResponse {
     /**
      * @param content The content to set.
      */
-    public void setContent(URLConnection content) {
+    public void setContent(final URLConnection content) {
         this.content = content;
     }
 
-    public void setStatusMessage(String responseString) {
+    public void setStatusMessage(final String responseString) {
         this.setResponseString(responseString);
     }
 

Reply via email to