Project Report: fawkez

Packagesummary org.jcoderz.commons.connector.http.transport

org.jcoderz.commons.connector.http.transport.ClientHandler

LineHitsNoteSource
1  /*
2   * $Id: ClientHandler.java 1011 2008-06-16 17:57:36Z amandel $
3   *
4   * Copyright 2006, The jCoderZ.org Project. All rights reserved.
5   *
6   * Redistribution and use in source and binary forms, with or without
7   * modification, are permitted provided that the following conditions are
8   * met:
9   *
10   *    * Redistributions of source code must retain the above copyright
11   *      notice, this list of conditions and the following disclaimer.
12   *    * Redistributions in binary form must reproduce the above
13   *      copyright notice, this list of conditions and the following
14   *      disclaimer in the documentation and/or other materials
15   *      provided with the distribution.
16   *    * Neither the name of the jCoderZ.org Project nor the names of
17   *      its contributors may be used to endorse or promote products
18   *      derived from this software without specific prior written
19   *      permission.
20   *
21   * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS" AND
22   * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24   * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS
25   * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26   * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27   * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
28   * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29   * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
30   * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
31   * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32   */
33  package org.jcoderz.commons.connector.http.transport;
34  
35  import java.io.ByteArrayOutputStream;
36  import java.io.IOException;
37  import java.io.InputStream;
38  import java.io.OutputStream;
39  import java.io.UnsupportedEncodingException;
40  import java.net.Socket;
41  import java.util.HashMap;
42  import java.util.Iterator;
43  import java.util.Map;
44  import java.util.logging.Logger;
45  import org.jcoderz.commons.util.Constants;
46  
47  
48  
49  /**
50   * Handler for http client requests.
51   */
52 (1)public class ClientHandler
53        extends Thread
54  {
55     /** Class name used for logging. */
5675    private static final String CLASSNAME
57           = ClientHandler.class.getName();
58     /** Logger in use. */
59100    private static final Logger logger
60           = Logger.getLogger(CLASSNAME);
61     private static final int MAX_REQUESTS = 1000;
62     private static final int SLEEP_TIME_BETWEEN_REQUESTS = 50;
63     private static final int BUFFER_SIZE = 4096;
64     private static final String NEW_LINE = "\n";
65     private static final String UTF8 = "UTF-8";
66     private final Socket mIncoming;
67     private final int mCounter;
68100    private InputStream mInStream = null;
69100    private OutputStream mOutStream = null;
70100    private boolean mHaveToStop = false;
71  
72     // request
73     private String mRequestLine;
74100    private final Map mRequestParameter = new HashMap();
75     private String mRequestBody;
76     private String mRequestContentType;
77100    private boolean mConnectionHaveToBeClosed = false;
78100    private boolean mDoNotRespond = false;
79100    private boolean mDoImmediateClose = false;
80100    private boolean mUseEmptyResponse = false;
81  
82     // response
83     private String mResponseLine;
84     private String mResponseBody;
85100    private final Map mResponseParameter = new HashMap();
86  
87     /**
88      * Constructor.
89      *
90      * @param incoming
91    * the incoming socket
92      * @param counter
93    * the number of handler
94      */
95     public ClientHandler (Socket incoming, int counter)
96100    {
97100       mIncoming = incoming;
98100       mCounter = counter;
99  
100100       logger.info("+++ Creating Thread "
101              + mCounter + "x"
102              + " for Socket(" + incoming.getPort() + ")\n");
103100    }
104  
105     /**
106      * Starting handler thread.
107      */
108     public void run ()
109     {
110        try
111        {
112100          mInStream = mIncoming.getInputStream();
113100          mOutStream = mIncoming.getOutputStream();
114100          for (int i = 1; i < MAX_REQUESTS; i++)
115           {
116100             if (!gotIncomingRequest())
117              {
1180                break;
119              }
120  
121100             logger.info(
122                    "+++ ITERATION " + i + "x Thread " + mCounter + "\n");
123              try
124              {
125                 // read response
126100                readRequest();
127  
128                 // if the client wants an immediate close without response
129100                if (mDoImmediateClose)
130                 {
131100                   break;
132                 }
133  
134                 // if the client do not want to receive a response
135100                if (!mDoNotRespond)
136                 {
137100                   writeResponse();
138                 }
139              }
1400             catch (Exception ie)
141              {
1420                logger.warning(
143                       "Exception (" + ie.getMessage() + ") while read/write");
1440(2)               ie.printStackTrace();
1450                break;
146100             }
147  
148100             if (mConnectionHaveToBeClosed)
149              {
150100                break;
151              }
152           } // end for
153100          mInStream.close();
154100          mOutStream.close();
155100          mIncoming.close();
156        }
1570       catch (Exception ex)
158        {
1590(3)         ex.printStackTrace();
160100       }
161100       logger.info("+++ Terminating Thread " + mCounter + "x\n");
162100    }
163  
164     private boolean gotIncomingRequest ()
165     {
166100       int bytesAvailable = 0;
167100       boolean handleRequest = true;
168        for (;;)
169        {
170           try
171           {
172100             bytesAvailable = mInStream.available();
173           }
1740          catch (IOException ioe)
175           {
1760             logger.warning(
177                    "IOException (" + ioe.getMessage()
178                    + ") on inputstream");
1790             handleRequest = false;
1800             break;
181100          }
182  
183           // take a break..
184           try
185           {
186100             Thread.sleep(SLEEP_TIME_BETWEEN_REQUESTS);
187           }
1880          catch (InterruptedException ie)
189           {
190              // ignore
191100          }
192  
193100          if (bytesAvailable > 0)
194           {
195100             break;
196           }
197100          if (mHaveToStop)
198           {
199              //hangUp = true;
2000             handleRequest = false;
2010             break;
202           }
203  
204        } // end for
205100       return handleRequest;
206     }
207  
208  
209     /**
210      * Reads the request.
211      * @throws Exception
212    * in case of an error
213      */
214     public void readRequest ()
215           throws Exception
216     {
217        // read the response message
218        try
219        {
220           // try to read <POST / HTTP/1.0>
221100          readRequestLine();
222  
223           // try to read
224           // <Connection: Keep-Alive> etc.
225100          readHeaderAttributes();
226  
227           // try to read
228           // request body
229100          readRequestBody();
230        }
2310       catch (Exception ex)
232        {
2330          throw ex;
234100       }
235  
236        // dump request
237100(4)      final StringBuffer buffer = new StringBuffer();
238100       buffer.append(
239              "\n- REQUEST ------------------------------------------\n");
240100       buffer.append(requestToString());
241100       buffer.append(
242              "\n-----------------------------------------------------\n");
243100       logger.info(buffer.toString());
244100    }
245  
246  
247     /**
248      * Reads the request header line.
249      * @throws Exception
250    * in case of an error
251      */
252     protected void readRequestLine ()
253           throws Exception
254     {
255100       String errorText = null; // used by throwing exceptions
256  
257100       String path = null;
258100       String httpVersion = null;
259  
260        try
261        { // try to find a HTTP status line in the read input data
262100          mRequestLine = readLine();
263100          while (mRequestLine != null && !mRequestLine.startsWith("POST"))
264           {
2650             mRequestLine = readLine();
266           }
267        }
2680       catch (IOException ioe)
269        {
2700          errorText = "IOException with message: " + ioe.getMessage();
2710(5)         throw new Exception(errorText);
272100       }
273  
274100       if (mRequestLine == null)
275        {
276           // A null requestLine means the connection was lost
277           // before we got a response. Try again.
2780          errorText = "Error in parsing the request line : unable to find line"
279                 + " starting with \"POST\"";
2800          throw new Exception(errorText);
281        }
282        // <POST> found...
283  
284100(6)(7)      final int pathIndex = mRequestLine.indexOf("/");
285100       int afterPathIndex = 0;
286100       if (pathIndex > 0)
287        {
288100(8)(9)         afterPathIndex = mRequestLine.indexOf(" ", pathIndex);
289100          if (afterPathIndex > pathIndex)
290           {
291100             path = mRequestLine.substring(pathIndex, afterPathIndex - 1);
292           }
293        }
294100       if (path == null)
295        {
2960          errorText = "Error in parsing the request line : unable to find path";
2970          throw new Exception(errorText);
298        }
299        // <POST /> found..
300  
301100       httpVersion = mRequestLine.substring(afterPathIndex).trim();
302100(10)      if (httpVersion == null)
303        {
3040          errorText
305              = "Error in parsing the request line : unable to find HTTP version";
3060          throw new Exception(errorText);
307        }
308        // <POST / HTTP/1.x> found..
309100    }
310  
311     /**
312      * Reads the header attributes.
313      * @throws Exception
314    * in case of an error
315      */
316     private void readHeaderAttributes ()
317           throws Exception
318     {
319100       String errorText = null; // used by throwing exceptions
320100       String headerLine = null;
321        for (;;)
322        {
323           try
324           {
325100             headerLine = readLine();
326           }
3270          catch (IOException ioe)
328           {
3290             errorText = "IOException with message: " + ioe.getMessage();
3300(11)            throw new Exception(errorText);
331100          }
332  
333           // if all header attributes read..
334100          if ((headerLine == null) || (headerLine.length() < 1))
335           {
336100             break;
337           }
338  
339100          final int colon = parseHeaderLine(headerLine);
340100          final String name = headerLine.substring(0, colon).trim();
341100          final String value = headerLine.substring(colon + 1).trim();
342  
343100          addRequestHeaderParameter(name, value);
344100       } // end for
345  
346100       assertRequestParameterGiven();
347  
348        // remember the Content-Type header
349100       mRequestContentType
350              = (String) mRequestParameter.get("content-type");
351  
352100       checkSpecialParameter();
353100       setEchoParameterToResponse();
354100    }
355  
356     private void checkSpecialParameter ()
357     {
358        // check for Connection: Close
359100       final String connectionValue
360              = (String) mRequestParameter.get("connection");
361  
362100(12)      if (connectionValue != null
363              && connectionValue.toLowerCase(
364                    Constants.SYSTEM_LOCALE).equals("close"))
365        {
366100          mConnectionHaveToBeClosed = true;
367        }
368  
369        // check for parameter "DoNotRespond"
370100       final String doNotRespondValue
371              = (String) mRequestParameter.get("donotrespond");
372  
373100(13)      if (doNotRespondValue != null
374              && doNotRespondValue.toLowerCase(
375                    Constants.SYSTEM_LOCALE).equals("true"))
376        {
377100          mDoNotRespond = true;
378        }
379  
380        // check for parameter "DoImmediateClose"
381100       final String doImmediateCloseValue
382              = (String) mRequestParameter.get("doimmediateclose");
383  
384100(14)      if (doImmediateCloseValue != null
385              && doImmediateCloseValue.toLowerCase(
386                    Constants.SYSTEM_LOCALE).equals("true"))
387        {
388100          mDoImmediateClose = true;
389        }
390  
391        // check for parameter "UseEmptyResponse"
392100       final String useEmptyResponse
393              = (String) mRequestParameter.get("useemptyresponse");
394  
395100(15)      if (useEmptyResponse != null
396              && useEmptyResponse.toLowerCase(
397                    Constants.SYSTEM_LOCALE).equals("true"))
398        {
399100          mUseEmptyResponse = true;
400        }
401100    }
402  
403     /**
404      * Detects a request parameter with prefix "ECHO_" in request
405      * and adds these parameter without prefix to response.
406      */
407     private void setEchoParameterToResponse ()
408     {
409100       for (final Iterator it = mRequestParameter.keySet().iterator();
410100             it.hasNext();)
411        {
412100          final String key = (String) it.next();
413100          final String value = (String) mRequestParameter.get(key);
414  
415100          final String prefix = "echo_";
416100          final int prefixLength = prefix.length();
417100          if (key.startsWith(prefix))
418           {
419100             final String responseKey = key.substring(prefixLength);
420100             mResponseParameter.put(responseKey, value);
421           }
422100       }
423100    }
424  
425     private int parseHeaderLine (String headerLine)
426           throws Exception
427     {
428        // Parse the header name and value
429100(16)(17)      final int colon = headerLine.indexOf(":");
430100       if (colon < 0)
431        {
4320          final String errorText
433              = "Unable to parse header - no colon found: " + headerLine;
4340          throw new Exception(errorText);
435        }
436100       return colon;
437     }
438  
439     private void addRequestHeaderParameter (String name, String value)
440     {
441100       if (name != null && value != null)
442        {
443100          mRequestParameter.put(name.toLowerCase(
444                 Constants.SYSTEM_LOCALE), value);
445100          logger.info("Header Parameter: " + name + "=" + value);
446        }
447100    }
448  
449     private void assertRequestParameterGiven ()
450           throws Exception
451     {
452100       if (mRequestParameter.isEmpty())
453        {
4540          final String errorText = "no header parameter found";
4550          throw new Exception(errorText);
456        }
457100    }
458  
459     /**
460      * Reads the request body.
461      * @throws Exception
462    * in case of an error
463      */
464     private void readRequestBody ()
465           throws Exception
466     {
467100       String errorText = null; // used by throwing exceptions
468100       byte[] responseBody = null;
469  
470        // check Content-Length
471100       final String stringValue
472              = (String) mRequestParameter.get("content-length");
473100       if (stringValue == null)
474        {
4750          errorText = "no Content-Length attribute found";
4760          logger.warning("Throwing Exception: " + errorText);
4770          throw new Exception(errorText);
478        }
479100       final int expectedLength = Integer.parseInt(stringValue);
480  
481        // check Content-Type
482100       final String encoding = getEncoding();
483100       if (encoding == null)
484        {
4850          errorText = "no Content-Type attribute found";
4860          logger.warning("Throwing Exception: " + errorText);
4870          throw new Exception(errorText);
488        }
489  
490        try
491        {
492100          responseBody = read(expectedLength);
493        }
4940       catch (IOException ioe)
495        {
4960          errorText = "IOException with message: " + ioe.getMessage();
4970(18)         throw new Exception(errorText);
498100       }
499  
500        try
501        {
502100          mRequestBody
503              = new String(responseBody, 0, responseBody.length, encoding);
504        }
5050       catch (UnsupportedEncodingException ee)
506        {
5070          errorText = "error while reading body: "
508                    + " encoding (" + encoding + ") is not supported";
5090          logger.warning("Throwing Exception: " + errorText);
5100(19)         throw new Exception(errorText);
511100       }
512100    }
513  
514     /**
515      * Reads a line from InputStream.
516      * @return String
517      *          the read line
518      * @throws IOException
519    * in case of an error
520      */
521     public String readLine ()
522           throws IOException
523     {
524100       String result = null;
525100       StringBuffer buffer = new StringBuffer();
526        for (;;)
527        {
528100          final int ch = mInStream.read();
529100          if (ch < 0)
530           {
5310             if (buffer.length() == 0)
532              {
5330                buffer = null;
5340                break;
535              }
536              else
537              {
538                 break;
539              }
540           }
541100          else if (ch == '\r')
542           {
543100             continue;
544           }
545100          else if (ch == '\n')
546           {
547100             break;
548           }
549100          buffer.append((char) ch);
550100       }
551100       if (buffer != null)
552        {
553100          result = buffer.toString();
554        }
555100       return result;
556     }
557  
558     /**
559      * Reads the response body.
560      *
561      * @param expectedLength
562    * the expected length of body
563      * @return byte[]
564      *          the request body
565      * @throws IOException
566    * in case of an error
567      */
568     public byte[] read (int expectedLength)
569           throws IOException
570     {
571100       final byte[] buffer = new byte[BUFFER_SIZE]; // todo ..configurable!
572100       final ByteArrayOutputStream tempOut = new ByteArrayOutputStream();
573  
574100       int bytesRead = 0;
575100       int foundLength = 0;
576  
577        // if expectedLength == -1 ..infinite read til timeout
578        // at the moment a header with "Content-Length" -1 is invalid
579        // and this infinite read scenario is not possible..
580100       while (expectedLength == -1 || foundLength < expectedLength)
581        {
582100          bytesRead = mInStream.read(buffer);
583  
584           // no bytes read
585100          if (bytesRead == -1)
586           {
5870             break;
588           }
589100          tempOut.write(buffer, 0, bytesRead);
590100          foundLength += bytesRead;
591100          if (expectedLength > -1)
592           {
593              // everything read as expected
594100             if (foundLength == expectedLength)
595              {
596100                break;
597              }
5980             else if (foundLength > expectedLength)
599              {
6000(20)               final StringBuffer strbuf = new StringBuffer();
6010(21)               strbuf.append("++ WARNING WHILE READING RESPONSE BODY ++\n");
6020(22)(23)               strbuf.append("++ expected length (" + expectedLength
603                       + ") exceeded ++\n");
6040(24)               strbuf.append("++ found " + foundLength + " bytes ++");
6050                logger.warning(strbuf.toString());
6060                break;
607              }
608           }
609        } // end while
610  
611        try
612        {
613100          tempOut.close();
614        }
6150       catch (IOException ioe)
616        {
6170          final String errorText
618                 = "unable to close buffer with data read from socket"
619                    + " as response body";
6200(25)(26)         throw new IOException(errorText);
621100       }
622100       return tempOut.toByteArray();
623     }
624  
625     /**
626      * Gets the encoding.
627      * @return String
628      *          the used encoding
629      */
630     public String getEncoding ()
631     {
632100       String result = null;
633100       final String contentType = (String) mRequestParameter.get("content-type");
634  
635100       if (contentType != null)
636        {
637100(27)         if (contentType.toUpperCase(
638                 Constants.SYSTEM_LOCALE).equals("TEXT/PLAIN"))
639           {
6400             result = UTF8;
641           }
642           else
643           {
644100             result = getEncodingFromCharsetValue (contentType);
645           }
646        }
647100       return result;
648     }
649  
650     /**
651      * Gets the encoding extracted from parameter value CHARSET.
652      *
653      * @param contentType
654    * the parameter value set for Content-Type
655      * @return String
656      *          the encoding extracted from CHARSET if found in
657      *          Content-Type, null else
658      */
659     private String getEncodingFromCharsetValue (String contentType)
660     {
661100       String result = UTF8; // as default
662100       final String charsetName = "CHARSET="; // must be upper case
663100       final int charsetIndex
664              = contentType.toUpperCase(Constants.SYSTEM_LOCALE).
665                    indexOf(charsetName);
666100       if (charsetIndex > 0)
667        {
668100(28)         final int quote1 = contentType.
669              indexOf("\"", charsetIndex + charsetName.length());
670100(29)(30)         final int quote2 = contentType.
671              indexOf("\"", quote1 + 1);
672100          if (quote1 > 0)
673           {
6740             result = contentType.
675                 substring(quote1 + 1, quote2).
676                       toUpperCase(Constants.SYSTEM_LOCALE);
677           }
678           else
679           {
680100             result = contentType.
681                 substring(charsetIndex + charsetName.length()).
682                       toUpperCase(Constants.SYSTEM_LOCALE);
683           }
684100       }
685        else
686        {
6870          final String messageText = "no charset defined in Content-Type ("
688                                   + contentType + ")";
6890          logger.info(messageText);
690        }
691100       return result;
692     }
693  
694     /**
695      * Writes the response message.
696      * @throws Exception
697    * in case of an error
698      */
699     public void writeResponse ()
700           throws Exception
701     {
702100       StringBuffer buffer = new StringBuffer();
703  
704        // create response
705        // header line
706100       mResponseLine = "HTTP/1.0 200 OK";
707  
708        // body
709100       if (!mUseEmptyResponse)
710        {
711100          buffer.append("Echo:");
712100          buffer.append(mRequestBody);
713        }
714100       mResponseBody = buffer.toString();
715  
716        // the message to be send
717100       final byte[] messageAsByte = mResponseBody.getBytes(UTF8);
718        //
719  
720        // header parameter
721100       if (mConnectionHaveToBeClosed)
722        {
723100          mResponseParameter.put("Connection", "Close");
724        }
725        else
726        {
727100          mResponseParameter.put("Connection", "Keep-Alive");
728        }
729  
730100       final int bodyLength = messageAsByte.length;
731100       mResponseParameter.put(
732              "Content-Length", Integer.toString(bodyLength));
733100       mResponseParameter.put("Content-Type", mRequestContentType);
734  
735        // complete response
736100       buffer = new StringBuffer();
737100       buffer.append(mResponseLine);
738100       buffer.append(NEW_LINE);
739100       buffer.append(getResponseParameterAsString());
740100       buffer.append(NEW_LINE);
741100       buffer.append(mResponseBody);
742  
743        // ..for dumping
744100(31)      final StringBuffer strbuf = new StringBuffer();
745100       strbuf.append("\n-- RESPONSE --\n");
746100       strbuf.append(buffer.toString());
747100       strbuf.append("\n--------------\n");
748100       logger.info(strbuf.toString());
749  
750        // complete message as byte array
751100       final byte[] messageAsBytes = buffer.toString().getBytes(UTF8);
752  
753100       mOutStream.write(messageAsBytes);
754100    }
755  
756     /**
757      * Gets response header parameter.
758      * @return String
759      *          parameter ready for sending
760      */
761     private String getResponseParameterAsString ()
762     {
763100       final StringBuffer buffer = new StringBuffer();
764100       final Iterator keyIterator = mResponseParameter.keySet().iterator();
765100       while (keyIterator.hasNext())
766        {
767100          final String key = (String) keyIterator.next();
768100          final String value = (String) mResponseParameter.get(key);
769100          buffer.append(key);
770100          buffer.append(": ");
771100          buffer.append(value);
772100          buffer.append(NEW_LINE);
773100       }
774100       return buffer.toString();
775     }
776  
777     /**
778      * Gets the request as string.
779      * @return String
780      *          the incoming request
781      */
782     private String requestToString ()
783     {
784100       final StringBuffer buffer = new StringBuffer();
785100       buffer.append(mRequestLine);
786100       buffer.append(NEW_LINE);
787100       final Iterator keyIterator = mRequestParameter.keySet().iterator();
788100       while (keyIterator.hasNext())
789        {
790100          final String key = (String) keyIterator.next();
791100          final String value = (String) mRequestParameter.get(key);
792100          buffer.append(key);
793100          buffer.append(": ");
794100          buffer.append(value);
795100          buffer.append(NEW_LINE);
796100       }
797100       buffer.append(NEW_LINE);
798100       buffer.append(mRequestBody);
799100       return buffer.toString();
800     }
801  
802     /**
803      * Checks flag indicating to stop handler thread.
804      */
805     public void haveToStop ()
806     {
8070       mHaveToStop = true;
8080    }
809  
810  }

