[Bug 66442] New: Data frame included in response for 204 No Content status

2023-01-25 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=66442

Bug ID: 66442
   Summary: Data frame included in response for 204 No Content
status
   Product: Tomcat 9
   Version: 9.0.71
  Hardware: PC
OS: Mac OS X 10.1
Status: NEW
  Severity: normal
  Priority: P2
 Component: Connectors
  Assignee: dev@tomcat.apache.org
  Reporter: violet...@apache.org
  Target Milestone: -

Hi,

While investigating issue https://github.com/reactor/reactor-netty/issues/2664
where the server is Tomcat and the client is Reactor Netty, I'm observing that
Tomcat sends (the logs below are from the client side):

HEADERS: streamId=3 headers=DefaultHttp2Headers[:status: 204, date: Wed, 25 Jan
2023 07:46:07 GMT] padding=0 endStream=false

DATA: streamId=3 padding=0 endStream=true length=0 bytes=

I expect that for responses 204/304 Tomcat will send only HEADERS with
endStream=true as these kind of response are defined as "no content".

A reproducible example can be found in the linked issue above.

Regards,
Violeta

-- 
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



[Bug 66442] Data frame included in response for 204 No Content status

2023-01-25 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=66442

--- Comment #1 from Mark Thomas  ---
I can see what the problem is and I think I have a fix for this. Just need to
work on some additional unit tests and confirm the fix works as intended.

-- 
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



[GitHub] [tomcat-jakartaee-migration] ifurnadjiev commented on issue #39: Fix (remove) "javax.servlet.*" package version when processing the MANIFEST.MF

2023-01-25 Thread via GitHub


ifurnadjiev commented on issue #39:
URL: 
https://github.com/apache/tomcat-jakartaee-migration/issues/39#issuecomment-1403436225

   Any comment on the issue? Do you have plans to address it?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



Re: JDK 20 Rampdown Phase 2 & JMX Heads-up

2023-01-25 Thread Mark Thomas

On 25/01/2023 05:21, David Delabassee wrote:



## Heads-up - JDK 21: JMX Subject Delegation & Fine-grained Security 
Deprecation


JMX has some features that rely on Security Manager APIs which are 
deprecated for removal (see JEP 411 [4]). These features are "Subject 
Delegation" and "Fine-grained Security", which both seem to be generally 
unused, and would require significant investment to implement without 
touching the deprecated APIs. As a consequence, "Subject Delegation" is 
being proposed for deprecation in JDK 21 [5].


Fine-grained Security is also being considered for deprecation at the 
same time. This feature [6] has allowed configuration of a security 
policy to restrict or permit access to specific MBean actions. It is 
expected that this feature is generally unused, possibly because there 
is simply no demand for such detailed control, and that it is too 
complex to create and maintain the policies.




I never even knew that this was possible. And I thought I had read the 
JMX docs reasonably thoroughly.


I have always viewed the lack of fine-grained security to be a 
significant weakness in the JMX security model. I wish I had known about 
this years ago.


There is a demand for fine-grained security with JMX. We have had users 
express a desire to expose some parts of some JMX MBeans to a sub-set of 
users.


I'm fine with the removal of the SecurityManager. Even if they had been 
aware of the option, requiring the use of a SecurityManager to enable 
fine-grained security with JMX may have prevented many users for 
adopting the approach.


If there is any way the fine-grained security can be retained, I think 
that would be useful. Maybe some sort of authorization SPI where users 
can provide the answer to "Can this user with these roles call this method?"


Mark

-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



[GitHub] [tomcat-jakartaee-migration] markt-asf commented on issue #39: Fix (remove) "javax.servlet.*" package version when processing the MANIFEST.MF

2023-01-25 Thread via GitHub


markt-asf commented on issue #39:
URL: 
https://github.com/apache/tomcat-jakartaee-migration/issues/39#issuecomment-1403469350

   I'm a little uncomfortable with the idea of ignoring an explicit version 
range but if the user opts to use the migration tool that is an implicit choice 
to ignore the version range if it does not include Jakarta EE.
   
   I'd prefer a solution that doesn't require parsing and understanding the 
existing version range but simply replaces it with something that will work on 
Jakarta EE.
   
   I'm not aware of any plans to address this in the immediate future. 
Providing a PR is likely to improve the chances of this being fixed sooner 
rather than later.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



Re: JDK 20 Rampdown Phase 2 & JMX Heads-up

2023-01-25 Thread Rémy Maucherat
On Wed, Jan 25, 2023 at 12:04 PM Mark Thomas  wrote:
>
> On 25/01/2023 05:21, David Delabassee wrote:
>
> 
>
> > ## Heads-up - JDK 21: JMX Subject Delegation & Fine-grained Security
> > Deprecation
> >
> > JMX has some features that rely on Security Manager APIs which are
> > deprecated for removal (see JEP 411 [4]). These features are "Subject
> > Delegation" and "Fine-grained Security", which both seem to be generally
> > unused, and would require significant investment to implement without
> > touching the deprecated APIs. As a consequence, "Subject Delegation" is
> > being proposed for deprecation in JDK 21 [5].
> >
> > Fine-grained Security is also being considered for deprecation at the
> > same time. This feature [6] has allowed configuration of a security
> > policy to restrict or permit access to specific MBean actions. It is
> > expected that this feature is generally unused, possibly because there
> > is simply no demand for such detailed control, and that it is too
> > complex to create and maintain the policies.
>
> 
>
> I never even knew that this was possible. And I thought I had read the
> JMX docs reasonably thoroughly.
>
> I have always viewed the lack of fine-grained security to be a
> significant weakness in the JMX security model. I wish I had known about
> this years ago.
>
> There is a demand for fine-grained security with JMX. We have had users
> express a desire to expose some parts of some JMX MBeans to a sub-set of
> users.
>
> I'm fine with the removal of the SecurityManager. Even if they had been
> aware of the option, requiring the use of a SecurityManager to enable
> fine-grained security with JMX may have prevented many users for
> adopting the approach.
>
> If there is any way the fine-grained security can be retained, I think
> that would be useful. Maybe some sort of authorization SPI where users
> can provide the answer to "Can this user with these roles call this method?"

I didn't know about the feature either. Maybe it wasn't there when we
initially implemented JMX ? I have no idea. And I don't know how to
use it right now obviously ;)
Using fine grained security would be a good idea if it is possible.
Probably something very simple though: stats only and the rest.

Rémy

> Mark
>
> -
> To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: dev-h...@tomcat.apache.org
>

-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



[Bug 66441] Static field import failed on Expression Language lookup

2023-01-25 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=66441

Mark Thomas  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |INVALID

--- Comment #2 from Mark Thomas  ---
This looks like a Jakarta EL API bug to me. I think it needs to handle the
static field. It also looks like the EvaluationListener#propertyResolved()
events aren't being triggered.

-- 
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



[tomcat] 01/05: Format each enum on a new line

2023-01-25 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit ee6ee5e9f29ea118b6d58c1936b48dfd90a51a49
Author: Mark Thomas 
AuthorDate: Wed Jan 25 15:30:17 2023 +

Format each enum on a new line
---
 res/ide-support/eclipse/formatting-asf-tomcat.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/res/ide-support/eclipse/formatting-asf-tomcat.xml 
b/res/ide-support/eclipse/formatting-asf-tomcat.xml
index 71f085b69d..7a4effe304 100644
--- a/res/ide-support/eclipse/formatting-asf-tomcat.xml
+++ b/res/ide-support/eclipse/formatting-asf-tomcat.xml
@@ -236,7 +236,7 @@
 
 
 
-
+
 
 
 


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



[tomcat] 02/05: Disable formatting for clarity

2023-01-25 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 09d70e9c802cf58e38972d5be56c443a939c984c
Author: Mark Thomas 
AuthorDate: Wed Jan 25 15:35:39 2023 +

Disable formatting for clarity
---
 java/org/apache/coyote/http2/FrameType.java  | 3 ++-
 java/org/apache/coyote/http2/Http2Error.java | 3 ++-
 java/org/apache/coyote/http2/StreamStateMachine.java | 2 ++
 3 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/coyote/http2/FrameType.java 
