Re: cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/util/buf ByteChunk.java

2001-06-03 Thread kevin seguin

i was looking at the diffs here because i was going to propagate this
change to jakarta-tomcat-connectors, but i'm no sure i understand this:

public int getOffset() {
   - return getStart();
   + return getEnd();
}

perhaps i'm missing something, but it looks like the offset returned by
getOffset() should be the offset into the byte array contained in
ByteChunk, which would be the start position in this case, rather than
the end position.

also, if you look at the append() and equals() methods that take
ByteChunk's as arguments, if getOffset() returns the end position rather
than the start position, these methods won't work as intended.  for
example, equals() will start comparing comparing bytes at the end of the
ByteChunk, rather than the start of it.

just a sanity check...

-kevin.

[EMAIL PROTECTED] wrote:
 
 nacho   01/06/02 14:53:46
 
   Modified:src/share/org/apache/tomcat/util/buf ByteChunk.java
   Log:
   Latest encoding fixes left some problems in the way.
   Fixing a hack is a hazardous task..
 
   Revision  ChangesPath
   1.5   +11 -10
jakarta-tomcat/src/share/org/apache/tomcat/util/buf/ByteChunk.java
 
   Index: ByteChunk.java
   ===
   RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/buf/ByteChunk.java,v
   retrieving revision 1.4
   retrieving revision 1.5
   diff -u -r1.4 -r1.5
   --- ByteChunk.java2001/05/27 23:16:19 1.4
   +++ ByteChunk.java2001/06/02 21:53:46 1.5
   @@ -208,12 +208,13 @@
public int getStart() {
 return start;
}
   -
   +
public int getOffset() {
   - return getStart();
   + return getEnd();
}
 
public void setOffset(int off) {
   +if (end  off ) end=off;
 start=off;
}
 
   @@ -263,7 +264,7 @@
{
 append( (byte)c);
}
   -
   +
public void append( byte b )
 throws IOException
{
   @@ -275,13 +276,13 @@
 }
 buff[end++]=b;
}
   -
   +
public void append( ByteChunk src )
 throws IOException
{
 append( src.getBytes(), src.getOffset(), src.getLength());
}
   -
   +
/** Add data to the buffer
 */
public void append( byte src[], int off, int len )
   @@ -297,7 +298,7 @@
 end+=len;
 return;
 }
   -
   +
 // if we have limit and we're below
 if( len = limit - end ) {
 // makeSpace will grow the buffer to the limit,
   @@ -311,7 +312,7 @@
 // buffer
 
 // the buffer is already at ( or bigger than ) limit
   -
   +
 // Optimization:
 // If len-avail  length ( i.e. after we fill the buffer with
 // what we can, the remaining will fit in the buffer ) we'll just
   @@ -327,12 +328,12 @@
 int avail=limit-end;
 System.arraycopy(src, off, buff, end, avail);
 end += avail;
   -
   +
 flushBuffer();
   -
   +
 System.arraycopy(src, off+avail, buff, end, len - avail);
 end+= len - avail;
   -
   +
 } else {// len  buf.length + avail
 // long write - flush the buffer and write the rest
 // directly from source
 
 




RE: cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/util/buf ByteChunk.java

2001-06-03 Thread Ignacio J. Ortega

 perhaps i'm missing something, but it looks like the offset 
 returned by
 getOffset() should be the offset into the byte array contained in
 ByteChunk, which would be the start position in this case, rather than
 the end position.
 

From the point of view of the o.a.t.m.s.ajp13, now getOffset() has the
correct behavior, at least now for me works, prior to that change ajp13
was unusable.., take a look in o.a.t.m.s.Ajp13.Ajp13Packet.appendString,
There is some magic in the use of ob.setbyteOff and ob.getByteOff...as i
understand this code.. ob.getByteOff is requiered to return the end of
the last writed byte chunk ..perhaps a better aproach to this fix is to
change ob.getOffset to use  bb.getEnd instead os bb.getOffset..at least
this will make the intention clearer.., in a really obscure code..

 also, if you look at the append() and equals() methods that take
 ByteChunk's as arguments, if getOffset() returns the end 
 position rather
 than the start position, these methods won't work as intended.  for
 example, equals() will start comparing comparing bytes at the 
 end of the
 ByteChunk, rather than the start of it.
 

I reviewed it, and your are right for equals..but not for append..append
is suppoused to use the end of the buffer not the start..so in append
getOffset is suppoused to return end not the start...

The better solution is to get rid of getOffset..and only use getStart or
getEnd where needed...

 just a sanity check...
 

Well done, OSS is great because of this comments..and the possibility to
make them just-in-time..:)))

 -kevin.

