https://issues.apache.org/bugzilla/show_bug.cgi?id=52769
Bug #: 52769 Summary: Potential Bug or Inconsistency in AjpMessage.java Product: Tomcat 7 Version: trunk Platform: All OS/Version: All Status: NEW Severity: normal Priority: P2 Component: Catalina AssignedTo: dev@tomcat.apache.org ReportedBy: msrbugzi...@gmail.com Classification: Unclassified This is Ken Cheung, a Computer Science M.Phil. student. I observed some code clones in Tomcat and found inconsistent code: /tomcat/trunk/java/org/apache/coyote/ajp/AjpMessage.java 195 if (cc == null) { 196 log.error(sm.getString("ajpmessage.null"), 197 new NullPointerException()); 198 appendInt(0); 199 appendByte(0); 200 return; 201 } 202 int start = cc.getStart(); 203 int end = cc.getEnd(); 204 appendInt(end - start); 205 char[] cbuf = cc.getBuffer(); 206 for (int i = start; i < end; i++) { 207 char c = cbuf[i]; 208 // Note: This is clearly incorrect for many strings, 209 // but is the only consistent approach within the current 210 // servlet framework. It must suffice until servlet output 211 // streams properly encode their output. 212 if (((c <= 31) && (c != 9)) || c == 127 || c > 255) { 213 c = ' '; 214 } 215 appendByte(c); 216 } 217 appendByte(0); /tomcat/trunk/java/org/apache/coyote/ajp/AjpMessage.java 230 if (str == null) { 231 log.error(sm.getString("ajpmessage.null"), 232 new NullPointerException()); 233 appendInt(0); 234 appendByte(0); 235 return; 236 } 237 int len = str.length(); 238 appendInt(len); 239 for (int i = 0; i < len; i++) { 240 char c = str.charAt (i); 241 // Note: This is clearly incorrect for many strings, 242 // but is the only consistent approach within the current 243 // servlet framework. It must suffice until servlet output 244 // streams properly encode their output. 245 if (((c <= 31) && (c != 9)) || c == 127 || c > 255) { 246 c = ' '; 247 } 248 appendByte(c); 249 } 250 appendByte(0); Quick description of the inconsistency Two code snippets are very similar code, but as you see, both codes use different ways to compute the condition of for loop. We thought it could be a potential bug or inconsistency. Hope this helps. -- Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org