Re: session invalid?

2001-06-12 Thread DAK

Got it figured out. I turns out that the proxy within Xerox was messing 
up the cookies. Disable the proxy and all is well!

   David

DAK wrote:

 
 I'm seeing something strange. (would I write if it wasn't strange?)
 I have a servlet that is used to generate an image. I include the URL 
 to it as output from another servlet. (so it is embedded in the page 
 generated by the first). Somewhat regularly, it fails to get the 
 session object. I call request.isSessionValid() and get false. If I 
 reload the page, it works fine. I'm not sure where to look. I'm using 
 Tomcat 3.2.2 on Solaris 8. I've looked that the source for 3.2.2 and 
 can't find anything about getting the session object that looks out of 
 whack. The only thing that could cause this was if the session was 
 temporarily invalid. The valid flag shouldn't be subject to race 
 conditions since it is set and not changed until the session is 
 recycled (or invalidated). I know I'm not marking it invalid since my 
 other servlets can continue to get the session object and that same 
 preview servlet that failed, will succeed the next time around.
 
 Any pointers for the more seasoned folks? I'm going to try switching 
 from session cookies to see how that works.
 
   David
 




Re: RPM of 3.3m3 - XERCES-J instead of JAXP - Agree ?

2001-06-06 Thread DAK

I agree about JAXP1.1 I've been using that with tomcat 3.2.x without any 
problems. I use Xalan and XSLT, so thought it would be nice to have 
everything running the same parser.

   David

[EMAIL PROTECTED] wrote:

 What about using jaxp-1.1 ? You can now build the whole thing from 
 xml-commons, xml-crimson and xml-xalan. 
 
 Jaxp1.0 is quite old, we should upgrade ( many bugs were fixed  ).
 
 I personally prefer using crimson ( but I can live with xerces1 ) - code
 size is the one reason ( I also worked much more with crimson ). Long term
 we'll use xerces2 of course. 
 
 Costin
 
 
 
 On Tue, 5 Jun 2001, GOMEZ Henri wrote:
 
 Just to comment the RPM building :
 
 In my TC 3.3-m3 RPM, I choose to use xerces-j = 1.2
 instead of the jaxp 1.1 present on TC 3.3
 
 I add the RPM dependency and didn't install jaxp.jar
 and parser.jar. At install time the RPM make a link
 to xerces in common lib :
 
 ln -s /usr/share/java/xerces.jar /var/tomcat/lib/common/xerces.jar
 
 Do you (users) agree ?
 
 In TC 3.2.2, I was installing a required jaxp.jar and parser.jar
 but in some case you could just have xerces.jar installed :!
 
 I'll modify the spec and will release an updated RPM ASAP.
 
 -
 Henri Gomez ___[_]
 EMAIL : [EMAIL PROTECTED](. .) 
 PGP KEY : 697ECEDD...oOOo..(_)..oOOo...
 PGP Fingerprint : 9DF8 1EA8 ED53 2F39 DC9B 904A 364F 80E6 
 
 
 
 -Original Message-
 From: GOMEZ Henri [mailto:[EMAIL PROTECTED]]
 Sent: Tuesday, June 05, 2001 12:58 PM
 To: [EMAIL PROTECTED]
 Subject: RE: RPM of 3.3m3 dependencies
 
 
 xerces
 
 I try to install on Mandrake 8.0,  tomcat-3.3-m3.1.noarch.rpm  
 and it has 
 a dependencie on Xerces-j. I found it at xml.apache.org, but 
 no rpm what DO 
 you have a solution ?
 ps: I then check with  tomcat-3.2.2-1.noarch.rpm   and 
 everything works 
 perfectly.
 
 Apache rpms are allways available at :
 
 ftp://ftp.falsehope.com/home/gomez/xerces-j/
 ftp://ftp.falsehope.com/home/gomez/xalan-j/
 ftp://ftp.falsehope.com/home/gomez/tomcat/
 
 Warning if you use also xalan-j 2.1.0 since this
 one will failed to use xerces.jar if you have jaxp.jar
 and parser.jar in THE SAME DIRECTORY THAT xalan.jar.
 
 I make a bug report on xalan list :)
 