Saludos ,
Ignacio J. Ortega




cvs commit: jakarta-tomcat-4.0/catalina/src/share/org/apache/naming/resources DirContextURLConnection.java

2001-06-03 Thread remm

remm01/06/03 12:52:00

  Modified:catalina/src/share/org/apache/naming/resources
DirContextURLConnection.java
  Log:
  - Possible workaround for the perf problem reported by Jon : don't create
a FilePermission is there is no security manager defined.
  
  Revision  ChangesPath
  1.11  +6 -5  
jakarta-tomcat-4.0/catalina/src/share/org/apache/naming/resources/DirContextURLConnection.java
  
  Index: DirContextURLConnection.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/naming/resources/DirContextURLConnection.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- DirContextURLConnection.java  2001/05/11 18:24:33 1.10
  +++ DirContextURLConnection.java  2001/06/03 19:52:00 1.11
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/naming/resources/DirContextURLConnection.java,v
 1.10 2001/05/11 18:24:33 remm Exp $
  - * $Revision: 1.10 $
  - * $Date: 2001/05/11 18:24:33 $
  + * $Header: 
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/naming/resources/DirContextURLConnection.java,v
 1.11 2001/06/03 19:52:00 remm Exp $
  + * $Revision: 1.11 $
  + * $Date: 2001/06/03 19:52:00 $
*
* 
*
  @@ -91,7 +91,7 @@
* content is directly returned.
* 
* @author a href=mailto:[EMAIL PROTECTED];Remy Maucherat/a
  - * @version $Revision: 1.10 $
  + * @version $Revision: 1.11 $
*/
   public class DirContextURLConnection 
   extends URLConnection {
  @@ -105,7 +105,8 @@
   if (context == null)
   throw new IllegalArgumentException
   (Directory context can't be null);
  -this.permission = new FilePermission(url.toString(), read);
  +if (System.getSecurityManager() != null)
  +this.permission = new FilePermission(url.toString(), read);
   this.context = context;
   }
   
  
  
  



Re: cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/util/buf ByteChunk.java

2001-06-03 Thread kevin seguin

Ignacio J. Ortega wrote:
 
  perhaps i'm missing something, but it looks like the offset
  returned by
  getOffset() should be the offset into the byte array contained in
  ByteChunk, which would be the start position in this case, rather than
  the end position.
 
 
 From the point of view of the o.a.t.m.s.ajp13, now getOffset() has the
 correct behavior, at least now for me works, prior to that change ajp13
 was unusable.., take a look in o.a.t.m.s.Ajp13.Ajp13Packet.appendString,
 There is some magic in the use of ob.setbyteOff and ob.getByteOff...as i
 understand this code.. ob.getByteOff is requiered to return the end of
 the last writed byte chunk ..perhaps a better aproach to this fix is to
 change ob.getOffset to use  bb.getEnd instead os bb.getOffset..at least
 this will make the intention clearer.., in a really obscure code..
 

i see...  kind of makes my head hurt :)  i think you're probably right
about changing OutputBuffer.getOffset() -- i would make things clearer.

  also, if you look at the append() and equals() methods that take
  ByteChunk's as arguments, if getOffset() returns the end
  position rather
  than the start position, these methods won't work as intended.  for
  example, equals() will start comparing comparing bytes at the
  end of the
  ByteChunk, rather than the start of it.
 
 
 I reviewed it, and your are right for equals..but not for append..append
 is suppoused to use the end of the buffer not the start..so in append
 getOffset is suppoused to return end not the start...
 