b/java/org/apache/coyote/http2/FrameType.java
index acd60eaa2c..64d1fd05f0 100644
--- a/java/org/apache/coyote/http2/FrameType.java
+++ b/java/org/apache/coyote/http2/FrameType.java
@@ -21,7 +21,7 @@ import java.util.function.IntPredicate;
 import org.apache.tomcat.util.res.StringManager;
 
 enum FrameType {
-
+// @formatter:off
 DATA(  0, false,  true, null,  false),
 HEADERS (  1, false,  true, null,   true),
 PRIORITY(  2, false,  true, (x) -> x == 5, false),
@@ -34,6 +34,7 @@ enum FrameType {
 CONTINUATION(  9, false,  true, null,   true),
 PRIORITY_UPDATE ( 16,  true, false, (x) -> x >= 4,  true),
 UNKNOWN (256,  true,  true, null,  false);
+// @formatter:on
 
 private static final StringManager sm = 
StringManager.getManager(FrameType.class);
 
diff --git a/java/org/apache/coyote/http2/Http2Error.java 
b/java/org/apache/coyote/http2/Http2Error.java
index b826b57812..4a47f22e79 100644
--- a/java/org/apache/coyote/http2/Http2Error.java
+++ b/java/org/apache/coyote/http2/Http2Error.java
@@ -17,7 +17,7 @@
 package org.apache.coyote.http2;
 
 enum Http2Error {
-
+// @formatter:off
 NO_ERROR(0x00),
 PROTOCOL_ERROR  (0x01),
 INTERNAL_ERROR  (0x02),
@@ -32,6 +32,7 @@ enum Http2Error {
 ENHANCE_YOUR_CALM   (0x0b),
 INADEQUATE_SECURITY (0x0c),
 HTTP_1_1_REQUIRED   (0x0d);
+// @formatter:on
 
 private final long code;
 
diff --git a/java/org/apache/coyote/http2/StreamStateMachine.java 
b/java/org/apache/coyote/http2/StreamStateMachine.java
index 6ec79ff81c..acc6687d36 100644
--- a/java/org/apache/coyote/http2/StreamStateMachine.java
+++ b/java/org/apache/coyote/http2/StreamStateMachine.java
@@ -169,6 +169,7 @@ class StreamStateMachine {
 }
 
 private enum State {
+// @formatter:off
 IDLE   (false, false, false, true,
 Http2Error.PROTOCOL_ERROR, FrameType.HEADERS,
FrameType.PRIORITY),
@@ -215,6 +216,7 @@ class StreamStateMachine {

FrameType.WINDOW_UPDATE),
 CLOSED_FINAL   (false, false, false, true,
 Http2Error.PROTOCOL_ERROR, FrameType.PRIORITY);
+// @formatter:on
 
 private final boolean canRead;
 private final boolean canWrite;


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



[tomcat] branch main updated (e329ceb5c7 -> 519403fb8a)

2023-01-25 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git


from e329ceb5c7 Switch to using LongAddr to track request/error count for 
servlets
 new ee6ee5e9f2 Format each enum on a new line
 new 09d70e9c80 Disable formatting for clarity
 new 1dfe7d3bf6 Add missing  tags
 new aaff739f63 Code clean-up (format). No functional change.
 new 519403fb8a Fix BZ 66442 - h2 responses without bodies should not use 
DATA frames

The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../apache/coyote/http2/AbstractNonZeroStream.java |  12 +-
 java/org/apache/coyote/http2/AbstractStream.java   |  20 +-
 java/org/apache/coyote/http2/ByteUtil.java |   9 +-
 .../coyote/http2/ConnectionSettingsBase.java   |  87 +++--
 .../coyote/http2/ConnectionSettingsLocal.java  |  19 +-
 .../coyote/http2/ConnectionSettingsRemote.java |   3 +-
 java/org/apache/coyote/http2/FrameType.java|  70 ++--
 java/org/apache/coyote/http2/HPackHuffman.java |  77 ++--
 java/org/apache/coyote/http2/HeaderSink.java   |   5 +-
 java/org/apache/coyote/http2/Hpack.java|  32 +-
 java/org/apache/coyote/http2/HpackDecoder.java |  98 +++--
 java/org/apache/coyote/http2/HpackEncoder.java | 123 +++---
 java/org/apache/coyote/http2/HpackException.java   |   4 +-
 java/org/apache/coyote/http2/Http2AsyncParser.java | 105 ++---
 .../coyote/http2/Http2AsyncUpgradeHandler.java | 153 
 java/org/apache/coyote/http2/Http2Error.java   |   3 +-
 .../org/apache/coyote/http2/Http2OutputBuffer.java |  10 +-
 java/org/apache/coyote/http2/Http2Parser.java  | 302 +++
 java/org/apache/coyote/http2/Http2Protocol.java|   7 +-
 .../apache/coyote/http2/Http2UpgradeHandler.java   | 405 ++--
 java/org/apache/coyote/http2/RecycledStream.java   |   9 +-
 java/org/apache/coyote/http2/Setting.java  |  52 +--
 java/org/apache/coyote/http2/Stream.java   | 426 ++---
 java/org/apache/coyote/http2/StreamProcessor.java  |  93 +++--
 .../apache/coyote/http2/StreamStateMachine.java|  33 +-
 .../coyote/http2/WindowAllocationManager.java  |  69 ++--
 res/ide-support/eclipse/formatting-asf-tomcat.xml  |   2 +-
 test/org/apache/coyote/http2/Http2TestBase.java|  12 +
 .../apache/coyote/http2/TestStreamProcessor.java   |  49 +++
 webapps/docs/changelog.xml |   5 +
 30 files changed, 1125 insertions(+), 1169 deletions(-)


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



[tomcat] 05/05: Fix BZ 66442 - h2 responses without bodies should not use DATA frames

2023-01-25 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 519403fb8aace2c64e1ee3999511719418dc6968
Author: Mark Thomas 
AuthorDate: Wed Jan 25 16:28:34 2023 +

Fix BZ 66442 - h2 responses without bodies should not use DATA frames

https://bz.apache.org/bugzilla/show_bug.cgi?id=66442
---
 java/org/apache/coyote/http2/Stream.java   |  9 +++-
 java/org/apache/coyote/http2/StreamProcessor.java  |  4 ++
 test/org/apache/coyote/http2/Http2TestBase.java| 12 ++
 .../apache/coyote/http2/TestStreamProcessor.java   | 49 ++
 webapps/docs/changelog.xml |  5 +++
 5 files changed, 77 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/coyote/http2/Stream.java 
b/java/org/apache/coyote/http2/Stream.java
index 349e2f5942..a0f997e13a 100644
--- a/java/org/apache/coyote/http2/Stream.java
+++ b/java/org/apache/coyote/http2/Stream.java
@@ -335,8 +335,7 @@ class Stream extends AbstractNonZeroStream implements 
HeaderEmitter {
 if (coyoteRequest.method().isNull()) {
 coyoteRequest.method().setString(value);
 if ("HEAD".equals(value)) {
-addOutputFilter(new VoidOutputFilter());
-streamOutputBuffer.closed = true;
+configureVoidOutputFilter();
 }
 } else {
 throw new HpackException(
@@ -448,6 +447,12 @@ class Stream extends AbstractNonZeroStream implements 
HeaderEmitter {
 }
 
 
+void configureVoidOutputFilter() {
+addOutputFilter(new VoidOutputFilter());
+// Prevent further writes by the application
+streamOutputBuffer.closed = true;
+}
+
 private void parseAuthority(String value, boolean host) throws 
HpackException {
 int i;
 try {
diff --git a/java/org/apache/coyote/http2/StreamProcessor.java 
b/java/org/apache/coyote/http2/StreamProcessor.java
index 635949fa34..7398ce0de5 100644
--- a/java/org/apache/coyote/http2/StreamProcessor.java
+++ b/java/org/apache/coyote/http2/StreamProcessor.java
@@ -205,6 +205,10 @@ class StreamProcessor extends AbstractProcessor {
 headers.addValue("content-length").setLong(contentLength);
 }
 } else {
+// Disable response body
+if (stream != null) {
+stream.configureVoidOutputFilter();
+}
 if (statusCode == 205) {
 // RFC 7231 requires the server to explicitly signal an empty
 // response in this case
diff --git a/test/org/apache/coyote/http2/Http2TestBase.java 
b/test/org/apache/coyote/http2/Http2TestBase.java
index 4dc566fb9a..a81a450f6b 100644
--- a/test/org/apache/coyote/http2/Http2TestBase.java
+++ b/test/org/apache/coyote/http2/Http2TestBase.java
@@ -1339,6 +1339,18 @@ public abstract class Http2TestBase extends 
TomcatBaseTest {
 }
 
 
+public static class NoContentServlet extends HttpServlet {
+
+private static final long serialVersionUID = 1L;
+
+@Override
+protected void doGet(HttpServletRequest req, HttpServletResponse resp)
+throws ServletException, IOException {
+resp.setStatus(HttpServletResponse.SC_NO_CONTENT);
+}
+}
+
+
 public static class SimpleServlet extends HttpServlet {
 
 private static final long serialVersionUID = 1L;
diff --git a/test/org/apache/coyote/http2/TestStreamProcessor.java 
b/test/org/apache/coyote/http2/TestStreamProcessor.java
index 8516d98f22..16fa106567 100644
--- a/test/org/apache/coyote/http2/TestStreamProcessor.java
+++ b/test/org/apache/coyote/http2/TestStreamProcessor.java
@@ -164,6 +164,55 @@ public class TestStreamProcessor extends Http2TestBase {
 }
 expected.append("3-Header-[date]-[Wed, 11 Nov 2015 19:18:42 GMT]\n");
 expected.append("3-HeadersEnd\n");
+expected.append("3-EndOfStream\n");
+
+Assert.assertEquals(expected.toString(), output.getTrace());
+}
+
+
+@Test
+public void testPrepareHeadersNoContent() throws Exception {
+enableHttp2();
+
+Tomcat tomcat = getTomcatInstance();
+
+File appDir = new File("test/webapp");
+Context ctxt = tomcat.addWebapp(null, "", appDir.getAbsolutePath());
+
+Tomcat.addServlet(ctxt, "simple", new SimpleServlet());
+ctxt.addServletMappingDecoded("/simple", "simple");
+Tomcat.addServlet(ctxt, "noContent", new NoContentServlet());
+ctxt.addServletMappingDecoded("/noContent", "noContent");
+
+
+tomcat.start();
+
+openClientConnection();
+doHttpUpgrade();
+sendClientPreface();
+validateHttp2InitialResponse();
+
+byte[] frameHeader = new byte[9];
+ByteBuffer headersPayload = ByteBuffer.allocate(128);
+
+   

[tomcat] 03/05: Add missing tags

2023-01-25 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 1dfe7d3bf6811f8219778f6b21ea137389aff1c8
Author: Mark Thomas 
AuthorDate: Wed Jan 25 15:40:32 2023 +

Add missing  tags
---
 java/org/apache/coyote/http2/WindowAllocationManager.java | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/java/org/apache/coyote/http2/WindowAllocationManager.java 
b/java/org/apache/coyote/http2/WindowAllocationManager.java
index 45ac2fdbfd..47d0d1ac1f 100644
--- a/java/org/apache/coyote/http2/WindowAllocationManager.java
+++ b/java/org/apache/coyote/http2/WindowAllocationManager.java
@@ -28,22 +28,22 @@ import org.apache.tomcat.util.res.StringManager;
  * allocation and only issues allocation notifications when the stream is known
  * to be waiting for the notification.
  *
- * It is possible for a stream to be waiting for a connection allocation when
+ * It is possible for a stream to be waiting for a connection allocation 
when
  * a stream allocation is made. Therefore this class tracks the type of
  * allocation that the stream is waiting for to ensure that notifications are
  * correctly triggered.
  *
- * With the implementation at the time of writing, it is not possible for a
+ * With the implementation at the time of writing, it is not possible for a
  * stream to receive an unexpected connection notification as these are only
  * issues to streams in the backlog and a stream must be waiting for a
  * connection allocation in order to be placed on the backlog. However, as a
  * precaution, this class protects against unexpected connection notifications.
  *
- * It is important for asynchronous processing not to notify unless a
+ * It is important for asynchronous processing not to notify unless a
  * notification is expected else a dispatch will be performed unnecessarily
  * which may lead to unexpected results.
  *
- * A previous implementation used separate locks for the stream and connection
+ * A previous implementation used separate locks for the stream and 
connection
  * notifications. However, correct handling of allocation waiting requires
  * holding the stream lock when making the decision to wait. Therefore both
  * allocations need to wait on the Stream.


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



[tomcat] branch 10.1.x updated (f747796f1e -> 063a326f79)

2023-01-25 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a change to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


from f747796f1e Add ALv2 headers
 new bc622a9e6e Format each enum on a new line
 new 033566f711 Disable formatting for clarity
 new d55413fb9b Add missing  tags
 new 364f0f7993 Code clean-up (format). No functional change.
 new 063a326f79 Fix BZ 66442 - h2 responses without bodies should not use 
DATA frames

The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../apache/coyote/http2/AbstractNonZeroStream.java |  44 +--
 java/org/apache/coyote/http2/AbstractStream.java   |  20 +-
 java/org/apache/coyote/http2/ByteUtil.java |   9 +-
 .../coyote/http2/ConnectionSettingsBase.java   |  75 ++--
 .../coyote/http2/ConnectionSettingsLocal.java  |  19 +-
 .../coyote/http2/ConnectionSettingsRemote.java |   3 +-
 java/org/apache/coyote/http2/FrameType.java|  66 ++--
 java/org/apache/coyote/http2/HPackHuffman.java |  77 ++--
 java/org/apache/coyote/http2/HeaderSink.java   |   5 +-
 java/org/apache/coyote/http2/Hpack.java|  32 +-
 java/org/apache/coyote/http2/HpackDecoder.java |  98 +++--
 java/org/apache/coyote/http2/HpackEncoder.java | 123 +++---
 java/org/apache/coyote/http2/HpackException.java   |   4 +-
 java/org/apache/coyote/http2/Http2AsyncParser.java |  99 ++---
 .../coyote/http2/Http2AsyncUpgradeHandler.java | 153 
 java/org/apache/coyote/http2/Http2Error.java   |   3 +-
 .../org/apache/coyote/http2/Http2OutputBuffer.java |  10 +-
 java/org/apache/coyote/http2/Http2Parser.java  | 308 +++
 java/org/apache/coyote/http2/Http2Protocol.java|   7 +-
 .../apache/coyote/http2/Http2UpgradeHandler.java   | 419 ++---
 java/org/apache/coyote/http2/RecycledStream.java   |   9 +-
 java/org/apache/coyote/http2/Setting.java  |  46 +--
 java/org/apache/coyote/http2/Stream.java   | 415 ++--
 java/org/apache/coyote/http2/StreamProcessor.java  |  93 +++--
 .../apache/coyote/http2/StreamStateMachine.java|  33 +-
 .../coyote/http2/WindowAllocationManager.java  |  69 ++--
 res/ide-support/eclipse/formatting-asf-tomcat.xml  |   2 +-
 test/org/apache/coyote/http2/Http2TestBase.java|  12 +
 .../apache/coyote/http2/TestStreamProcessor.java   |  49 +++
 webapps/docs/changelog.xml |   5 +
 30 files changed, 1124 insertions(+), 1183 deletions(-)


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



[tomcat] 01/05: Format each enum on a new line

2023-01-25 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit bc622a9e6ea66037eaf5dfdab0e363f2ee334362
Author: Mark Thomas 
AuthorDate: Wed Jan 25 15:30:17 2023 +

Format each enum on a new line
---
 res/ide-support/eclipse/formatting-asf-tomcat.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/res/ide-support/eclipse/formatting-asf-tomcat.xml 
b/res/ide-support/eclipse/formatting-asf-tomcat.xml
index 71f085b69d..7a4effe304 100644
--- a/res/ide-support/eclipse/formatting-asf-tomcat.xml
+++ b/res/ide-support/eclipse/formatting-asf-tomcat.xml
@@ -236,7 +236,7 @@
 
 
 
-
+
 
 
 


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



[tomcat] 03/05: Add missing tags

2023-01-25 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit d55413fb9bfc25518550b7be470bbc5c23ccad5c
Author: Mark Thomas 
AuthorDate: Wed Jan 25 15:40:32 2023 +

Add missing  tags
---
 java/org/apache/coyote/http2/WindowAllocationManager.java | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/java/org/apache/coyote/http2/WindowAllocationManager.java 
b/java/org/apache/coyote/http2/WindowAllocationManager.java
index 45ac2fdbfd..47d0d1ac1f 100644
--- a/java/org/apache/coyote/http2/WindowAllocationManager.java
+++ b/java/org/apache/coyote/http2/WindowAllocationManager.java
@@ -28,22 +28,22 @@ import org.apache.tomcat.util.res.StringManager;
  * allocation and only issues allocation notifications when the stream is known
  * to be waiting for the notification.
  *
- * It is possible for a stream to be waiting for a connection allocation when
+ * It is possible for a stream to be waiting for a connection allocation 
when
  * a stream allocation is made. Therefore this class tracks the type of
  * allocation that the stream is waiting for to ensure that notifications are
  * correctly triggered.
  *
- * With the implementation at the time of writing, it is not possible for a
+ * With the implementation at the time of writing, it is not possible for a
  * stream to receive an unexpected connection notification as these are only
  * issues to streams in the backlog and a stream must be waiting for a
  * connection allocation in order to be placed on the backlog. However, as a
  * precaution, this class protects against unexpected connection notifications.
  *
- * It is important for asynchronous processing not to notify unless a
+ * It is important for asynchronous processing not to notify unless a
  * notification is expected else a dispatch will be performed unnecessarily
  * which may lead to unexpected results.
  *
- * A previous implementation used separate locks for the stream and connection
+ * A previous implementation used separate locks for the stream and 
connection
  * notifications. However, correct handling of allocation waiting requires
  * holding the stream lock when making the decision to wait. Therefore both
  * allocations need to wait on the Stream.


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



[tomcat] 02/05: Disable formatting for clarity

2023-01-25 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 033566f711745ee4790ef6c630cba0a74f29db9a
Author: Mark Thomas 
AuthorDate: Wed Jan 25 15:35:39 2023 +

Disable formatting for clarity
---
 java/org/apache/coyote/http2/FrameType.java  | 3 ++-
 java/org/apache/coyote/http2/Http2Error.java | 3 ++-
 java/org/apache/coyote/http2/StreamStateMachine.java | 2 ++
 3 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/coyote/http2/FrameType.java 
b/java/org/apache/coyote/http2/FrameType.java
index 8734944595..425c0516fd 100644
--- a/java/org/apache/coyote/http2/FrameType.java
+++ b/java/org/apache/coyote/http2/FrameType.java
@@ -21,7 +21,7 @@ import java.util.function.IntPredicate;
 import org.apache.tomcat.util.res.StringManager;
 
 enum FrameType {
-
+// @formatter:off
 DATA  (0,   false,  true, null,  false),
 HEADERS   (1,   false,  true, null,   true),
 PRIORITY  (2,   false,  true, (x) -> x == 5, false),
@@ -33,6 +33,7 @@ enum FrameType {
 WINDOW_UPDATE (8,true,  true, (x) -> x == 4,  true),
 CONTINUATION  (9,   false,  true, null,   true),
 UNKNOWN   (256,  true,  true, null,  false);
+// @formatter:on
 
 private static final StringManager sm = 
StringManager.getManager(FrameType.class);
 
diff --git a/java/org/apache/coyote/http2/Http2Error.java 
b/java/org/apache/coyote/http2/Http2Error.java
index b826b57812..4a47f22e79 100644
--- a/java/org/apache/coyote/http2/Http2Error.java
+++ b/java/org/apache/coyote/http2/Http2Error.java
@@ -17,7 +17,7 @@
 package org.apache.coyote.http2;
 
 enum Http2Error {
-
+// @formatter:off
 NO_ERROR(0x00),
 PROTOCOL_ERROR  (0x01),
 INTERNAL_ERROR  (0x02),
@@ -32,6 +32,7 @@ enum Http2Error {
 ENHANCE_YOUR_CALM   (0x0b),
 INADEQUATE_SECURITY (0x0c),
 HTTP_1_1_REQUIRED   (0x0d);
+// @formatter:on
 
 private final long code;
 
diff --git a/java/org/apache/coyote/http2/StreamStateMachine.java 
b/java/org/apache/coyote/http2/StreamStateMachine.java
index 6ec79ff81c..acc6687d36 100644
--- a/java/org/apache/coyote/http2/StreamStateMachine.java
+++ b/java/org/apache/coyote/http2/StreamStateMachine.java
@@ -169,6 +169,7 @@ class StreamStateMachine {
 }
 
 private enum State {
+// @formatter:off
 IDLE   (false, false, false, true,
 Http2Error.PROTOCOL_ERROR, FrameType.HEADERS,
FrameType.PRIORITY),
@@ -215,6 +216,7 @@ class StreamStateMachine {

FrameType.WINDOW_UPDATE),
 CLOSED_FINAL   (false, false, false, true,
 Http2Error.PROTOCOL_ERROR, FrameType.PRIORITY);
+// @formatter:on
 
 private final boolean canRead;
 private final boolean canWrite;


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



[tomcat] 05/05: Fix BZ 66442 - h2 responses without bodies should not use DATA frames

2023-01-25 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 063a326f79908a58d2aed1fbe4629865075240ab
Author: Mark Thomas 
AuthorDate: Wed Jan 25 16:28:34 2023 +

Fix BZ 66442 - h2 responses without bodies should not use DATA frames

https://bz.apache.org/bugzilla/show_bug.cgi?id=66442
---
 java/org/apache/coyote/http2/Stream.java   |  9 +++-
 java/org/apache/coyote/http2/StreamProcessor.java  |  4 ++
 test/org/apache/coyote/http2/Http2TestBase.java| 12 ++
 .../apache/coyote/http2/TestStreamProcessor.java   | 49 ++
 webapps/docs/changelog.xml |  5 +++
 5 files changed, 77 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/coyote/http2/Stream.java 
b/java/org/apache/coyote/http2/Stream.java
index 26eaf1b7f4..36aebe44d4 100644
--- a/java/org/apache/coyote/http2/Stream.java
+++ b/java/org/apache/coyote/http2/Stream.java
@@ -334,8 +334,7 @@ class Stream extends AbstractNonZeroStream implements 
HeaderEmitter {
 if (coyoteRequest.method().isNull()) {
 coyoteRequest.method().setString(value);
 if ("HEAD".equals(value)) {
-addOutputFilter(new VoidOutputFilter());
-streamOutputBuffer.closed = true;
+configureVoidOutputFilter();
 }
 } else {
 throw new HpackException(
@@ -437,6 +436,12 @@ class Stream extends AbstractNonZeroStream implements 
HeaderEmitter {
 }
 
 
+void configureVoidOutputFilter() {
+addOutputFilter(new VoidOutputFilter());
+// Prevent further writes by the application
+streamOutputBuffer.closed = true;
+}
+
 private void parseAuthority(String value, boolean host) throws 
HpackException {
 int i;
 try {
diff --git a/java/org/apache/coyote/http2/StreamProcessor.java 
b/java/org/apache/coyote/http2/StreamProcessor.java
index fef400d4d8..1a991a05ab 100644
--- a/java/org/apache/coyote/http2/StreamProcessor.java
+++ b/java/org/apache/coyote/http2/StreamProcessor.java
@@ -205,6 +205,10 @@ class StreamProcessor extends AbstractProcessor {
 headers.addValue("content-length").setLong(contentLength);
 }
 } else {
+// Disable response body
+if (stream != null) {
+stream.configureVoidOutputFilter();
+}
 if (statusCode == 205) {
 // RFC 7231 requires the server to explicitly signal an empty
 // response in this case
diff --git a/test/org/apache/coyote/http2/Http2TestBase.java 
b/test/org/apache/coyote/http2/Http2TestBase.java
index 301450011c..f9763e3fe9 100644
--- a/test/org/apache/coyote/http2/Http2TestBase.java
+++ b/test/org/apache/coyote/http2/Http2TestBase.java
@@ -1306,6 +1306,18 @@ public abstract class Http2TestBase extends 
TomcatBaseTest {
 }
 
 
+public static class NoContentServlet extends HttpServlet {
+
+private static final long serialVersionUID = 1L;
+
+@Override
+protected void doGet(HttpServletRequest req, HttpServletResponse resp)
+throws ServletException, IOException {
+resp.setStatus(HttpServletResponse.SC_NO_CONTENT);
+}
+}
+
+
 public static class SimpleServlet extends HttpServlet {
 
 private static final long serialVersionUID = 1L;
diff --git a/test/org/apache/coyote/http2/TestStreamProcessor.java 
b/test/org/apache/coyote/http2/TestStreamProcessor.java
index 8516d98f22..16fa106567 100644
--- a/test/org/apache/coyote/http2/TestStreamProcessor.java
+++ b/test/org/apache/coyote/http2/TestStreamProcessor.java
@@ -164,6 +164,55 @@ public class TestStreamProcessor extends Http2TestBase {
 }
 expected.append("3-Header-[date]-[Wed, 11 Nov 2015 19:18:42 GMT]\n");
 expected.append("3-HeadersEnd\n");
+expected.append("3-EndOfStream\n");
+
+Assert.assertEquals(expected.toString(), output.getTrace());
+}
+
+
+@Test
+public void testPrepareHeadersNoContent() throws Exception {
+enableHttp2();
+
+Tomcat tomcat = getTomcatInstance();
+
+File appDir = new File("test/webapp");
+Context ctxt = tomcat.addWebapp(null, "", appDir.getAbsolutePath());
+
+Tomcat.addServlet(ctxt, "simple", new SimpleServlet());
+ctxt.addServletMappingDecoded("/simple", "simple");
+Tomcat.addServlet(ctxt, "noContent", new NoContentServlet());
+ctxt.addServletMappingDecoded("/noContent", "noContent");
+
+
+tomcat.start();
+
+openClientConnection();
+doHttpUpgrade();
+sendClientPreface();
+validateHttp2InitialResponse();
+
+byte[] frameHeader = new byte[9];
+ByteBuffer headersPayload = ByteBuffer.allocate(128);
+
+ 

[tomcat] 02/05: Disable formatting for clarity

2023-01-25 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit b49a17f9c82fefd42e123b7268786aaa18401eb9
Author: Mark Thomas 
AuthorDate: Wed Jan 25 15:35:39 2023 +

Disable formatting for clarity
---
 java/org/apache/coyote/http2/FrameType.java  | 3 ++-
 java/org/apache/coyote/http2/Http2Error.java | 3 ++-
 java/org/apache/coyote/http2/StreamStateMachine.java | 2 ++
 3 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/coyote/http2/FrameType.java 
b/java/org/apache/coyote/http2/FrameType.java
index 8734944595..425c0516fd 100644
--- a/java/org/apache/coyote/http2/FrameType.java
+++ b/java/org/apache/coyote/http2/FrameType.java
@@ -21,7 +21,7 @@ import java.util.function.IntPredicate;
 import org.apache.tomcat.util.res.StringManager;
 
 enum FrameType {
-
+// @formatter:off
 DATA  (0,   false,  true, null,  false),
 HEADERS   (1,   false,  true, null,   true),
 PRIORITY  (2,   false,  true, (x) -> x == 5, false),
@@ -33,6 +33,7 @@ enum FrameType {
 WINDOW_UPDATE (8,true,  true, (x) -> x == 4,  true),
 CONTINUATION  (9,   false,  true, null,   true),
 UNKNOWN   (256,  true,  true, null,  false);
+// @formatter:on
 
 private static final StringManager sm = 
StringManager.getManager(FrameType.class);
 
diff --git a/java/org/apache/coyote/http2/Http2Error.java 
b/java/org/apache/coyote/http2/Http2Error.java
index b826b57812..4a47f22e79 100644
--- a/java/org/apache/coyote/http2/Http2Error.java
+++ b/java/org/apache/coyote/http2/Http2Error.java
@@ -17,7 +17,7 @@
 package org.apache.coyote.http2;
 
 enum Http2Error {
-
+// @formatter:off
 NO_ERROR(0x00),
 PROTOCOL_ERROR  (0x01),
 INTERNAL_ERROR  (0x02),
@@ -32,6 +32,7 @@ enum Http2Error {
 ENHANCE_YOUR_CALM   (0x0b),
 INADEQUATE_SECURITY (0x0c),
 HTTP_1_1_REQUIRED   (0x0d);
+// @formatter:on
 
 private final long code;
 
diff --git a/java/org/apache/coyote/http2/StreamStateMachine.java 
b/java/org/apache/coyote/http2/StreamStateMachine.java
index 6ec79ff81c..acc6687d36 100644
--- a/java/org/apache/coyote/http2/StreamStateMachine.java
+++ b/java/org/apache/coyote/http2/StreamStateMachine.java
@@ -169,6 +169,7 @@ class StreamStateMachine {
 }
 
 private enum State {
+// @formatter:off
 IDLE   (false, false, false, true,
 Http2Error.PROTOCOL_ERROR, FrameType.HEADERS,
FrameType.PRIORITY),
@@ -215,6 +216,7 @@ class StreamStateMachine {

FrameType.WINDOW_UPDATE),
 CLOSED_FINAL   (false, false, false, true,
 Http2Error.PROTOCOL_ERROR, FrameType.PRIORITY);
+// @formatter:on
 
 private final boolean canRead;
 private final boolean canWrite;


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



[tomcat] 01/05: Format each enum on a new line

2023-01-25 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 1bb14a46096f7d35c7a84804dc6fb18ac64d2495
Author: Mark Thomas 
AuthorDate: Wed Jan 25 15:30:17 2023 +

Format each enum on a new line
---
 res/ide-support/eclipse/formatting-asf-tomcat.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/res/ide-support/eclipse/formatting-asf-tomcat.xml 
b/res/ide-support/eclipse/formatting-asf-tomcat.xml
index 71f085b69d..7a4effe304 100644
--- a/res/ide-support/eclipse/formatting-asf-tomcat.xml
+++ b/res/ide-support/eclipse/formatting-asf-tomcat.xml
@@ -236,7 +236,7 @@
 
 
 
-
+
 
 
 


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



[tomcat] 05/05: Fix BZ 66442 - h2 responses without bodies should not use DATA frames

2023-01-25 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit b7a21f2d6fa73f932e9d01874936e5b6b32503fb
Author: Mark Thomas 
AuthorDate: Wed Jan 25 16:28:34 2023 +

Fix BZ 66442 - h2 responses without bodies should not use DATA frames

https://bz.apache.org/bugzilla/show_bug.cgi?id=66442
---
 java/org/apache/coyote/http2/Stream.java   |  7 
 java/org/apache/coyote/http2/StreamProcessor.java  |  4 ++
 test/org/apache/coyote/http2/Http2TestBase.java| 12 ++
 .../apache/coyote/http2/TestStreamProcessor.java   | 49 ++
 webapps/docs/changelog.xml |  5 +++
 5 files changed, 77 insertions(+)

diff --git a/java/org/apache/coyote/http2/Stream.java 
b/java/org/apache/coyote/http2/Stream.java
index faa00d0446..f018a97335 100644
--- a/java/org/apache/coyote/http2/Stream.java
+++ b/java/org/apache/coyote/http2/Stream.java
@@ -37,6 +37,7 @@ import org.apache.coyote.Response;
 import org.apache.coyote.http11.HttpOutputBuffer;
 import org.apache.coyote.http11.OutputFilter;
 import org.apache.coyote.http11.filters.SavedRequestInputFilter;
+import org.apache.coyote.http11.filters.VoidOutputFilter;
 import org.apache.coyote.http2.HpackDecoder.HeaderEmitter;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
@@ -432,6 +433,12 @@ class Stream extends AbstractNonZeroStream implements 
HeaderEmitter {
 }
 
 
+void configureVoidOutputFilter() {
+addOutputFilter(new VoidOutputFilter());
+// Prevent further writes by the application
+streamOutputBuffer.closed = true;
+}
+
 private void parseAuthority(String value, boolean host) throws 
HpackException {
 int i;
 try {
diff --git a/java/org/apache/coyote/http2/StreamProcessor.java 
b/java/org/apache/coyote/http2/StreamProcessor.java
index ba6e44617f..3e969cc5ea 100644
--- a/java/org/apache/coyote/http2/StreamProcessor.java
+++ b/java/org/apache/coyote/http2/StreamProcessor.java
@@ -205,6 +205,10 @@ class StreamProcessor extends AbstractProcessor {
 headers.addValue("content-length").setLong(contentLength);
 }
 } else {
+// Disable response body
+if (stream != null) {
+stream.configureVoidOutputFilter();
+}
 if (statusCode == 205) {
 // RFC 7231 requires the server to explicitly signal an empty
 // response in this case
diff --git a/test/org/apache/coyote/http2/Http2TestBase.java 
b/test/org/apache/coyote/http2/Http2TestBase.java
index fc3ad89f77..12c928852f 100644
--- a/test/org/apache/coyote/http2/Http2TestBase.java
+++ b/test/org/apache/coyote/http2/Http2TestBase.java
@@ -1275,6 +1275,18 @@ public abstract class Http2TestBase extends 
TomcatBaseTest {
 }
 
 
+public static class NoContentServlet extends HttpServlet {
+
+private static final long serialVersionUID = 1L;
+
+@Override
+protected void doGet(HttpServletRequest req, HttpServletResponse resp)
+throws ServletException, IOException {
+resp.setStatus(HttpServletResponse.SC_NO_CONTENT);
+}
+}
+
+
 protected static class SimpleServlet extends HttpServlet {
 
 private static final long serialVersionUID = 1L;
diff --git a/test/org/apache/coyote/http2/TestStreamProcessor.java 
b/test/org/apache/coyote/http2/TestStreamProcessor.java
index 21ec994ba7..ff3f7d07cf 100644
--- a/test/org/apache/coyote/http2/TestStreamProcessor.java
+++ b/test/org/apache/coyote/http2/TestStreamProcessor.java
@@ -165,6 +165,55 @@ public class TestStreamProcessor extends Http2TestBase {
 }
 expected.append("3-Header-[date]-[Wed, 11 Nov 2015 19:18:42 GMT]\n");
 expected.append("3-HeadersEnd\n");
+expected.append("3-EndOfStream\n");
+
+Assert.assertEquals(expected.toString(), output.getTrace());
+}
+
+
+@Test
+public void testPrepareHeadersNoContent() throws Exception {
+enableHttp2();
+
+Tomcat tomcat = getTomcatInstance();
+
+File appDir = new File("test/webapp");
+Context ctxt = tomcat.addWebapp(null, "", appDir.getAbsolutePath());
+
+Tomcat.addServlet(ctxt, "simple", new SimpleServlet());
+ctxt.addServletMappingDecoded("/simple", "simple");
+Tomcat.addServlet(ctxt, "noContent", new NoContentServlet());
+ctxt.addServletMappingDecoded("/noContent", "noContent");
+
+
+tomcat.start();
+
+openClientConnection();
+doHttpUpgrade();
+sendClientPreface();
+validateHttp2InitialResponse();
+
+byte[] frameHeader = new byte[9];
+ByteBuffer headersPayload = ByteBuffer.allocate(128);
+
+List headers = new ArrayList<>(3);
+headers.add(new Header(":method", "GET"));
+headers.add(new Header(":sc

[tomcat] branch 9.0.x updated (adb9c8a0f2 -> b7a21f2d6f)

2023-01-25 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a change to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


from adb9c8a0f2 Add ALv2 headers
 new 1bb14a4609 Format each enum on a new line
 new b49a17f9c8 Disable formatting for clarity
 new 47970e2d8f Add missing  tags
 new e1ae5aeb08 Code clean-up (format). No functional change.
 new b7a21f2d6f Fix BZ 66442 - h2 responses without bodies should not use 
DATA frames

The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../apache/coyote/http2/AbstractNonZeroStream.java |  44 +--
 java/org/apache/coyote/http2/AbstractStream.java   |  20 +-
 java/org/apache/coyote/http2/ByteUtil.java |   9 +-
 .../coyote/http2/ConnectionSettingsBase.java   |  75 ++--
 .../coyote/http2/ConnectionSettingsLocal.java  |  19 +-
 .../coyote/http2/ConnectionSettingsRemote.java |   3 +-
 java/org/apache/coyote/http2/FrameType.java|  66 ++--
 java/org/apache/coyote/http2/HPackHuffman.java |  77 ++--
 java/org/apache/coyote/http2/HeaderSink.java   |   5 +-
 java/org/apache/coyote/http2/Hpack.java|  32 +-
 java/org/apache/coyote/http2/HpackDecoder.java |  98 +++--
 java/org/apache/coyote/http2/HpackEncoder.java | 123 +++---
 java/org/apache/coyote/http2/HpackException.java   |   4 +-
 java/org/apache/coyote/http2/Http2AsyncParser.java |  99 ++---
 .../coyote/http2/Http2AsyncUpgradeHandler.java | 152 
 java/org/apache/coyote/http2/Http2Error.java   |   3 +-
 .../org/apache/coyote/http2/Http2OutputBuffer.java |  10 +-
 java/org/apache/coyote/http2/Http2Parser.java  | 308 +++
 java/org/apache/coyote/http2/Http2Protocol.java|  15 +-
 .../apache/coyote/http2/Http2UpgradeHandler.java   | 410 ++--
 java/org/apache/coyote/http2/RecycledStream.java   |   9 +-
 java/org/apache/coyote/http2/Setting.java  |  46 +--
 java/org/apache/coyote/http2/Stream.java   | 411 ++---
 java/org/apache/coyote/http2/StreamProcessor.java  |  93 +++--
 .../apache/coyote/http2/StreamStateMachine.java|  33 +-
 .../coyote/http2/WindowAllocationManager.java  |  69 ++--
 res/ide-support/eclipse/formatting-asf-tomcat.xml  |   2 +-
 test/org/apache/coyote/http2/Http2TestBase.java|  12 +
 .../apache/coyote/http2/TestStreamProcessor.java   |  49 +++
 webapps/docs/changelog.xml |   5 +
 30 files changed, 1125 insertions(+), 1176 deletions(-)


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



[tomcat] 03/05: Add missing tags

2023-01-25 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 47970e2d8f62806f9b55b332bb7784ad4a32d6b8
Author: Mark Thomas 
AuthorDate: Wed Jan 25 15:40:32 2023 +

Add missing  tags
---
 java/org/apache/coyote/http2/WindowAllocationManager.java | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/java/org/apache/coyote/http2/WindowAllocationManager.java 
b/java/org/apache/coyote/http2/WindowAllocationManager.java
index 45ac2fdbfd..47d0d1ac1f 100644
--- a/java/org/apache/coyote/http2/WindowAllocationManager.java
+++ b/java/org/apache/coyote/http2/WindowAllocationManager.java
@@ -28,22 +28,22 @@ import org.apache.tomcat.util.res.StringManager;
  * allocation and only issues allocation notifications when the stream is known
  * to be waiting for the notification.
  *
- * It is possible for a stream to be waiting for a connection allocation when
+ * It is possible for a stream to be waiting for a connection allocation 
when
  * a stream allocation is made. Therefore this class tracks the type of
  * allocation that the stream is waiting for to ensure that notifications are
  * correctly triggered.
  *
- * With the implementation at the time of writing, it is not possible for a
+ * With the implementation at the time of writing, it is not possible for a
  * stream to receive an unexpected connection notification as these are only
  * issues to streams in the backlog and a stream must be waiting for a
  * connection allocation in order to be placed on the backlog. However, as a
  * precaution, this class protects against unexpected connection notifications.
  *
- * It is important for asynchronous processing not to notify unless a
+ * It is important for asynchronous processing not to notify unless a
  * notification is expected else a dispatch will be performed unnecessarily
  * which may lead to unexpected results.
  *
- * A previous implementation used separate locks for the stream and connection
+ * A previous implementation used separate locks for the stream and 
connection
  * notifications. However, correct handling of allocation waiting requires
  * holding the stream lock when making the decision to wait. Therefore both
  * allocations need to wait on the Stream.


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



[tomcat] branch 8.5.x updated (353306175b -> ab34aa9a33)

2023-01-25 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a change to branch 8.5.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


from 353306175b Add ALv2 headers
 new 2e67ad0e4d Format each enum on a new line
 new 85d7d75d82 Disable formatting for clarity
 new af5653a7e4 Add missing  tags
 new 0241a20c16 Code clean-up (format). No functional change.
 new ab34aa9a33 Fix BZ 66442 - h2 responses without bodies should not use 
DATA frames

The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../apache/coyote/http2/AbstractNonZeroStream.java |  44 +--
 java/org/apache/coyote/http2/AbstractStream.java   |  24 +-
 java/org/apache/coyote/http2/ByteUtil.java |   9 +-
 .../coyote/http2/ConnectionSettingsBase.java   |  75 ++--
 .../coyote/http2/ConnectionSettingsLocal.java  |  19 +-
 .../coyote/http2/ConnectionSettingsRemote.java |   3 +-
 java/org/apache/coyote/http2/FrameType.java|  66 ++--
 java/org/apache/coyote/http2/HPackHuffman.java |  77 ++--
 java/org/apache/coyote/http2/HeaderSink.java   |   5 +-
 java/org/apache/coyote/http2/Hpack.java|  32 +-
 java/org/apache/coyote/http2/HpackDecoder.java |  98 +++--
 java/org/apache/coyote/http2/HpackEncoder.java | 123 +++
 java/org/apache/coyote/http2/HpackException.java   |   4 +-
 java/org/apache/coyote/http2/Http2Error.java   |   3 +-
 .../org/apache/coyote/http2/Http2OutputBuffer.java |  10 +-
 java/org/apache/coyote/http2/Http2Parser.java  | 320 -
 java/org/apache/coyote/http2/Http2Protocol.java|  14 +-
 .../apache/coyote/http2/Http2UpgradeHandler.java   | 394 ++---
 java/org/apache/coyote/http2/RecycledStream.java   |   9 +-
 java/org/apache/coyote/http2/Setting.java  |  46 +--
 java/org/apache/coyote/http2/Stream.java   | 393 ++--
 java/org/apache/coyote/http2/StreamProcessor.java  |  81 ++---
 .../apache/coyote/http2/StreamStateMachine.java|  33 +-
 .../coyote/http2/WindowAllocationManager.java  |  69 ++--
 res/ide-support/eclipse/formatting-asf-tomcat.xml  |   2 +-
 test/org/apache/coyote/http2/Http2TestBase.java|  12 +
 .../apache/coyote/http2/TestStreamProcessor.java   |  49 +++
 webapps/docs/changelog.xml |   5 +
 28 files changed, 979 insertions(+), 1040 deletions(-)


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



[tomcat] 03/05: Add missing tags

2023-01-25 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 8.5.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit af5653a7e4e740aa80f574d3eb7969742ca3396a
Author: Mark Thomas 
AuthorDate: Wed Jan 25 15:40:32 2023 +

Add missing  tags
---
 java/org/apache/coyote/http2/WindowAllocationManager.java | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/java/org/apache/coyote/http2/WindowAllocationManager.java 
b/java/org/apache/coyote/http2/WindowAllocationManager.java
index 45ac2fdbfd..47d0d1ac1f 100644
--- a/java/org/apache/coyote/http2/WindowAllocationManager.java
+++ b/java/org/apache/coyote/http2/WindowAllocationManager.java
@@ -28,22 +28,22 @@ import org.apache.tomcat.util.res.StringManager;
  * allocation and only issues allocation notifications when the stream is known
  * to be waiting for the notification.
  *
- * It is possible for a stream to be waiting for a connection allocation when
+ * It is possible for a stream to be waiting for a connection allocation 
when
  * a stream allocation is made. Therefore this class tracks the type of
  * allocation that the stream is waiting for to ensure that notifications are
  * correctly triggered.
  *
- * With the implementation at the time of writing, it is not possible for a
+ * With the implementation at the time of writing, it is not possible for a
  * stream to receive an unexpected connection notification as these are only
  * issues to streams in the backlog and a stream must be waiting for a
  * connection allocation in order to be placed on the backlog. However, as a
  * precaution, this class protects against unexpected connection notifications.
  *
- * It is important for asynchronous processing not to notify unless a
+ * It is important for asynchronous processing not to notify unless a
  * notification is expected else a dispatch will be performed unnecessarily
  * which may lead to unexpected results.
  *
- * A previous implementation used separate locks for the stream and connection
+ * A previous implementation used separate locks for the stream and 
connection
  * notifications. However, correct handling of allocation waiting requires
  * holding the stream lock when making the decision to wait. Therefore both
  * allocations need to wait on the Stream.


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



[tomcat] 02/05: Disable formatting for clarity

2023-01-25 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 8.5.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 85d7d75d82f6cc040fa897cd692ead06380db03a
Author: Mark Thomas 
AuthorDate: Wed Jan 25 15:35:39 2023 +

Disable formatting for clarity
---
 java/org/apache/coyote/http2/FrameType.java  | 3 ++-
 java/org/apache/coyote/http2/Http2Error.java | 3 ++-
 java/org/apache/coyote/http2/StreamStateMachine.java | 2 ++
 3 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/coyote/http2/FrameType.java 
b/java/org/apache/coyote/http2/FrameType.java
index 44e5b55c51..ca6476b1e0 100644
--- a/java/org/apache/coyote/http2/FrameType.java
+++ b/java/org/apache/coyote/http2/FrameType.java
@@ -19,7 +19,7 @@ package org.apache.coyote.http2;
 import org.apache.tomcat.util.res.StringManager;
 
 enum FrameType {
-
+// @formatter:off
 DATA  (0,   false,  true, null,   false),
 HEADERS   (1,   false,  true, null,true),
 PRIORITY  (2,   false,  true, equals(5),  false),
@@ -31,6 +31,7 @@ enum FrameType {
 WINDOW_UPDATE (8,true,  true, equals(4),   true),
 CONTINUATION  (9,   false,  true, null,true),
 UNKNOWN   (256,  true,  true, null,   false);
+// @formatter:on
 
 private static final StringManager sm = 
StringManager.getManager(FrameType.class);
 
diff --git a/java/org/apache/coyote/http2/Http2Error.java 
b/java/org/apache/coyote/http2/Http2Error.java
index b826b57812..4a47f22e79 100644
--- a/java/org/apache/coyote/http2/Http2Error.java
+++ b/java/org/apache/coyote/http2/Http2Error.java
@@ -17,7 +17,7 @@
 package org.apache.coyote.http2;
 
 enum Http2Error {
-
+// @formatter:off
 NO_ERROR(0x00),
 PROTOCOL_ERROR  (0x01),
 INTERNAL_ERROR  (0x02),
@@ -32,6 +32,7 @@ enum Http2Error {
 ENHANCE_YOUR_CALM   (0x0b),
 INADEQUATE_SECURITY (0x0c),
 HTTP_1_1_REQUIRED   (0x0d);
+// @formatter:on
 
 private final long code;
 
diff --git a/java/org/apache/coyote/http2/StreamStateMachine.java 
b/java/org/apache/coyote/http2/StreamStateMachine.java
index 6ec79ff81c..acc6687d36 100644
--- a/java/org/apache/coyote/http2/StreamStateMachine.java
+++ b/java/org/apache/coyote/http2/StreamStateMachine.java
@@ -169,6 +169,7 @@ class StreamStateMachine {
 }
 
 private enum State {
+// @formatter:off
 IDLE   (false, false, false, true,
 Http2Error.PROTOCOL_ERROR, FrameType.HEADERS,
FrameType.PRIORITY),
@@ -215,6 +216,7 @@ class StreamStateMachine {

FrameType.WINDOW_UPDATE),
 CLOSED_FINAL   (false, false, false, true,
 Http2Error.PROTOCOL_ERROR, FrameType.PRIORITY);
+// @formatter:on
 
 private final boolean canRead;
 private final boolean canWrite;


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



[tomcat] 05/05: Fix BZ 66442 - h2 responses without bodies should not use DATA frames

2023-01-25 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 8.5.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit ab34aa9a338c3de113dfe4dda1ebbd49defb7d04
Author: Mark Thomas 
AuthorDate: Wed Jan 25 16:28:34 2023 +

Fix BZ 66442 - h2 responses without bodies should not use DATA frames

https://bz.apache.org/bugzilla/show_bug.cgi?id=66442
---
 java/org/apache/coyote/http2/Stream.java   |  7 
 java/org/apache/coyote/http2/StreamProcessor.java  |  4 ++
 test/org/apache/coyote/http2/Http2TestBase.java| 12 ++
 .../apache/coyote/http2/TestStreamProcessor.java   | 49 ++
 webapps/docs/changelog.xml |  5 +++
 5 files changed, 77 insertions(+)

diff --git a/java/org/apache/coyote/http2/Stream.java 
b/java/org/apache/coyote/http2/Stream.java
index 51f9f72f76..2c05ff688f 100644
--- a/java/org/apache/coyote/http2/Stream.java
+++ b/java/org/apache/coyote/http2/Stream.java
@@ -34,6 +34,7 @@ import org.apache.coyote.Response;
 import org.apache.coyote.http11.HttpOutputBuffer;
 import org.apache.coyote.http11.OutputFilter;
 import org.apache.coyote.http11.filters.SavedRequestInputFilter;
+import org.apache.coyote.http11.filters.VoidOutputFilter;
 import org.apache.coyote.http2.HpackDecoder.HeaderEmitter;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
@@ -425,6 +426,12 @@ class Stream extends AbstractNonZeroStream implements 
HeaderEmitter {
 }
 
 
+void configureVoidOutputFilter() {
+addOutputFilter(new VoidOutputFilter());
+// Prevent further writes by the application
+streamOutputBuffer.closed = true;
+}
+
 private void parseAuthority(String value, boolean host) throws 
HpackException {
 int i;
 try {
diff --git a/java/org/apache/coyote/http2/StreamProcessor.java 
b/java/org/apache/coyote/http2/StreamProcessor.java
index d6e48624b3..d51ad971e1 100644
--- a/java/org/apache/coyote/http2/StreamProcessor.java
+++ b/java/org/apache/coyote/http2/StreamProcessor.java
@@ -182,6 +182,10 @@ class StreamProcessor extends AbstractProcessor {
 headers.addValue("content-length").setLong(contentLength);
 }
 } else {
+// Disable response body
+if (stream != null) {
+stream.configureVoidOutputFilter();
+}
 if (statusCode == 205) {
 // RFC 7231 requires the server to explicitly signal an empty
 // response in this case
diff --git a/test/org/apache/coyote/http2/Http2TestBase.java 
b/test/org/apache/coyote/http2/Http2TestBase.java
index e6f60a2f3a..5d4b2d9dae 100644
--- a/test/org/apache/coyote/http2/Http2TestBase.java
+++ b/test/org/apache/coyote/http2/Http2TestBase.java
@@ -1269,6 +1269,18 @@ public abstract class Http2TestBase extends 
TomcatBaseTest {
 }
 
 
+public static class NoContentServlet extends HttpServlet {
+
+private static final long serialVersionUID = 1L;
+
+@Override
+protected void doGet(HttpServletRequest req, HttpServletResponse resp)
+throws ServletException, IOException {
+resp.setStatus(HttpServletResponse.SC_NO_CONTENT);
+}
+}
+
+
 protected static class SimpleServlet extends HttpServlet {
 
 private static final long serialVersionUID = 1L;
diff --git a/test/org/apache/coyote/http2/TestStreamProcessor.java 
b/test/org/apache/coyote/http2/TestStreamProcessor.java
index 21ec994ba7..ff3f7d07cf 100644
--- a/test/org/apache/coyote/http2/TestStreamProcessor.java
+++ b/test/org/apache/coyote/http2/TestStreamProcessor.java
@@ -165,6 +165,55 @@ public class TestStreamProcessor extends Http2TestBase {
 }
 expected.append("3-Header-[date]-[Wed, 11 Nov 2015 19:18:42 GMT]\n");
 expected.append("3-HeadersEnd\n");
+expected.append("3-EndOfStream\n");
+
+Assert.assertEquals(expected.toString(), output.getTrace());
+}
+
+
+@Test
+public void testPrepareHeadersNoContent() throws Exception {
+enableHttp2();
+
+Tomcat tomcat = getTomcatInstance();
+
+File appDir = new File("test/webapp");
+Context ctxt = tomcat.addWebapp(null, "", appDir.getAbsolutePath());
+
+Tomcat.addServlet(ctxt, "simple", new SimpleServlet());
+ctxt.addServletMappingDecoded("/simple", "simple");
+Tomcat.addServlet(ctxt, "noContent", new NoContentServlet());
+ctxt.addServletMappingDecoded("/noContent", "noContent");
+
+
+tomcat.start();
+
+openClientConnection();
+doHttpUpgrade();
+sendClientPreface();
+validateHttp2InitialResponse();
+
+byte[] frameHeader = new byte[9];
+ByteBuffer headersPayload = ByteBuffer.allocate(128);
+
+List headers = new ArrayList<>(3);
+headers.add(new Header(":method", "GET"));
+headers.add(new Header(":sc

[tomcat] 01/05: Format each enum on a new line

2023-01-25 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 8.5.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 2e67ad0e4d5c92a2e2b7e9a70ae04087f982a085
Author: Mark Thomas 
AuthorDate: Wed Jan 25 15:30:17 2023 +

Format each enum on a new line
---
 res/ide-support/eclipse/formatting-asf-tomcat.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/res/ide-support/eclipse/formatting-asf-tomcat.xml 
b/res/ide-support/eclipse/formatting-asf-tomcat.xml
index 71f085b69d..7a4effe304 100644
--- a/res/ide-support/eclipse/formatting-asf-tomcat.xml
+++ b/res/ide-support/eclipse/formatting-asf-tomcat.xml
@@ -236,7 +236,7 @@
 
 
 
-
+
 
 
 


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



[Bug 66442] Data frame included in response for 204 No Content status

2023-01-25 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=66442

Mark Thomas  changed:

   What|Removed |Added

 Resolution|--- |FIXED
 Status|NEW |RESOLVED

--- Comment #2 from Mark Thomas  ---
Fixed in:
- 11.0.x for 11.0.0-M3 onwards
- 10.1.x for 10.1.6 onwards
-  9.0.x for  9.0.72 onwards
-  8.5.x for  8.5.86 onwards

-- 
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



[tomcat] branch main updated (519403fb8a -> 83801d7d84)

2023-01-25 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git


from 519403fb8a Fix BZ 66442 - h2 responses without bodies should not use 
DATA frames
 new 9437efd95b Refactor constants for default priority values
 new 83801d7d84 Add test for new default Chrome priority value

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 java/org/apache/coyote/http2/Constants.java|  3 ---
 java/org/apache/coyote/http2/Stream.java   |  4 ++--
 .../apache/tomcat/util/http/parser/Priority.java   |  7 +--
 .../tomcat/util/http/parser/TestPriority.java  | 22 --
 4 files changed, 19 insertions(+), 17 deletions(-)
 copy 
modules/jdbc-pool/src/test/java/org/apache/tomcat/jdbc/test/TestGetConnection.java
 => test/org/apache/tomcat/util/http/parser/TestPriority.java (64%)


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



[tomcat] 02/02: Add test for new default Chrome priority value

2023-01-25 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 83801d7d8482855d3cad43b3e73920b15964b667
Author: Mark Thomas 
AuthorDate: Wed Jan 25 17:56:41 2023 +

Add test for new default Chrome priority value

Reported to be causing issues for some servers
---
 .../tomcat/util/http/parser/TestPriority.java  | 37 ++
 1 file changed, 37 insertions(+)

diff --git a/test/org/apache/tomcat/util/http/parser/TestPriority.java 
b/test/org/apache/tomcat/util/http/parser/TestPriority.java
new file mode 100644
index 00..eeac940f6e
--- /dev/null
+++ b/test/org/apache/tomcat/util/http/parser/TestPriority.java
@@ -0,0 +1,37 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.tomcat.util.http.parser;
+
+import java.io.Reader;
+import java.io.StringReader;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class TestPriority {
+
+@Test
+public void testOnlyIncremental() throws Exception {
+String input = "i";
+Reader reader = new StringReader(input);
+
+Priority p = Priority.parsePriority(reader);
+
+Assert.assertEquals(Priority.DEFAULT_URGENCY, p.getUrgency());
+Assert.assertTrue(p.getIncremental());
+}
+}


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



[tomcat] 01/02: Refactor constants for default priority values

2023-01-25 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 9437efd95b137b7bf41b498df444d54ce08fd68f
Author: Mark Thomas 
AuthorDate: Wed Jan 25 17:56:32 2023 +

Refactor constants for default priority values
---
 java/org/apache/coyote/http2/Constants.java   | 3 ---
 java/org/apache/coyote/http2/Stream.java  | 4 ++--
 java/org/apache/tomcat/util/http/parser/Priority.java | 7 +--
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/java/org/apache/coyote/http2/Constants.java 
b/java/org/apache/coyote/http2/Constants.java
index e1ee63bb34..26ddba1960 100644
--- a/java/org/apache/coyote/http2/Constants.java
+++ b/java/org/apache/coyote/http2/Constants.java
@@ -18,9 +18,6 @@ package org.apache.coyote.http2;
 
 public class Constants {
 
-// Prioritisation
-public static final int DEFAULT_URGENCY = 3;
-public static final boolean DEFAULT_INCREMENTAL = false;
 // Range 0 to 7 inclusive
 public static final int URGENCY_RANGE = 8;
 
diff --git a/java/org/apache/coyote/http2/Stream.java 
b/java/org/apache/coyote/http2/Stream.java
index a0f997e13a..ae491f6339 100644
--- a/java/org/apache/coyote/http2/Stream.java
+++ b/java/org/apache/coyote/http2/Stream.java
@@ -97,8 +97,8 @@ class Stream extends AbstractNonZeroStream implements 
HeaderEmitter {
 private Object pendingWindowUpdateForStreamLock = new Object();
 private int pendingWindowUpdateForStream = 0;
 
-private volatile int urgency = Constants.DEFAULT_URGENCY;
-private volatile boolean incremental = Constants.DEFAULT_INCREMENTAL;
+private volatile int urgency = Priority.DEFAULT_URGENCY;
+private volatile boolean incremental = Priority.DEFAULT_INCREMENTAL;
 
 
 Stream(Integer identifier, Http2UpgradeHandler handler) {
diff --git a/java/org/apache/tomcat/util/http/parser/Priority.java 
b/java/org/apache/tomcat/util/http/parser/Priority.java
index 0690bd0c41..ce8ec3b8e0 100644
--- a/java/org/apache/tomcat/util/http/parser/Priority.java
+++ b/java/org/apache/tomcat/util/http/parser/Priority.java
@@ -29,9 +29,12 @@ import 
org.apache.tomcat.util.http.parser.StructuredField.SfListMember;
  */
 public class Priority {
 
+public static final int DEFAULT_URGENCY = 3;
+public static final boolean DEFAULT_INCREMENTAL = false;
+
 // Explicitly set the defaults as per RFC 9218
-private int urgency = 3;
-private boolean incremental = false;
+private int urgency = DEFAULT_URGENCY;
+private boolean incremental = DEFAULT_INCREMENTAL;
 
 public Priority() {
 // Default constructor is NO-OP.


-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org