Re: [BUG T322] Bug in getServletContext().getResource() for relative URLs

2001-05-30 Thread DAK

Yes, Have a look at this

Bug Id: 4447088
On the Bug Parade at the JDC. I submitted this after trying to use 
classloader.getResource() in a servlet. URL doesn't construct a proper 
URL string when the constructor you show is used. Works fine on 
unix/linux, but windows absolute paths can start with a letter, not a 
slash. I'd like to see tomcat use a different constructor so I can rip 
out some special code that checks the classloader first!

   David

Stevenson, Chris (SSABSA) wrote:

 Bugzilla is down so I am forced to send this to the list:
 
 Relative URLs from a servlet resource do not work (Tomcat 3.2.2).
 
 I have the following code in a Servlet:
 
 URL propURL = getServletContext().getResource(
 /WEB-INF/connection.properties )
 URL configURL = new URL( url, config.xml );
 
 The servlet throws a FileNotFoundException on configURL.getInputStream() 
 some diagnostic info follows:
 
 Could not load configuration file: file:persist.config.xml
 propURL: file:F:\tomcat\tomcat-dev\webapps\ore\WEB-INF\connection.properties
 configURL: persist.config.xml
 
 Apache Tomcat/4.0-b5 works perfectly, but its using jndi.
 
 Also, if I do the following:
 
 URL configURL = new URL( url, config.xml );
 configURL = new URL( configURL.toString() );
 
 it works!
 
 java version 1.3.1
 Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1-b24)
 Java HotSpot(TM) Client VM (build 1.3.1-b24, mixed mode)
 
 Full Exception is
 java.io.FileNotFoundException: persist.config.xml (The system cannot find
 the file specified)
 at java.io.FileInputStream.open(Native Method)
 at java.io.FileInputStream.init(FileInputStream.java:64)
 at
 sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:6
 9)
 at
 sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection
 .java:133)
 at java.net.URL.openStream(URL.java:798)
 at ssabsa.control.Controller.init(Controller.java:52)
 at ssabsa.control.Controller.getInstance(Controller.java:74)
 at ssabsa.ore.WoreServlet.init(WoreServlet.java:47)
 at javax.servlet.GenericServlet.init(GenericServlet.java:258)
 at
 org.apache.tomcat.core.ServletWrapper.doInit(ServletWrapper.java:317)
 at org.apache.tomcat.core.Handler.init(Handler.java:215)
 at
 org.apache.tomcat.core.ServletWrapper.init(ServletWrapper.java:296)
 at
 org.apache.tomcat.context.LoadOnStartupInterceptor.contextInit(LoadOnStartup
 Interceptor.java:130)
 at
 org.apache.tomcat.core.ContextManager.initContext(ContextManager.java:491)
 at
 org.apache.tomcat.core.ContextManager.init(ContextManager.java:453)
 at org.apache.tomcat.startup.Tomcat.execute(Tomcat.java:195)
 at org.apache.tomcat.startup.Tomcat.main(Tomcat.java:235)
 
 
 




Re: [PATCH] Bug fix for #1678

2001-05-24 Thread DAK

Now, this is what I was talking about with the upload data corruption! 
Finally, corroboration!

   David

Hiro Takahashi wrote:

 This is the fix for ServletInputStream.read() bug.
 #1678: http://nagoya.apache.org/bugzilla/show_bug.cgi?id=1678
 The change is in Ajp13ConnectorRequest.java. This one is obviously
 the one which has not been tested with a binary data.
 I made this patch for 3.2.1.
 
 Index: Ajp13ConnectorRequest.java
 ===
 RCS file: 