are you sure?  here's the code i was looking at:

 code snip 
public void append( ByteChunk src )
throws IOException
{
append( src.getBytes(), src.getOffset(), src.getLength());
}

/** Add data to the buffer
 */
public void append( byte src[], int off, int len )
throws IOException
{
// will grow, up to limit
makeSpace( len );

// if we don't have limit: makeSpace can grow as it wants
if( limit  0 ) {
// assert: makeSpace made enough space
System.arraycopy( src, off, buff, end, len );
end+=len;
return;
}

// if we have limit and we're below
if( len = limit - end ) {
// makeSpace will grow the buffer to the limit,
// so we have space
System.arraycopy( src, off, buff, end, len );
end+=len;
return;
}
 end code snip 

it looks like when you call append(ByteChunk), the result will be an
IndexOutOfBoundsException.  in fact, this code proves that:

public void testByteChunk() throws Exception {
System.out.println(testByteChunk);

byte[] b1 = new String(bytes1).getBytes();
byte[] b2 = new String(bytes2).getBytes();

ByteChunk bc1 = new ByteChunk();
ByteChunk bc2 = new ByteChunk();

bc1.setBytes(b1, 0, b1.length);
bc2.setBytes(b2, 0, b2.length);

String s1 = bc1.toString();
String s2 = bc2.toString();

System.out.println(s1 =  + s1);
System.out.println(s2 =  + s2);

bc1.append(bc2);
s1 = bc1.toString();
System.out.println(s1 =  + s1);
}

i believe the solution here would be to have append(ByteChunk) look like
this:

public void append( ByteChunk src )
throws IOException
{
append( src.getBytes(), src.getStart(), src.getLength());
}


 The better solution is to get rid of getOffset..and only use getStart or
 getEnd where needed...

  just a sanity check...
 
 
 Well done, OSS is great because of this comments..and the possibility to
 make them just-in-time..:)))
 
  -kevin.
 
 Saludos ,
 Ignacio J. Ortega



RE: cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/util/buf ByteChunk.java

2001-06-03 Thread Ignacio J. Ortega

 I reviewed it, and your are right for equals..but not for 
 append..append
 is suppoused to use the end of the buffer not the start..so in append
 getOffset is suppoused to return end not the start...
 

This is not true...append needs getStart too...finally i will make this
changes:

1) use bb.getEnd in ob.getOffset as it seems this is the intention
explained in the comment , to track the next free byte ( or the last
writed byte as is used )

2) use getStart instead of getOffset inside bb to make things a bit
clearer..

I think this is the correct change..it works and pass tests ..

( you take me be storm just writing this message when received yours :))
thanks

Saludos ,
Ignacio J. Ortega




cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/util/buf ByteChunk.java

2001-06-03 Thread nacho

nacho   01/06/03 13:16:46

  Modified:src/share/org/apache/tomcat/core OutputBuffer.java
   src/share/org/apache/tomcat/util/buf ByteChunk.java
  Log:
  * Fix for ob.getByteOff hack...and reverting previous fix..
  * Use getStart where needed on bb intead of getOffset, a bit clearer.
  
  Submitted by: Kevin Seguin
  
  Revision  ChangesPath
  1.18  +1 -1  
jakarta-tomcat/src/share/org/apache/tomcat/core/OutputBuffer.java
  
  Index: OutputBuffer.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/OutputBuffer.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- OutputBuffer.java 2001/05/26 17:46:46 1.17
  +++ OutputBuffer.java 2001/06/03 20:16:46 1.18
  @@ -148,7 +148,7 @@
