Hi,

I'm investigating what appears to be a possible regression after upgrading 
Tomcat from 9.0.118 (working) to 9.0.119.

Environment:

  *   Apache Tomcat 9.0.119
  *   Java 21
  *   Running inside Apache Karaf

After the upgrade, one of our release pipeline tests consistently fails while 
reading the body of an HTTP POST request.

The exception is:
java.lang.IllegalArgumentException: newPosition > limit: (8175 > 9)
    at java.base/java.nio.Buffer.createPositionException(Buffer.java:352)
    at java.base/java.nio.Buffer.position(Buffer.java:327)
    at java.base/java.nio.ByteBuffer.position(ByteBuffer.java:1551)
    at org.apache.tomcat.util.buf.B2CConverter.convert(B2CConverter.java:300)
    at 
org.apache.catalina.connector.InputBuffer.realReadChars(InputBuffer.java:485)
    at 
org.apache.catalina.connector.InputBuffer.checkCharBufferEof(InputBuffer.java:691)
    at org.apache.catalina.connector.InputBuffer.read(InputBuffer.java:517)
    at org.apache.catalina.connector.CoyoteReader.read(CoyoteReader.java:108)
    ...

The application code is simply:

private String loadXMLContent(HttpServletRequest request) throws IOException {
    StringBuffer crBuff = new StringBuffer();

    try (Reader reader = request.getReader()) {
        char[] chBuff = new char[500];
        int charsNumber;

        while ((charsNumber = reader.read(chBuff)) != -1) {
            crBuff.append(chBuff, 0, charsNumber);
        }
    }

    return crBuff.toString();
}

The exception is thrown from reader.read(...);  there is no custom buffering or 
manipulation of the request stream.

The request body is XML and is normally processed without problems on the 
previous Tomcat version.

I'd like to ask:

  1.  Has anyone seen a similar IllegalArgumentException originating from 
B2CConverter / InputBuffer after upgrading to 9.0.119?
  2.  Are there any known changes in the request body decoding path that could 
explain this behavior?
  3.  Is there any additional logging or diagnostics you would recommend to 
determine whether this is a Tomcat issue or an application/environment issue?

Best Regards,
Yavor Stankov








SEEBURGER AG            Vorstand/SEEBURGER Executive Board:
Sitz der Gesellschaft/Registered Office:                Axel Haas, Michael 
Kleeberg, Dr. Martin Kuntz
Edisonstr. 1
D-75015 Bretten         Vorsitzende des Aufsichtsrats/Chairperson of the 
SEEBURGER Supervisory Board:
Tel.: 07252 / 96 - 0            Prof. Dr. Simone Zeuchner-Egli
Fax: 07252 / 96 - 2222
Internet: http://www.seeburger.de               Registergericht/Commercial 
Register:
e-mail: [email protected]               HRB 240708 Mannheim

Hinweis: Diese Nachricht ist vertraulich und nur f?r den Empf?nger bestimmt. 
Wenn Sie sie irrt?mlich erhalten haben, informieren Sie bitte den Absender und 
l?schen Sie die Nachricht. Keine Haftung f?r Sch?den durch Viren oder 
Manipulationen - bitte pr?fen Sie Anh?nge vor dem ?ffnen. Informationen zur 
Verarbeitung personenbezogener Daten:Datenschutzhinweise f?r 
Gesch?ftspartner<https://www.seeburger.com/fileadmin/noIndex/legal/SEEBURGER_Datenschutzhinweise_Geschaeftspartner_DE.pdf>

Notice: This message is confidential and intended only for the recipient. If 
received in error, please notify the sender and delete it. No liability for 
damages caused by viruses or manipulation - please scan attachments before 
opening. Information on personal data processing:Privacy Notice for Business 
Partners<https://www.seeburger.com/fileadmin/noIndex/legal/SEEBURGER_Privacy_Notice_Business_Partners_EN.pdf>

Reply via email to