jakarta-tomcat/src/share/org/apache/tomcat/service/connector/Ajp13ConnectorRequest.java,v
 retrieving revision 1.1
 diff -u -r1.1 Ajp13ConnectorRequest.java
 --- Ajp13ConnectorRequest.java2001/05/23 22:41:09 1.1
 +++ Ajp13ConnectorRequest.java2001/05/24 06:20:53
 @@ -251,8 +251,12 @@
  {
  if(pos = blen) {
  refeelReadBuffer();
 + if (pos= blen) {
 + // seems no data
 + return -1;
 + }
  }
 -return bodyBuff[pos++];
 +return bodyBuff[pos++]  0xff;
  }
  
  public int doRead(byte[] b, int off, int len) throws IOException 
 @@ -261,7 +265,6 @@
  for(int i = off ; i  (len + off) ; i++) {
  int a = doRead();
  if(-1 == a) {
 -System.out.println(Y);
  return i-off;
  }
  b[i] = (byte)a;
 




tomcat.sh for cygwin

2001-05-24 Thread DAK

For those who use cygwin on windows, here is a version of the tomcat.sh 
script that I've been using.
Perhaps this could go in the repository under tomcat.cygwin

   David


#!/bin/sh
#
# $Id: tomcat.sh,v 1.17.2.1 2000/11/17 22:05:50 glenn Exp $

# Shell script to start and stop the server

# There are other, simpler commands to startup the runner. The two
# commented commands good replacements. The first works well with
# Java Platform 1.1 based runtimes. The second works well with
# Java2 Platform based runtimes.

#jre -cp runner.jar:servlet.jar:classes org.apache.tomcat.shell.Startup $*
#java -cp runner.jar:servlet.jar:classes org.apache.tomcat.shell.Startup $*

if [ -f $HOME/.tomcatrc ] ; then 
  . $HOME/.tomcatrc
fi

if [ $TOMCAT_HOME =  ] ; then
  ## resolve links - $0 may be a link to  home
  PRG=$0
  progname=`basename $0`
  
  while [ -h $PRG ] ; do
ls=`ls -ld $PRG`
link=`expr $ls : '.*- \(.*\)$'`
if expr $link : '.*/.*'  /dev/null; then
PRG=$link
else
PRG=`dirname $PRG`/$link
fi
  done
  
  TOMCAT_HOME_1=`dirname $PRG`/..
  echo Guessing TOMCAT_HOME from tomcat.sh to ${TOMCAT_HOME_1} 
if [ -d ${TOMCAT_HOME_1}/conf ] ; then 
TOMCAT_HOME=${TOMCAT_HOME_1}
echo Setting TOMCAT_HOME to $TOMCAT_HOME
fi
fi


if [ $TOMCAT_HOME =  ] ; then
  # try to find tomcat
  if [ -d ${HOME}/opt/tomcat/conf ] ; then 
TOMCAT_HOME=${HOME}/opt/tomcat
echo Defaulting TOMCAT_HOME to $TOMCAT_HOME
  fi

  if [ -d /opt/tomcat/conf ] ; then 
TOMCAT_HOME=/opt/tomcat
echo Defaulting TOMCAT_HOME to $TOMCAT_HOME
  fi
 
  # Add other standard locations for tomcat
fi

if [ $TOMCAT_HOME =  ] ; then
echo TOMCAT_HOME not set, you need to set it or install in a standard location
exit 1
fi

if [ $TOMCAT_OPTS =  ] ; then
  TOMCAT_OPTS=
fi

if [ $ANT_OPTS =  ] ; then
  ANT_OPTS=
fi

if [ $JSPC_OPTS =  ] ; then
  JSPC_OPTS=
fi

if [ -z $JAVA_HOME ] ;  then
  JAVA=`which java`
  if [ -z $JAVA ] ; then
echo Cannot find JAVA. Please set your PATH.
exit 1
  fi
  JAVA_BINDIR=`dirname $JAVA`
  JAVA_HOME=$JAVA_BINDIR/..
fi

if [ $JAVACMD =  ] ; then 
   # it may be defined in env - including flags!!
   JAVACMD=$JAVA_HOME/bin/java
fi

oldCP=$CLASSPATH
 
unset CLASSPATH
for i in ${TOMCAT_HOME}/lib/* ; do
  if [ $CLASSPATH !=  ]; then
CLASSPATH=${CLASSPATH};$i
  else
CLASSPATH=$i
  fi
done

if [ -f ${JAVA_HOME}/lib/tools.jar ] ; then
   # We are probably in a JDK1.2 environment
   CLASSPATH=${CLASSPATH};${JAVA_HOME}/lib/tools.jar
fi

# Backdoor classpath setting for development purposes when all classes
# are compiled into a /classes dir and are not yet jarred.
if [ -d ${TOMCAT_HOME}/classes ]; then
CLASSPATH=${TOMCAT_HOME}/classes;${CLASSPATH}
fi

if [ $oldCP !=  ]; then
CLASSPATH=${CLASSPATH};${oldCP}
fi

export CLASSPATH

# We start the server up in the background for a couple of reasons:
#   1) It frees up your command window
#   2) You should use `stop` option instead of ^C to bring down the server
if [ $1 = start ] ; then 
  shift 
  echo Using classpath: ${CLASSPATH}
echo options: ${TOMCAT_OPTS}
  if [ $1 = -security ] ; then
echo Starting with a SecurityManager
$JAVACMD $TOMCAT_OPTS -Djava.security.manager 
-Djava.security.policy==${TOMCAT_HOME}/conf/tomcat.policy -Dtomcat.home=${TOMCAT_HOME} 
 org.apache.tomcat.startup.Tomcat $@ 
  else
  $JAVACMD $TOMCAT_OPTS -Dtomcat.home=${TOMCAT_HOME}  org.apache.tomcat.startup.Tomcat 
$@ 
  fi
#   $JAVACMD org.apache.tomcat.shell.Startup $@ 

elif [ $1 = stop ] ; then 
  shift 
  echo Using classpath: ${CLASSPATH}
  $JAVACMD $TOMCAT_OPTS -Dtomcat.home=${TOMCAT_HOME} org.apache.tomcat.startup.Tomcat 
-stop $@
#   $JAVACMD org.apache.tomcat.shell.Shutdown $@

elif [ $1 = run ] ; then 
  shift 
  echo Using classpath: ${CLASSPATH}
  if [ $1 = -security ] ; then
echo Starting with a SecurityManager
$JAVACMD $TOMCAT_OPTS -Djava.security.manager 
-Djava.security.policy==${TOMCAT_HOME}/conf/tomcat.policy -Dtomcat.home=${TOMCAT_HOME} 
org.apache.tomcat.startup.Tomcat $@
  else
  $JAVACMD $TOMCAT_OPTS -Dtomcat.home=${TOMCAT_HOME} org.apache.tomcat.startup.Tomcat 
$@ 
  fi
#  $JAVACMD org.apache.tomcat.shell.Startup $@ 
  # no 

elif [ $1 = ant ] ; then 
  shift 

  $JAVACMD $ANT_OPTS -Dant.home=${TOMCAT_HOME} -Dtomcat.home=${TOMCAT_HOME} 
org.apache.tools.ant.Main $@

elif [ $1 = jspc ] ; then 
  shift 

  $JAVACMD $JSPC_OPTS -Dtomcat.home=${TOMCAT_HOME} org.apache.jasper.JspC $@

elif [ $1 = env ] ; then 
  ## Call it with source tomcat.sh to set the env for tomcat
  shift 
  echo Setting classpath to: ${CLASSPATH}
  oldCP=$CLASSPATH

else
  echo Usage:
  echo tomcat (start|env|run|stop|ant)
  echo start - start tomcat in the background
  echo run   - start tomcat in the foreground
  echo   -security - use a SecurityManager when starting
  echo stop  - stop tomcat
  echo env  -  set CLASSPATH and TOMCAT_HOME env. variables
  echo

servlet upload data corruption (more)

2001-05-19 Thread DAK


I finally got out from under some work and was able to make some test 
code. I'm attaching the client and servlet code.
The code transfers a couple parameters, then a binary file (I was using 
a .jar). If you call the client with
BinTestClient localhost something.jar b, it uses byte-by-byte read on 
the server to spool the file to a temp file. If you call the client 
without the 'b', it uses the byte-array read that I was complaining 
about.  Transfer a file, then try jar tvf test.jar to see if it 
works. I uses a jar that contains .jpg images and when using the byte 
array read method, it creats a corrupt jar file. If I apply my fix to 
the Ajp13ConnectorRequest class, it works fine.
(I tried a jar that contained class files and it worked anyway...)
I'd like for someone else to try this out to make sure I didn't screw 
something up. The code seems pretty simple.
I discovered this when using JarIn/OutputStream to transfer data from 
client to servlet.

   David



import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;
import java.net.URLConnection;

//  args[0] = hostname
//  args[1] = jarfile
//  args[2] = 'b' for single byte read.
public class BinTestClient {

public static void main(String [] args) {
try {
URL url = new URL(http://+args[0]+/examples/BinTest;);
URLConnection connection = (URLConnection)url.openConnection();
connection.setDoOutput(true);
connection.setUseCaches(false);
DataOutputStream output = new 
DataOutputStream(connection.getOutputStream());
File jarFile = new File(args[1]);
if (jarFile.exists()) {
output.writeUTF(+jarFile.length());
}
if (args.length  2  args[2] != null  
args[2].trim().equals(b))
output.writeChar('b');
else
output.writeChar(' ');

InputStream istr = new FileInputStream(jarFile);
byte [] buf = new byte[8192];
int count = istr.read(buf);
while (count != -1) {
if (count  0)
output.write(buf, 0, count);
count = istr.read(buf);
}
istr.close();
output.flush();
output.close();

istr = connection.getInputStream();
istr.read();
} catch (Exception ex) {
ex.printStackTrace();
}
}
}



import java.io.DataInputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.IOException;
import java.io.OutputStream;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class BinTestServlet extends HttpServlet{

public void doPost (HttpServletRequest request, HttpServletResponse response) {
try {
DataInputStream istr = new 
DataInputStream(request.getInputStream());
long fileLen = Long.parseLong(istr.readUTF());
char mode = istr.readChar();

File tmp = File.createTempFile(test, .jar);
OutputStream fstr = new FileOutputStream(tmp);
if (mode == 'b') {
System.out.println(Using byte-by-byte read);
for (int i=0; ifileLen; i++)
fstr.write(istr.read());
}
else {
System.out.println(Using byte-array read);
byte [] buf = new byte[8192];
int count = istr.read(buf);
while (count != -1) {
if (count  0)
fstr.write(buf, 0, count);
count = istr.read(buf);
}
}
fstr.flush();
fstr.close();

OutputStream ostr = response.getOutputStream();
ostr.write(1);  // positive response
} catch (Exception ex) {
ex.printStackTrace();
}
}
}



upload data corruption report

2001-05-19 Thread DAK

I've been asked to provide more information, so here is combination of 
the two messages I posted with some more commentary and attachments.

It pertains to Tomcat-3.2.1 and looks to be  the same in 3.2.2.b4. I'm 
running Apache 1.3.17 on Win 2K Professional. I'm also using mod_jk

I have some client code that sends a jar file to the servlet. The jar 
file was getting corrupted. After much digging, I found a CVS commit to 
Ajp13ConnectorRequest.java that mentioned a problem like this with the 
doRead() method. It turns out the the same applies to the doRead(byte[], 
int, int) method. The same problem exists in the Ajp12ConnectionHandler 
for that byte array read. Single byte reads for both protocols work just 
fine. I'm including the diffs for these classes to show what I'm talking 
about.


I finally got out from under some work and was able to make some test 
code. I'm attaching the client and servlet code.
The code transfers a couple parameters, then a binary file (I was using 
a .jar). If you call the client with
BinTestClient localhost something.jar b, it uses byte-by-byte read on 
the server to spool the file to a temp file. If you call the client 
without the 'b', it uses the byte-array read that I was complaining 
about.  Transfer a file, then try jar tvf test.jar to see if it 
works. I uses a jar that contains .jpg images and when using the byte 
array read method, it creats a corrupt jar file. If I apply my fix to 
the Ajp13ConnectorRequest class, it works fine.
(I tried a jar that contained class files and it worked anyway...)
I'd like for someone else to try this out to make sure I didn't screw 
something up. The code seems pretty simple.
I discovered this when using JarIn/OutputStream to transfer data from  
client to servlet.I've seen this type of thing in Java before when 
writing code that talks to hardware (such as touchscreen driver and 
scanner drivers).

   David



Index: Ajp13ConnectorRequest.java
===
RCS file: 
/home/cvspublic/jakarta-tomcat/src/share/org/apache/tomcat/service/connector/Attic/Ajp13ConnectorRequest.java,v
retrieving revision 1.5.2.7
diff -r1.5.2.7 Ajp13ConnectorRequest.java
274c274,277
   System.arraycopy(bodyBuff, pos, b, off, c);
---
   //System.arraycopy(bodyBuff, pos, b, off, c);
   for (int i=pos, j=off, d=c; d  0; i++, j++, d--) {
   b[j] = (byte)(((char)bodyBuff[i])0xff);
   }

What I've done here is to replace the array copy with a loop that does the appropriate 
data conversion.


Index: Ajp12ConnectionHandler.java
===
RCS file: 
/home/cvspublic/jakarta-tomcat/src/share/org/apache/tomcat/service/connector/Attic/Ajp12ConnectionHandler.java,v
retrieving revision 1.28.2.4
diff -r1.28.2.4 Ajp12ConnectionHandler.java
542a543,549
 public  int read(byte b[], int off, int len) throws IOException {
   int ret = super.read(b, off, len);
   for (int i=0, j=off; ilen; i++, j++) {
   b[j] = (byte)(((char)b[j])0xff);
   }
   return ret;
 }

In this case, I over-rode the read method to convert the data after calling the 
super.read 




import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;
import java.net.URLConnection;

//  args[0] = hostname
//  args[1] = jarfile
//  args[2] = 'b' for single byte read.
public class BinTestClient {

public static void main(String [] args) {
try {
URL url = new URL(http://+args[0]+/examples/BinTest;);
URLConnection connection = (URLConnection)url.openConnection();
connection.setDoOutput(true);
connection.setUseCaches(false);
DataOutputStream output = new 
DataOutputStream(connection.getOutputStream());
File jarFile = new File(args[1]);
if (jarFile.exists()) {
output.writeUTF(+jarFile.length());
}
if (args.length  2  args[2] != null  
args[2].trim().equals(b))
output.writeChar('b');
else
output.writeChar(' ');

InputStream istr = new FileInputStream(jarFile);
byte [] buf = new byte[8192];
int count = istr.read(buf);
while (count != -1) {
if (count  0)
output.write(buf, 0, count);
count = istr.read(buf);
}
istr.close();
output.flush();
output.close();

  

Re: Servlet Upload Data Corruption

2001-05-17 Thread DAK

This is the log message to which I'm referring. It put the (char) in the 
return statement of doRead()

revision 1.5.2.4
date: 2001/01/30 04:17:53;  author: danmil;  state: Exp;  lines: +4 -4

Fixed (yet another) bug with File Upload.  Tomcat was returning signed data
to servlets (via ServletInputStream.read()), which was causing servlets to
read 0xFF as EOF.

Contributed by Keith Wannamaker ([EMAIL PROTECTED]):


David

kevin seguin wrote:

 i didn't see any comments in commit messages that mentioned the problem
 you are speaking of.  can you find that comment again and send it? 
 thanks.
 
 DAK wrote:
 
 Here's my first submission! It pertains to Tomcat-3.2.1 and looks to be
 the same in 3.2.2.b4
 
 I have some client code that sends a jar file to the servlet. The jar
 file was getting corrupted. After much digging, I found a CVS commit to
 Ajp13ConnectorRequest.java that mentioned a problem like this with the
 doRead() method. It turns out the the same applies to the doRead(byte[],
 int, int) method. The same problem exists in the Ajp12ConnectionHandler
 for that byte array read. Single byte reads for both protocols work just
 fine. I'm including the diffs for these classes to show what I'm talking
 about. I may be called a developer now, but I'm certainly not a
 commiter, so what is the procedure for getting this fix validated by
 somebody else and put into the codebase?
 
 Index: Ajp13ConnectorRequest.java
 ===
 RCS file:
 
/home/cvspublic/jakarta-tomcat/src/share/org/apache/tomcat/service/connector/Attic/Ajp13ConnectorRequest.java,v
 retrieving revision 1.5.2.7
 diff -r1.5.2.7 Ajp13ConnectorRequest.java
 274c274,277
System.arraycopy(bodyBuff, pos, b, off, c);
 ---
 //System.arraycopy(bodyBuff, pos, b, off, c);
 for (int i=pos, j=off, d=c; d  0; i++, j++, d--) {
 b[j] = (byte)(((char)bodyBuff[i])0xff);
 }
 
 What I've done here is to replace the array copy with a loop that does
 the appropriate data conversion.
 
 Index: Ajp12ConnectionHandler.java
 ===
 RCS file:
 
/home/cvspublic/jakarta-tomcat/src/share/org/apache/tomcat/service/connector/Attic/Ajp12ConnectionHandler.java,v
 retrieving revision 1.28.2.4
 diff -r1.28.2.4 Ajp12ConnectionHandler.java
 542a543,549
   public  int read(byte b[], int off, int len) throws IOException {
 int ret = super.read(b, off, len);
 for (int i=0, j=off; ilen; i++, j++) {
 b[j] = (byte)(((char)b[j])0xff);
 }
 return ret;
   }
 
 In this case, I over-rode the read method to convert the data after
 calling the super.read
 
 I'd like to see this stuff end up in 3.2.2.b5
 
Thanks,
David Kavanagh
 




Servlet Upload Data Corruption

2001-05-16 Thread DAK

Here's my first submission! It pertains to Tomcat-3.2.1 and looks to be 
the same in 3.2.2.b4

I have some client code that sends a jar file to the servlet. The jar 
file was getting corrupted. After much digging, I found a CVS commit to 
Ajp13ConnectorRequest.java that mentioned a problem like this with the 
doRead() method. It turns out the the same applies to the doRead(byte[], 
int, int) method. The same problem exists in the Ajp12ConnectionHandler 
for that byte array read. Single byte reads for both protocols work just 
fine. I'm including the diffs for these classes to show what I'm talking 
about. I may be called a developer now, but I'm certainly not a 
commiter, so what is the procedure for getting this fix validated by 
somebody else and put into the codebase?

Index: Ajp13ConnectorRequest.java
===
RCS file: 
/home/cvspublic/jakarta-tomcat/src/share/org/apache/tomcat/service/connector/Attic/Ajp13ConnectorRequest.java,v
retrieving revision 1.5.2.7
diff -r1.5.2.7 Ajp13ConnectorRequest.java
274c274,277
   System.arraycopy(bodyBuff, pos, b, off, c);
---
//System.arraycopy(bodyBuff, pos, b, off, c);
for (int i=pos, j=off, d=c; d  0; i++, j++, d--) {
b[j] = (byte)(((char)bodyBuff[i])0xff);
}

What I've done here is to replace the array copy with a loop that does 
the appropriate data conversion.


Index: Ajp12ConnectionHandler.java
===
RCS file: 
/home/cvspublic/jakarta-tomcat/src/share/org/apache/tomcat/service/connector/Attic/Ajp12ConnectionHandler.java,v
retrieving revision 1.28.2.4
diff -r1.28.2.4 Ajp12ConnectionHandler.java
542a543,549
  public  int read(byte b[], int off, int len) throws IOException {
int ret = super.read(b, off, len);
for (int i=0, j=off; ilen; i++, j++) {
b[j] = (byte)(((char)b[j])0xff);
}
return ret;
  }

In this case, I over-rode the read method to convert the data after 
calling the super.read


I'd like to see this stuff end up in 3.2.2.b5


   Thanks,
   David Kavanagh