*  @deprecated Used only in Ajp13Packet for a hack
*/
   public int getByteOff() {
  - return bb.getOffset();
  + return bb.getEnd();
   }
   
   /** Set the write position in the byte buffer
  
  
  
  1.6   +4 -4  
jakarta-tomcat/src/share/org/apache/tomcat/util/buf/ByteChunk.java
  
  Index: ByteChunk.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/buf/ByteChunk.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ByteChunk.java2001/06/02 21:53:46 1.5
  +++ ByteChunk.java2001/06/03 20:16:46 1.6
  @@ -210,7 +210,7 @@
   }
   
   public int getOffset() {
  - return getEnd();
  + return getStart();
   }
   
   public void setOffset(int off) {
  @@ -280,7 +280,7 @@
   public void append( ByteChunk src )
throws IOException
   {
  - append( src.getBytes(), src.getOffset(), src.getLength());
  + append( src.getBytes(), src.getStart(), src.getLength());
   }
   
   /** Add data to the buffer
  @@ -479,7 +479,7 @@
   }
   
   public boolean equals( ByteChunk bb ) {
  - return equals( bb.getBytes(), bb.getOffset(), bb.getLength());
  + return equals( bb.getBytes(), bb.getStart(), bb.getLength());
   }
   
   public boolean equals( byte b2[], int off2, int len2) {
  @@ -501,7 +501,7 @@
   }
   
   public boolean equals( CharChunk cc ) {
  - return equals( cc.getChars(), cc.getOffset(), cc.getLength());
  + return equals( cc.getChars(), cc.getStart(), cc.getLength());
   }
   
   public boolean equals( char c2[], int off2, int len2) {
  
  
  



cvs commit: jakarta-tomcat-connectors/util/src/java/org/apache/tomcat/util/buf ByteChunk.java

2001-06-03 Thread seguin

seguin  01/06/03 13:34:25

  Modified:util/src/java/org/apache/tomcat/util/buf ByteChunk.java
  Log:
  propagate changes made by Ignacio J. Ortega in tomcat 3.
  
  Revision  ChangesPath
  1.3   +13 -12
jakarta-tomcat-connectors/util/src/java/org/apache/tomcat/util/buf/ByteChunk.java
  
  Index: ByteChunk.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/util/src/java/org/apache/tomcat/util/buf/ByteChunk.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ByteChunk.java2001/05/29 06:22:53 1.2
  +++ ByteChunk.java2001/06/03 20:34:25 1.3
  @@ -208,12 +208,13 @@
   public int getStart() {
return start;
   }
  -
  +
   public int getOffset() {
return getStart();
   }
   
   public void setOffset(int off) {
  +if (end  off ) end=off;
start=off;
   }
   
  @@ -263,7 +264,7 @@
   {
append( (byte)c);
   }
  -
  +
   public void append( byte b )
throws IOException
   {
  @@ -275,13 +276,13 @@
}
buff[end++]=b;
   }
  -
  +
   public void append( ByteChunk src )
throws IOException
   {
  - append( src.getBytes(), src.getOffset(), src.getLength());
  + append( src.getBytes(), src.getStart(), src.getLength());
   }
  -
  +
   /** Add data to the buffer
*/
   public void append( byte src[], int off, int len )
  @@ -297,7 +298,7 @@
end+=len;
return;
}
  - 
  +
