Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 39694200CFE for ; Fri, 8 Sep 2017 14:23:51 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 37E421609C5; Fri, 8 Sep 2017 12:23:51 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 2E7D21609BF for ; Fri, 8 Sep 2017 14:23:50 +0200 (CEST) Received: (qmail 19004 invoked by uid 500); 8 Sep 2017 12:23:47 -0000 Mailing-List: contact dev-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Developers List" Delivered-To: mailing list dev@tomcat.apache.org Received: (qmail 18993 invoked by uid 99); 8 Sep 2017 12:23:47 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 08 Sep 2017 12:23:47 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 50FF4C78AD for ; Fri, 8 Sep 2017 12:23:47 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.179 X-Spam-Level: * X-Spam-Status: No, score=1.179 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, KAM_ASCII_DIVIDERS=0.8, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_SORBS_SPAM=0.5, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd1-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id M_ZhVLkgohMj for ; Fri, 8 Sep 2017 12:23:46 +0000 (UTC) Received: from mail-oi0-f41.google.com (mail-oi0-f41.google.com [209.85.218.41]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTPS id 7DF245F3D1 for ; Fri, 8 Sep 2017 12:23:45 +0000 (UTC) Received: by mail-oi0-f41.google.com with SMTP id l74so9522070oih.1 for ; Fri, 08 Sep 2017 05:23:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-transfer-encoding; bh=wIAg3VUFOnquSssyfx/Mx5+yWgNWTTmITFMYDe5sQbk=; b=noznry59NE2AkMe87s+8VaFIv2qpm1aoGZC4s79AeHu099LPXXtwbqNPjd1McMOvot ebDiHhnJrN3aEFSIXNQf4mEoIOgWCiC+XdEDZNN0JS1QSLk4wb7jIGvEjXuLZRe7vrO9 2VlIBkSJPebpAQ3VuVXjlwzh+BYq/PO/r57bIXKIXpfizFSJurezo6u5wn6XdVzJDj7I JYinskr6tO6VVizKkrhsKBFtAcyD36eOY53g0vkNdpMsh2WIXet4lZ01z16+lHBkKuz3 kf45h3nmtydkwwIxv1vEbOyuCF0JfFiRcnFs5jg15Ysg4E5dAk+EupqdUx2XN8zEXhJR nQ+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:content-transfer-encoding; bh=wIAg3VUFOnquSssyfx/Mx5+yWgNWTTmITFMYDe5sQbk=; b=fHdBg4afIympitybooG+AhJjrop8DtBAc66dTPtqno8qbzry9oj2g6HnserqOmRluQ UjmmaHJGrdfeutu19AUdEZqyKTfYpq/FN/V1Mc8TS8bgU3DXyS613vJWJYTfPOEnhzPL ueUQvDcYzih0fEenIS/O7WHi5GV3lXd0NsTAUJQR/Qn3XXPe6Si3SlMOktpVZiIc9+Lh 1EYNXKsITouJY+BXhyMjiAq+lJveoD1KC8gWjbkD/OowbFP185Lm7mRUUMen4GKEonDn qDvrBJC6SsqnBhxvmePRsAWH8EBILZVP6CA6XFeWXzRC2fnT+IqmGFBe4InrHEyu+5yu mPUw== X-Gm-Message-State: AHPjjUh6aN61k+Y4xMR9ioF2zVw1N1pv2ArEtKqATqIa9oSnAeg8UirA GzTElw9B3b8QQFZh2UuFHm5EVQMAo8lTMqg= X-Google-Smtp-Source: AOwi7QDLFNjow8/1M7p5WIpAuFwGBi6goKS6I8LdqblPKofjUEyJnYA2DJhtVzQQRqCysnVIxlRPyB8HAxPojSYhtb8= X-Received: by 10.202.73.65 with SMTP id w62mr2415356oia.169.1504873423771; Fri, 08 Sep 2017 05:23:43 -0700 (PDT) MIME-Version: 1.0 Received: by 10.74.137.75 with HTTP; Fri, 8 Sep 2017 05:23:43 -0700 (PDT) In-Reply-To: <20170908090648.2F81B3A0051@svn01-us-west.apache.org> References: <20170908090648.2F81B3A0051@svn01-us-west.apache.org> From: Konstantin Kolinko Date: Fri, 8 Sep 2017 15:23:43 +0300 Message-ID: Subject: Re: svn commit: r1807693 - in /tomcat/tc7.0.x/trunk: ./ java/org/apache/tomcat/websocket/PerMessageDeflate.java test/org/apache/tomcat/websocket/TestPerMessageDeflate.java webapps/docs/changelog.xml To: Tomcat Developers List Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable archived-at: Fri, 08 Sep 2017 12:23:51 -0000 2017-09-08 12:06 GMT+03:00 : > Author: markt > Date: Fri Sep 8 09:06:47 2017 > New Revision: 1807693 > > URL: http://svn.apache.org/viewvc?rev=3D1807693&view=3Drev > Log: > Fix https://bz.apache.org/bugzilla/show_bug.cgi?id=3D61491 > When using the permessage-deflate extension, correctly handle the sending= of empty messages after non-empty messages to avoid the IllegalArgumentExc= eption > > Added: > tomcat/tc7.0.x/trunk/test/org/apache/tomcat/websocket/TestPerMessageD= eflate.java > - copied, changed from r1807689, tomcat/tc8.5.x/trunk/test/org/apac= he/tomcat/websocket/TestPerMessageDeflate.java > Modified: > tomcat/tc7.0.x/trunk/ (props changed) > tomcat/tc7.0.x/trunk/java/org/apache/tomcat/websocket/PerMessageDefla= te.java > tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml 1. There are local variables for uncompressedPart.getPayload() and uncompressedPart.isFin() several lines below in this method. They can be moved up and used here. Though it does not matter much as those methods in MessagePart class are simple getters. > ByteBuffer uncompressedPayload =3D uncompressedPart.getPayload(); > boolean fin =3D uncompressedPart.isFin(); 2. If sendMessagePart() is called with an empty part and this is not the last part, does the call have to be delivered to client, like some king of flush or ping? Or it can be ignored? If it is not ignored, and compression of (empty part) is not empty (I may be wrong, but I expect it to contains some code to initialize compression table, as gz archive of an empty file is not empty), then I wonder whether the following works: sending two empty parts: {empty part, empty part & fin=3Dtrue} From the code I think that the output will be {compressed part}, followed by {passed-through empty "fin" part}? I think it will not be received correctly. 3. Javadoc for Deflater shows that end of input is signaled by calling finish();. I do not see such call here. https://docs.oracle.com/javase/8/docs/api/java/util/zip/Deflater.html Best regards, Konstantin Kolinko > Modified: tomcat/tc7.0.x/trunk/java/org/apache/tomcat/websocket/PerMessag= eDeflate.java > URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/to= mcat/websocket/PerMessageDeflate.java?rev=3D1807693&r1=3D1807692&r2=3D18076= 93&view=3Ddiff > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- tomcat/tc7.0.x/trunk/java/org/apache/tomcat/websocket/PerMessageDefla= te.java (original) > +++ tomcat/tc7.0.x/trunk/java/org/apache/tomcat/websocket/PerMessageDefla= te.java Fri Sep 8 09:06:47 2017 > @@ -315,16 +315,20 @@ public class PerMessageDeflate implement > public List sendMessagePart(List uncompres= sedParts) { > List allCompressedParts =3D new ArrayList(); > > + // Flag to track if a message is completely empty > + boolean emptyMessage =3D true; > + > for (MessagePart uncompressedPart : uncompressedParts) { > byte opCode =3D uncompressedPart.getOpCode(); > + boolean emptyPart =3D uncompressedPart.getPayload().limit() = =3D=3D 0; > + emptyMessage =3D emptyMessage && emptyPart; > if (Util.isControl(opCode)) { > // Control messages can appear in the middle of other me= ssages > // and must not be compressed. Pass it straight through > allCompressedParts.add(uncompressedPart); > - } else if (uncompressedPart.getPayload().limit() =3D=3D 0 &&= uncompressedPart.isFin() && > - deflater.getBytesRead() =3D=3D 0) { > - // Zero length messages can't be compressed so pass them > - // straight through. > + } else if (emptyMessage && uncompressedPart.isFin()) { > + // Zero length messages can't be compressed so pass the > + // final (empty) part straight through. > allCompressedParts.add(uncompressedPart); > } else { > List compressedParts =3D new ArrayList(); > > Copied: tomcat/tc7.0.x/trunk/test/org/apache/tomcat/websocket/TestPerMess= ageDeflate.java (from r1807689, tomcat/tc8.5.x/trunk/test/org/apache/tomcat= /websocket/TestPerMessageDeflate.java) > URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/to= mcat/websocket/TestPerMessageDeflate.java?p2=3Dtomcat/tc7.0.x/trunk/test/or= g/apache/tomcat/websocket/TestPerMessageDeflate.java&p1=3Dtomcat/tc8.5.x/tr= unk/test/org/apache/tomcat/websocket/TestPerMessageDeflate.java&r1=3D180768= 9&r2=3D1807693&rev=3D1807693&view=3Ddiff > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- tomcat/tc8.5.x/trunk/test/org/apache/tomcat/websocket/TestPerMessageD= eflate.java (original) > +++ tomcat/tc7.0.x/trunk/test/org/apache/tomcat/websocket/TestPerMessageD= eflate.java Fri Sep 8 09:06:47 2017 > @@ -18,7 +18,6 @@ package org.apache.tomcat.websocket; > > import java.io.IOException; > import java.nio.ByteBuffer; > -import java.nio.charset.StandardCharsets; > import java.util.ArrayList; > import java.util.Collections; > import java.util.List; > @@ -38,23 +37,23 @@ public class TestPerMessageDeflate { > > // Set up the extension using defaults > List parameters =3D Collections.emptyList(); > - List> preferences =3D new ArrayList<>(); > + List> preferences =3D new ArrayList>(); > preferences.add(parameters); > > PerMessageDeflate perMessageDeflate =3D PerMessageDeflate.negoti= ate(preferences, true); > perMessageDeflate.setNext(new TesterTransformation()); > > ByteBuffer bb1 =3D ByteBuffer.wrap("A".getBytes(StandardCharsets= .UTF_8)); > - MessagePart mp1 =3D new MessagePart(true, 0, Constants.OPCODE_TE= XT, bb1, null, null, -1); > + MessagePart mp1 =3D new MessagePart(true, 0, Constants.OPCODE_TE= XT, bb1, null, null); > > - List uncompressedParts1 =3D new ArrayList<>(); > + List uncompressedParts1 =3D new ArrayList(); > uncompressedParts1.add(mp1); > perMessageDeflate.sendMessagePart(uncompressedParts1); > > ByteBuffer bb2 =3D ByteBuffer.wrap("".getBytes(StandardCharsets.= UTF_8)); > - MessagePart mp2 =3D new MessagePart(true, 0, Constants.OPCODE_TE= XT, bb2, null, null, -1); > + MessagePart mp2 =3D new MessagePart(true, 0, Constants.OPCODE_TE= XT, bb2, null, null); > > - List uncompressedParts2 =3D new ArrayList<>(); > + List uncompressedParts2 =3D new ArrayList(); > uncompressedParts2.add(mp2); > perMessageDeflate.sendMessagePart(uncompressedParts2); > } > > Modified: tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml > URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/docs/chang= elog.xml?rev=3D1807693&r1=3D1807692&r2=3D1807693&view=3Ddiff > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml (original) > +++ tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Fri Sep 8 09:06:47 2= 017 > @@ -100,6 +100,16 @@ > > > > + > + > + > + 61491: When using the permessage-deflate > + extension, correctly handle the sending of empty messages after > + non-empty messages to avoid the IllegalArgumentException. > + (markt) > + > + > + > > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org > For additional commands, e-mail: dev-help@tomcat.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org For additional commands, e-mail: dev-help@tomcat.apache.org