Findings in this File

f (32) A method/constructor shouldn't explicitly throw java.lang.Exception Not required for testcode.
f (33) A method/constructor shouldn't explicitly throw java.lang.Exception Not required for testcode.
f (34) A method/constructor shouldn't explicitly throw java.lang.Exception Not required for testcode.
f (35) A method/constructor shouldn't explicitly throw java.lang.Exception Not required for testcode.
f (36) A method/constructor shouldn't explicitly throw java.lang.Exception Not required for testcode.
f (37) A method/constructor shouldn't explicitly throw java.lang.Exception Not required for testcode.
f (38) A method/constructor shouldn't explicitly throw java.lang.Exception Not required for testcode.
c (1) 52 : 0 Type Javadoc comment is missing an @author tag.
d (2) 144 : 16 Avoid printStackTrace(); use a logger call instead.
d (3) 159 : 10 Avoid printStackTrace(); use a logger call instead.
i (4) 237 : 26 StringBuffer constructor is initialized with size 16, but has at least 113 characters appended. (test code)
i (5) 271 : 0 Method org.jcoderz.commons.connector.http.transport.ClientHandler.readRequestLine() throws alternative exception from catch block without history (test code) Decreased severity from 'warning' for testcode.
i (6) 284 : 0 Method org.jcoderz.commons.connector.http.transport.ClientHandler.readRequestLine() passes constant String of length 1 to character overridden method (test code) Decreased severity from 'warning' for testcode.
i (7) 284 : 29 String.indexOf(char) is faster than String.indexOf(String). (test code)
i (8) 288 : 0 Method org.jcoderz.commons.connector.http.transport.ClientHandler.readRequestLine() passes constant String of length 1 to character overridden method (test code) Decreased severity from 'warning' for testcode.
i (9) 288 : 27 String.indexOf(char) is faster than String.indexOf(String). (test code)
i (10) 302 : 0 Redundant nullcheck of httpVersion, which is known to be non-null in org.jcoderz.commons.connector.http.transport.ClientHandler.readRequestLine() (test code)
i (11) 330 : 0 Method org.jcoderz.commons.connector.http.transport.ClientHandler.readHeaderAttributes() throws alternative exception from catch block without history (test code) Decreased severity from 'warning' for testcode.
i (12) 362 : 0 method org.jcoderz.commons.connector.http.transport.ClientHandler.checkSpecialParameter() makes literal string comparisons passing the literal as an argument (test code)
i (13) 373 : 0 method org.jcoderz.commons.connector.http.transport.ClientHandler.checkSpecialParameter() makes literal string comparisons passing the literal as an argument (test code)
i (14) 384 : 0 method org.jcoderz.commons.connector.http.transport.ClientHandler.checkSpecialParameter() makes literal string comparisons passing the literal as an argument (test code)
i (15) 395 : 0 method org.jcoderz.commons.connector.http.transport.ClientHandler.checkSpecialParameter() makes literal string comparisons passing the literal as an argument (test code)
i (16) 429 : 0 Method org.jcoderz.commons.connector.http.transport.ClientHandler.parseHeaderLine(String) passes constant String of length 1 to character overridden method (test code) Decreased severity from 'warning' for testcode.
i (17) 429 : 25 String.indexOf(char) is faster than String.indexOf(String). (test code)
i (18) 497 : 0 Method org.jcoderz.commons.connector.http.transport.ClientHandler.readRequestBody() throws alternative exception from catch block without history (test code) Decreased severity from 'warning' for testcode.
i (19) 510 : 0 Method org.jcoderz.commons.connector.http.transport.ClientHandler.readRequestBody() throws alternative exception from catch block without history (test code) Decreased severity from 'warning' for testcode.
i (20) 600 : 35 StringBuffer constructor is initialized with size 16, but has at least 18 characters appended. (test code)
i (21) 601 : 29 StringBuffer.append is called 2 consecutive times with literal Strings. Use a single append with a single String. (test code)
i (22) 602 : 0 method org.jcoderz.commons.connector.http.transport.ClientHandler.read(int) passes simple concatenating string in StringBuffer or StringBuilder append (test code) Decreased severity from 'warning' for testcode.
i (23) 602 : 29 StringBuffer.append is called 2 consecutive times with literal Strings. Use a single append with a single String. (test code)
i (24) 604 : 0 method org.jcoderz.commons.connector.http.transport.ClientHandler.read(int) passes simple concatenating string in StringBuffer or StringBuilder append (test code) Decreased severity from 'warning' for testcode.
i (25) 620 : 0 Method org.jcoderz.commons.connector.http.transport.ClientHandler.read(int) throws alternative exception from catch block without history (test code) Decreased severity from 'warning' for testcode.
i (26) 620 : 0 method org.jcoderz.commons.connector.http.transport.ClientHandler.read(int) throws exception with static message string (test code)
i (27) 637 : 0 method org.jcoderz.commons.connector.http.transport.ClientHandler.getEncoding() makes literal string comparisons passing the literal as an argument (test code)
i (28) 668 : 0 Method org.jcoderz.commons.connector.http.transport.ClientHandler.getEncodingFromCharsetValue(String) passes constant String of length 1 to character overridden method (test code) Decreased severity from 'warning' for testcode.
i (29) 670 : 0 Method org.jcoderz.commons.connector.http.transport.ClientHandler.getEncodingFromCharsetValue(String) assigns a variable in a larger scope then is needed (test code) Decreased severity from 'warning' for testcode.
i (30) 670 : 0 Method org.jcoderz.commons.connector.http.transport.ClientHandler.getEncodingFromCharsetValue(String) passes constant String of length 1 to character overridden method (test code) Decreased severity from 'warning' for testcode.
i (31) 744 : 26 StringBuffer constructor is initialized with size 16, but has at least 36 characters appended. (test code)