// if we have limit and we're below
if( len = limit - end ) {
// makeSpace will grow the buffer to the limit,
  @@ -311,7 +312,7 @@
// buffer
   
// the buffer is already at ( or bigger than ) limit
  - 
  +
// Optimization:
// If len-avail  length ( i.e. after we fill the buffer with
// what we can, the remaining will fit in the buffer ) we'll just
  @@ -327,12 +328,12 @@
int avail=limit-end;
System.arraycopy(src, off, buff, end, avail);
end += avail;
  - 
  +
flushBuffer();
  - 
  +
System.arraycopy(src, off+avail, buff, end, len - avail);
end+= len - avail;
  - 
  +
} else {// len  buf.length + avail
// long write - flush the buffer and write the rest
// directly from source
  @@ -478,7 +479,7 @@
   }
   
   public boolean equals( ByteChunk bb ) {
  - return equals( bb.getBytes(), bb.getOffset(), bb.getLength());
  + return equals( bb.getBytes(), bb.getStart(), bb.getLength());
   }
   
   public boolean equals( byte b2[], int off2, int len2) {
  @@ -500,7 +501,7 @@
   }
   
   public boolean equals( CharChunk cc ) {
  - return equals( cc.getChars(), cc.getOffset(), cc.getLength());
  + return equals( cc.getChars(), cc.getStart(), cc.getLength());
   }
   
   public boolean equals( char c2[], int off2, int len2) {
  
  
  



cvs commit: jakarta-tomcat-connectors/jk/src/java/org/apache/ajp/test TestAjp13.java

2001-06-03 Thread seguin

seguin  01/06/03 14:08:14

  Modified:jk/src/java/org/apache/ajp/test TestAjp13.java
  Log:
  small update...
  
  Revision  ChangesPath
  1.4   +20 -23
jakarta-tomcat-connectors/jk/src/java/org/apache/ajp/test/TestAjp13.java
  
  Index: TestAjp13.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/jk/src/java/org/apache/ajp/test/TestAjp13.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- TestAjp13.java2001/05/29 23:05:57 1.3
  +++ TestAjp13.java2001/06/03 21:08:14 1.4
  @@ -22,24 +22,22 @@
   return new TestSuite(TestAjp13.class);
   }
   
  -protected void my_setUp() {
  +protected void setUp() {
   println(setup...);
   
   server = new Ajp13Server();
   server.start();
   }
   
  -protected void my_tearDown() {
  +protected void tearDown() {
   println(tear down...);
   
   server.shutdown();
   }
   
   public void test1() throws Exception {
  -System.out.println(running test1);
  +println(running test1);
   
  -my_setUp();
  -
   Socket s = new Socket(localhost, 8009);
   
   Ajp13Packet p = new Ajp13Packet(Ajp13.MAX_PACKET_SIZE);
  @@ -73,7 +71,7 @@
   
   InputStream is = s.getInputStream();
   
  -System.out.println(decoding response...);
  +println(decoding response...);
   
   boolean done = false;
   while (!done) {
  @@ -86,7 +84,7 @@
   b2 = is.read();
   assertTrue(byte 2 was  + (char)b2, b2 == (int)'B');
   
  -System.out.println(b1 =  + (char)b1 + ; b2 =  + (char)b2);
  +println(b1 =  + (char)b1 + ; b2 =  + (char)b2);
   
   // next is length
   b1 = is.read();
  @@ -96,7 +94,7 @@
   
   int l = (b1  8) + b2;
   
  -System.out.println(length =  + l);
  +println(length =  + l);
   
   // now get data
   byte[] buf = new byte[l];
  @@ -108,7 +106,7 @@
   off += n;
   }
   
  -System.out.println(read  + total);
  +println(read  + total);
   
   assertTrue(total read was  + total +
  , should have been  + l,
  @@ -120,17 +118,17 @@
   
   switch (code) {
   case 3:
  -System.out.println(AJP13_SEND_BODY_CHUNK );
  +println(AJP13_SEND_BODY_CHUNK );
   break;
   case 4:
  -System.out.println(AJP13_SEND_HEADERS );
  +println(AJP13_SEND_HEADERS );
   break;
   case 5:
  -System.out.println(AJP13_END_RESPONSE );
  +println(AJP13_END_RESPONSE );
   done = true;
   break;
   case 6:
  -System.out.println(AJP13_GET_BODY_CHUNK );
  +println(AJP13_GET_BODY_CHUNK );
   break;
   default:
   assertTrue(invalid prefix code:   + code, false);
  @@ -138,13 +136,12 @@
   }
   }
   
  -System.out.println(shutting down socket...);
  +println(shutting down socket...);
   s.shutdownOutput();
   s.shutdownInput();
   s.close();
   
  -System.out.println(shutting down server...);
  -my_tearDown();
  +println(done test1...);
   }
   
   protected static void println(String msg) {
  @@ -173,7 +170,7 @@
   public void run() {
   try {
   ServerSocket server = new ServerSocket(8009);
  -System.out.println(Ajp13Server running...);
  +TestAjp13.println(Ajp13Server running...);
   Socket socket = server.accept();
   Ajp13 ajp13 = new Ajp13();
   MimeHeaders headers = new MimeHeaders();
  @@ -188,10 +185,10 @@
   status = ajp13.receiveNextRequest(request);
   } catch (IOException e) {
   if (shutdown) {
  -System.out.println(Ajp13Server told to shutdown);
  +TestAjp13.println(Ajp13Server told to shutdown);
   break;
   }
  -System.out.println(process: ajp13.receiveNextRequest -  + e);
  +TestAjp13.println(process: ajp13.receiveNextRequest -  + e);
   }
   
   if( status==-2) {
  @@ -208,7 +205,7 @@
   if( status != 200 )
   break;
   
  -System.out.println(request);
  +TestAjp13.println(request.toString());
   
   String message =
   htmlbodypre +
  @@ -234,17 +231,17 @@
 

cvs commit: jakarta-tomcat-connectors/jk/src/java/org/apache/ajp/test TestAjp13.java

2001-06-03 Thread seguin

seguin  01/06/03 14:13:44

  Modified:jk/src/java/org/apache/ajp/test TestAjp13.java
  Log:
  remove commented out code.
  
  Revision  ChangesPath
  1.5   +1 -6  
jakarta-tomcat-connectors/jk/src/java/org/apache/ajp/test/TestAjp13.java
  
  Index: TestAjp13.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/jk/src/java/org/apache/ajp/test/TestAjp13.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- TestAjp13.java2001/06/03 21:08:14 1.4
  +++ TestAjp13.java2001/06/03 21:13:44 1.5
  @@ -159,12 +159,7 @@
   
   void shutdown() {
   this.shutdown = true;
  -
  -//  try {
  -this.interrupt();
  -//  } catch (InterruptedException e) {
  -//  throw new RuntimeException(e.toString());
  -//  }
  +this.interrupt();
   }
   
   public void run() {
  
  
  



[ANNOUNCE] Domino redirector 1.0.1

2001-06-03 Thread Andy Armstrong

Version 1.0.1 of the Lotus Domino redirector is available now at

  http://free.tagish.net/domino-tomcat/

The main change is that Linux is a supported platform in addition to
Win32. It should be quite simple to build it for other Unices now, and
I'd be most grateful to hear of the experiences of anyone who is in a
position to do this.

-- 
Andy Armstrong, Tagish



[PATCH] [tc4] invisible docs

2001-06-03 Thread jeff

Hi,

The docs have:

body bgcolor=light blue link=black

Mozilla doesn't understand light blue, and renders the background
black, which is unfortunately the same colour as the links. The attached
patch fixes this.

thanks,

--Jeff


Index: catalina/docs/config/categories.html
===
RCS file: /home/cvspublic/jakarta-tomcat-4.0/catalina/docs/config/categories.html,v
retrieving revision 1.3
diff -u -r1.3 categories.html
--- catalina/docs/config/categories.html2001/02/26 03:48:44 1.3
+++ catalina/docs/config/categories.html2001/06/02 01:52:06
@@ -2,7 +2,7 @@
 head
 titleCatalina Configuration Categories/title
 /head
-body bgcolor=sky blue link=black vlink=black
+body bgcolor=#008ED5 link=black vlink=black
 font size=2
 
 h3Home/h3