[tomcat] 02/03: Add missing facade checks

2023-01-18 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 2528795d57358f8c00d92bd616803eed3b4be485
Author: Mark Thomas 
AuthorDate: Wed Jan 18 19:29:37 2023 +

Add missing facade checks
---
 .../apache/catalina/connector/ResponseFacade.java   | 21 -
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/java/org/apache/catalina/connector/ResponseFacade.java 
b/java/org/apache/catalina/connector/ResponseFacade.java
index ef01dd674f..46b198c63d 100644
--- a/java/org/apache/catalina/connector/ResponseFacade.java
+++ b/java/org/apache/catalina/connector/ResponseFacade.java
@@ -109,7 +109,6 @@ public class ResponseFacade implements HttpServletResponse {
  * @param response The response to be wrapped
  */
 public ResponseFacade(Response response) {
-
  this.response = response;
 }
 
@@ -177,6 +176,7 @@ public class ResponseFacade implements HttpServletResponse {
 
 @Override
 public ServletOutputStream getOutputStream() throws IOException {
+checkFacade();
 ServletOutputStream sos = response.getOutputStream();
 if (isFinished()) {
 response.setSuspended(true);
@@ -187,6 +187,7 @@ public class ResponseFacade implements HttpServletResponse {
 
 @Override
 public PrintWriter getWriter() throws IOException {
+checkFacade();
 PrintWriter writer = response.getWriter();
 if (isFinished()) {
 response.setSuspended(true);
@@ -197,6 +198,7 @@ public class ResponseFacade implements HttpServletResponse {
 
 @Override
 public void setContentLength(int len) {
+checkFacade();
 if (isCommitted()) {
 return;
 }
@@ -206,6 +208,7 @@ public class ResponseFacade implements HttpServletResponse {
 
 @Override
 public void setContentLengthLong(long length) {
+checkFacade();
 if (isCommitted()) {
 return;
 }
@@ -215,6 +218,7 @@ public class ResponseFacade implements HttpServletResponse {
 
 @Override
 public void setContentType(String type) {
+checkFacade();
 if (isCommitted()) {
 return;
 }
@@ -243,6 +247,7 @@ public class ResponseFacade implements HttpServletResponse {
 
 @Override
 public void flushBuffer() throws IOException {
+checkFacade();
 if (isFinished()) {
 return;
 }
@@ -286,6 +291,7 @@ public class ResponseFacade implements HttpServletResponse {
 
 @Override
 public void setLocale(Locale loc) {
+checkFacade();
 if (isCommitted()) {
 return;
 }
@@ -302,6 +308,7 @@ public class ResponseFacade implements HttpServletResponse {
 
 @Override
 public void addCookie(Cookie cookie) {
+checkFacade();
 if (isCommitted()) {
 return;
 }
@@ -370,6 +377,7 @@ public class ResponseFacade implements HttpServletResponse {
 
 @Override
 public void setDateHeader(String name, long date) {
+checkFacade();
 if (isCommitted()) {
 return;
 }
@@ -384,6 +392,7 @@ public class ResponseFacade implements HttpServletResponse {
 
 @Override
 public void addDateHeader(String name, long date) {
+checkFacade();
 if (isCommitted()) {
 return;
 }
@@ -398,6 +407,7 @@ public class ResponseFacade implements HttpServletResponse {
 
 @Override
 public void setHeader(String name, String value) {
+checkFacade();
 if (isCommitted()) {
 return;
 }
@@ -407,6 +417,7 @@ public class ResponseFacade implements HttpServletResponse {
 
 @Override
 public void addHeader(String name, String value) {
+checkFacade();
 if (isCommitted()) {
 return;
 }
@@ -416,6 +427,7 @@ public class ResponseFacade implements HttpServletResponse {
 
 @Override
 public void setIntHeader(String name, int value) {
+checkFacade();
 if (isCommitted()) {
 return;
 }
@@ -425,6 +437,7 @@ public class ResponseFacade implements HttpServletResponse {
 
 @Override
 public void addIntHeader(String name, int value) {
+checkFacade();
 if (isCommitted()) {
 return;
 }
@@ -434,6 +447,7 @@ public class ResponseFacade implements HttpServletResponse {
 
 @Override
 public void setStatus(int sc) {
+checkFacade();
 if (isCommitted()) {
 return;
 }
@@ -467,21 +481,25 @@ public class ResponseFacade implements 
HttpServletResponse {
 
 @Override
 public int getStatus() {
+checkFacade();
 return response.getStatus();
 }
 
 @Override
 public String getHeader(String name) {
+checkFacade();
 return response.getHeader(name);
 }
 
 @Override
 

[tomcat] 01/03: Refactor to reduce duplicate code

2023-01-18 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 64b0d9d6717a7f8f2f6efe57adc8cb7ddab9c266
Author: Mark Thomas 
AuthorDate: Wed Jan 18 19:26:07 2023 +

Refactor to reduce duplicate code
---
 .../apache/catalina/connector/ResponseFacade.java  | 232 -
 1 file changed, 45 insertions(+), 187 deletions(-)

diff --git a/java/org/apache/catalina/connector/ResponseFacade.java 
b/java/org/apache/catalina/connector/ResponseFacade.java
index 4656076a00..ef01dd674f 100644
--- a/java/org/apache/catalina/connector/ResponseFacade.java
+++ b/java/org/apache/catalina/connector/ResponseFacade.java
@@ -131,7 +131,6 @@ public class ResponseFacade implements HttpServletResponse {
 
 // - Public Methods
 
-
 /**
  * Clear facade.
  */
@@ -144,90 +143,55 @@ public class ResponseFacade implements 
HttpServletResponse {
  * Prevent cloning the facade.
  */
 @Override
-protected Object clone()
-throws CloneNotSupportedException {
+protected Object clone() throws CloneNotSupportedException {
 throw new CloneNotSupportedException();
 }
 
 
 public void finish() {
-
-if (response == null) {
-throw new IllegalStateException(
-sm.getString("responseFacade.nullResponse"));
-}
-
+checkFacade();
 response.setSuspended(true);
 }
 
 
 public boolean isFinished() {
-
-if (response == null) {
-throw new IllegalStateException(
-sm.getString("responseFacade.nullResponse"));
-}
-
+checkFacade();
 return response.isSuspended();
 }
 
 
 public long getContentWritten() {
-
-if (response == null) {
-throw new IllegalStateException(
-sm.getString("responseFacade.nullResponse"));
-}
-
+checkFacade();
 return response.getContentWritten();
 }
 
-//  ServletResponse Methods
 
+//  ServletResponse Methods
 
 @Override
 public String getCharacterEncoding() {
-
-if (response == null) {
-throw new IllegalStateException(
-sm.getString("responseFacade.nullResponse"));
-}
-
+checkFacade();
 return response.getCharacterEncoding();
 }
 
 
 @Override
-public ServletOutputStream getOutputStream()
-throws IOException {
-
-//if (isFinished())
-//throw new IllegalStateException
-//(/*sm.getString("responseFacade.finished")*/);
-
+public ServletOutputStream getOutputStream() throws IOException {
 ServletOutputStream sos = response.getOutputStream();
 if (isFinished()) {
 response.setSuspended(true);
 }
 return sos;
-
 }
 
 
 @Override
-public PrintWriter getWriter()
-throws IOException {
-
-//if (isFinished())
-//throw new IllegalStateException
-//(/*sm.getString("responseFacade.finished")*/);
-
+public PrintWriter getWriter() throws IOException {
 PrintWriter writer = response.getWriter();
 if (isFinished()) {
 response.setSuspended(true);
 }
 return writer;
-
 }
 
 
@@ -251,7 +215,6 @@ public class ResponseFacade implements HttpServletResponse {
 
 @Override
 public void setContentType(String type) {
-
 if (isCommitted()) {
 return;
 }
@@ -266,32 +229,20 @@ public class ResponseFacade implements 
HttpServletResponse {
 
 @Override
 public void setBufferSize(int size) {
-
-if (isCommitted()) {
-throw new IllegalStateException
-(sm.getString("coyoteResponse.setBufferSize.ise"));
-}
-
+checkCommitted("coyoteResponse.setBufferSize.ise");
 response.setBufferSize(size);
-
 }
 
 
 @Override
 public int getBufferSize() {
-
-if (response == null) {
-throw new IllegalStateException(
-sm.getString("responseFacade.nullResponse"));
-}
-
+checkFacade();
 return response.getBufferSize();
 }
 
 
 @Override
 public void flushBuffer() throws IOException {
-
 if (isFinished()) {
 return;
 }
@@ -314,276 +265,179 @@ public class ResponseFacade implements 
HttpServletResponse {
 
 @Override
 public void resetBuffer() {
-
-if (isCommitted()) {
-throw new IllegalStateException
-(sm.getString("coyoteResponse.resetBuffer.ise"));
-}
-
+checkCommitted("coyoteResponse.resetBuffer.is

[tomcat] 03/03: Refactor to reduce code duplication

2023-01-18 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 ed6f1a616c0d80c292a883cb3b361a49863d728a
Author: Mark Thomas 
AuthorDate: Wed Jan 18 20:02:14 2023 +

Refactor to reduce code duplication
---
 .../apache/catalina/core/ApplicationContext.java   | 72 ++
 1 file changed, 19 insertions(+), 53 deletions(-)

diff --git a/java/org/apache/catalina/core/ApplicationContext.java 
b/java/org/apache/catalina/core/ApplicationContext.java
index ab125aa829..6d5615ddd1 100644
--- a/java/org/apache/catalina/core/ApplicationContext.java
+++ b/java/org/apache/catalina/core/ApplicationContext.java
@@ -93,7 +93,6 @@ public class ApplicationContext implements ServletContext {
 
 protected static final boolean GET_RESOURCE_REQUIRE_SLASH;
 
-
 static {
 STRICT_SERVLET_COMPLIANCE = Globals.STRICT_SERVLET_COMPLIANCE;
 
@@ -106,8 +105,8 @@ public class ApplicationContext implements ServletContext {
 }
 }
 
-// --- Constructors
 
+// --- Constructors
 
 /**
  * Construct a new instance of this class, associated with the specified
@@ -790,12 +789,8 @@ public class ApplicationContext implements ServletContext {
 "applicationContext.invalidFilterName", filterName));
 }
 
-if (!context.getState().equals(LifecycleState.STARTING_PREP)) {
-//TODO Spec breaking enhancement to ignore this restriction
-throw new IllegalStateException(
-sm.getString("applicationContext.addFilter.ise",
-getContextPath()));
-}
+// TODO Spec breaking enhancement to ignore this restriction
+checkState("applicationContext.addFilter.ise");
 
 FilterDef filterDef = context.findFilterDef(filterName);
 
@@ -910,12 +905,8 @@ public class ApplicationContext implements ServletContext {
 "applicationContext.invalidServletName", servletName));
 }
 
-if (!context.getState().equals(LifecycleState.STARTING_PREP)) {
-//TODO Spec breaking enhancement to ignore this restriction
-throw new IllegalStateException(
-sm.getString("applicationContext.addServlet.ise",
-getContextPath()));
-}
+// TODO Spec breaking enhancement to ignore this restriction
+checkState("applicationContext.addServlet.ise");
 
 Wrapper wrapper = (Wrapper) context.findChild(servletName);
 
@@ -1040,11 +1031,7 @@ public class ApplicationContext implements 
ServletContext {
 @Override
 public void setSessionTrackingModes(Set 
sessionTrackingModes) {
 
-if (!context.getState().equals(LifecycleState.STARTING_PREP)) {
-throw new IllegalStateException(
-sm.getString("applicationContext.setSessionTracking.ise",
-getContextPath()));
-}
+checkState("applicationContext.setSessionTracking.ise");
 
 // Check that only supported tracking modes have been requested
 for (SessionTrackingMode sessionTrackingMode : sessionTrackingModes) {
@@ -1074,12 +1061,7 @@ public class ApplicationContext implements 
ServletContext {
 if (name == null) {
 throw new 
NullPointerException(sm.getString("applicationContext.setAttribute.namenull"));
 }
-if (!context.getState().equals(LifecycleState.STARTING_PREP)) {
-throw new IllegalStateException(
-sm.getString("applicationContext.setInitParam.ise",
-getContextPath()));
-}
-
+checkState("applicationContext.setInitParam.ise");
 return parameters.putIfAbsent(name, value) == null;
 }
 
@@ -1130,11 +1112,7 @@ public class ApplicationContext implements 
ServletContext {
 
 @Override
 public  void addListener(T t) {
-if (!context.getState().equals(LifecycleState.STARTING_PREP)) {
-throw new IllegalStateException(
-sm.getString("applicationContext.addListener.ise",
-getContextPath()));
-}
+checkState("applicationContext.addListener.ise");
 
 boolean match = false;
 if (t instanceof ServletContextAttributeListener ||
@@ -1200,12 +1178,8 @@ public class ApplicationContext implements 
ServletContext {
 @Override
 public void declareRoles(String... roleNames) {
 
-if (!context.getState().equals(LifecycleState.STARTING_PREP)) {
-//TODO Spec breaking enhancement to ignore this restriction
-throw new IllegalStateException(
-sm.getString("applicationContext.addRole.ise",
-getContextPath()));
-}
+/

[tomcat] branch 8.5.x updated (c8ffc35997 -> ed6f1a616c)

2023-01-18 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 c8ffc35997 Add missing "Not implemented" exception.
 new 64b0d9d671 Refactor to reduce duplicate code
 new 2528795d57 Add missing facade checks
 new ed6f1a616c Refactor to reduce code duplication

The 3 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/catalina/connector/ResponseFacade.java  | 253 ++---
 .../apache/catalina/core/ApplicationContext.java   |  72 ++
 2 files changed, 84 insertions(+), 241 deletions(-)


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



[tomcat] 03/03: Refactor to reduce code duplication

2023-01-18 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 1825ed0c8ff1a368010d6d293568ea71e46dba35
Author: Mark Thomas 
AuthorDate: Wed Jan 18 20:02:14 2023 +

Refactor to reduce code duplication
---
 .../apache/catalina/core/ApplicationContext.java   | 72 ++
 1 file changed, 19 insertions(+), 53 deletions(-)

diff --git a/java/org/apache/catalina/core/ApplicationContext.java 
b/java/org/apache/catalina/core/ApplicationContext.java
index 2672861433..7dbc88bd73 100644
--- a/java/org/apache/catalina/core/ApplicationContext.java
+++ b/java/org/apache/catalina/core/ApplicationContext.java
@@ -93,7 +93,6 @@ public class ApplicationContext implements ServletContext {
 
 protected static final boolean GET_RESOURCE_REQUIRE_SLASH;
 
-
 static {
 STRICT_SERVLET_COMPLIANCE = Globals.STRICT_SERVLET_COMPLIANCE;
 
@@ -106,8 +105,8 @@ public class ApplicationContext implements ServletContext {
 }
 }
 
-// --- Constructors
 
+// --- Constructors
 
 /**
  * Construct a new instance of this class, associated with the specified
@@ -790,12 +789,8 @@ public class ApplicationContext implements ServletContext {
 "applicationContext.invalidFilterName", filterName));
 }
 
-if (!context.getState().equals(LifecycleState.STARTING_PREP)) {
-//TODO Spec breaking enhancement to ignore this restriction
-throw new IllegalStateException(
-sm.getString("applicationContext.addFilter.ise",
-getContextPath()));
-}
+// TODO Spec breaking enhancement to ignore this restriction
+checkState("applicationContext.addFilter.ise");
 
 FilterDef filterDef = context.findFilterDef(filterName);
 
@@ -911,12 +906,8 @@ public class ApplicationContext implements ServletContext {
 "applicationContext.invalidServletName", servletName));
 }
 
-if (!context.getState().equals(LifecycleState.STARTING_PREP)) {
-//TODO Spec breaking enhancement to ignore this restriction
-throw new IllegalStateException(
-sm.getString("applicationContext.addServlet.ise",
-getContextPath()));
-}
+// TODO Spec breaking enhancement to ignore this restriction
+checkState("applicationContext.addServlet.ise");
 
 Wrapper wrapper = (Wrapper) context.findChild(servletName);
 
@@ -1041,11 +1032,7 @@ public class ApplicationContext implements 
ServletContext {
 @Override
 public void setSessionTrackingModes(Set 
sessionTrackingModes) {
 
-if (!context.getState().equals(LifecycleState.STARTING_PREP)) {
-throw new IllegalStateException(
-sm.getString("applicationContext.setSessionTracking.ise",
-getContextPath()));
-}
+checkState("applicationContext.setSessionTracking.ise");
 
 // Check that only supported tracking modes have been requested
 for (SessionTrackingMode sessionTrackingMode : sessionTrackingModes) {
@@ -1075,12 +1062,7 @@ public class ApplicationContext implements 
ServletContext {
 if (name == null) {
 throw new 
NullPointerException(sm.getString("applicationContext.setAttribute.namenull"));
 }
-if (!context.getState().equals(LifecycleState.STARTING_PREP)) {
-throw new IllegalStateException(
-sm.getString("applicationContext.setInitParam.ise",
-getContextPath()));
-}
-
+checkState("applicationContext.setInitParam.ise");
 return parameters.putIfAbsent(name, value) == null;
 }
 
@@ -1131,11 +1113,7 @@ public class ApplicationContext implements 
ServletContext {
 
 @Override
 public  void addListener(T t) {
-if (!context.getState().equals(LifecycleState.STARTING_PREP)) {
-throw new IllegalStateException(
-sm.getString("applicationContext.addListener.ise",
-getContextPath()));
-}
+checkState("applicationContext.addListener.ise");
 
 boolean match = false;
 if (t instanceof ServletContextAttributeListener ||
@@ -1201,12 +1179,8 @@ public class ApplicationContext implements 
ServletContext {
 @Override
 public void declareRoles(String... roleNames) {
 
-if (!context.getState().equals(LifecycleState.STARTING_PREP)) {
-//TODO Spec breaking enhancement to ignore this restriction
-throw new IllegalStateException(
-sm.getString("applicationContext.addRole.ise",
-getContextPath()));
-}
+/

[tomcat] 02/03: Add missing facade checks

2023-01-18 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 5d4071b229830d1dbcfea2ae727e73cbadd34e10
Author: Mark Thomas 
AuthorDate: Wed Jan 18 19:29:37 2023 +

Add missing facade checks
---
 .../apache/catalina/connector/ResponseFacade.java  | 23 +-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/java/org/apache/catalina/connector/ResponseFacade.java 
b/java/org/apache/catalina/connector/ResponseFacade.java
index 9b9e00af08..1ae9ee6805 100644
--- a/java/org/apache/catalina/connector/ResponseFacade.java
+++ b/java/org/apache/catalina/connector/ResponseFacade.java
@@ -111,7 +111,6 @@ public class ResponseFacade implements HttpServletResponse {
  * @param response The response to be wrapped
  */
 public ResponseFacade(Response response) {
-
  this.response = response;
 }
 
@@ -179,6 +178,7 @@ public class ResponseFacade implements HttpServletResponse {
 
 @Override
 public ServletOutputStream getOutputStream() throws IOException {
+checkFacade();
 ServletOutputStream sos = response.getOutputStream();
 if (isFinished()) {
 response.setSuspended(true);
@@ -189,6 +189,7 @@ public class ResponseFacade implements HttpServletResponse {
 
 @Override
 public PrintWriter getWriter() throws IOException {
+checkFacade();
 PrintWriter writer = response.getWriter();
 if (isFinished()) {
 response.setSuspended(true);
@@ -199,6 +200,7 @@ public class ResponseFacade implements HttpServletResponse {
 
 @Override
 public void setContentLength(int len) {
+checkFacade();
 if (isCommitted()) {
 return;
 }
@@ -208,6 +210,7 @@ public class ResponseFacade implements HttpServletResponse {
 
 @Override
 public void setContentLengthLong(long length) {
+checkFacade();
 if (isCommitted()) {
 return;
 }
@@ -217,6 +220,7 @@ public class ResponseFacade implements HttpServletResponse {
 
 @Override
 public void setContentType(String type) {
+checkFacade();
 if (isCommitted()) {
 return;
 }
@@ -245,6 +249,7 @@ public class ResponseFacade implements HttpServletResponse {
 
 @Override
 public void flushBuffer() throws IOException {
+checkFacade();
 if (isFinished()) {
 return;
 }
@@ -288,6 +293,7 @@ public class ResponseFacade implements HttpServletResponse {
 
 @Override
 public void setLocale(Locale loc) {
+checkFacade();
 if (isCommitted()) {
 return;
 }
@@ -304,6 +310,7 @@ public class ResponseFacade implements HttpServletResponse {
 
 @Override
 public void addCookie(Cookie cookie) {
+checkFacade();
 if (isCommitted()) {
 return;
 }
@@ -372,6 +379,7 @@ public class ResponseFacade implements HttpServletResponse {
 
 @Override
 public void setDateHeader(String name, long date) {
+checkFacade();
 if (isCommitted()) {
 return;
 }
@@ -386,6 +394,7 @@ public class ResponseFacade implements HttpServletResponse {
 
 @Override
 public void addDateHeader(String name, long date) {
+checkFacade();
 if (isCommitted()) {
 return;
 }
@@ -400,6 +409,7 @@ public class ResponseFacade implements HttpServletResponse {
 
 @Override
 public void setHeader(String name, String value) {
+checkFacade();
 if (isCommitted()) {
 return;
 }
@@ -409,6 +419,7 @@ public class ResponseFacade implements HttpServletResponse {
 
 @Override
 public void addHeader(String name, String value) {
+checkFacade();
 if (isCommitted()) {
 return;
 }
@@ -418,6 +429,7 @@ public class ResponseFacade implements HttpServletResponse {
 
 @Override
 public void setIntHeader(String name, int value) {
+checkFacade();
 if (isCommitted()) {
 return;
 }
@@ -427,6 +439,7 @@ public class ResponseFacade implements HttpServletResponse {
 
 @Override
 public void addIntHeader(String name, int value) {
+checkFacade();
 if (isCommitted()) {
 return;
 }
@@ -436,6 +449,7 @@ public class ResponseFacade implements HttpServletResponse {
 
 @Override
 public void setStatus(int sc) {
+checkFacade();
 if (isCommitted()) {
 return;
 }
@@ -469,33 +483,39 @@ public class ResponseFacade implements 
HttpServletResponse {
 
 @Override
 public int getStatus() {
+checkFacade();
 return response.getStatus();
 }
 
 @Override
 public String getHeader(String name) {
+checkFacade();
 return response.getHeader(name);
 }
 
 @Override
 

[tomcat] 01/03: Refactor to reduce duplicate code

2023-01-18 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 20c4d5512e95c1e1c2f5c1fb82e01c5f2d21a426
Author: Mark Thomas 
AuthorDate: Wed Jan 18 19:26:07 2023 +

Refactor to reduce duplicate code
---
 .../apache/catalina/connector/ResponseFacade.java  | 232 -
 1 file changed, 45 insertions(+), 187 deletions(-)

diff --git a/java/org/apache/catalina/connector/ResponseFacade.java 
b/java/org/apache/catalina/connector/ResponseFacade.java
index 6c04b17de2..9b9e00af08 100644
--- a/java/org/apache/catalina/connector/ResponseFacade.java
+++ b/java/org/apache/catalina/connector/ResponseFacade.java
@@ -133,7 +133,6 @@ public class ResponseFacade implements HttpServletResponse {
 
 // - Public Methods
 
-
 /**
  * Clear facade.
  */
@@ -146,90 +145,55 @@ public class ResponseFacade implements 
HttpServletResponse {
  * Prevent cloning the facade.
  */
 @Override
-protected Object clone()
-throws CloneNotSupportedException {
+protected Object clone() throws CloneNotSupportedException {
 throw new CloneNotSupportedException();
 }
 
 
 public void finish() {
-
-if (response == null) {
-throw new IllegalStateException(
-sm.getString("responseFacade.nullResponse"));
-}
-
+checkFacade();
 response.setSuspended(true);
 }
 
 
 public boolean isFinished() {
-
-if (response == null) {
-throw new IllegalStateException(
-sm.getString("responseFacade.nullResponse"));
-}
-
+checkFacade();
 return response.isSuspended();
 }
 
 
 public long getContentWritten() {
-
-if (response == null) {
-throw new IllegalStateException(
-sm.getString("responseFacade.nullResponse"));
-}
-
+checkFacade();
 return response.getContentWritten();
 }
 
-//  ServletResponse Methods
 
+//  ServletResponse Methods
 
 @Override
 public String getCharacterEncoding() {
-
-if (response == null) {
-throw new IllegalStateException(
-sm.getString("responseFacade.nullResponse"));
-}
-
+checkFacade();
 return response.getCharacterEncoding();
 }
 
 
 @Override
-public ServletOutputStream getOutputStream()
-throws IOException {
-
-//if (isFinished())
-//throw new IllegalStateException
-//(/*sm.getString("responseFacade.finished")*/);
-
+public ServletOutputStream getOutputStream() throws IOException {
 ServletOutputStream sos = response.getOutputStream();
 if (isFinished()) {
 response.setSuspended(true);
 }
 return sos;
-
 }
 
 
 @Override
-public PrintWriter getWriter()
-throws IOException {
-
-//if (isFinished())
-//throw new IllegalStateException
-//(/*sm.getString("responseFacade.finished")*/);
-
+public PrintWriter getWriter() throws IOException {
 PrintWriter writer = response.getWriter();
 if (isFinished()) {
 response.setSuspended(true);
 }
 return writer;
-
 }
 
 
@@ -253,7 +217,6 @@ public class ResponseFacade implements HttpServletResponse {
 
 @Override
 public void setContentType(String type) {
-
 if (isCommitted()) {
 return;
 }
@@ -268,32 +231,20 @@ public class ResponseFacade implements 
HttpServletResponse {
 
 @Override
 public void setBufferSize(int size) {
-
-if (isCommitted()) {
-throw new IllegalStateException
-(sm.getString("coyoteResponse.setBufferSize.ise"));
-}
-
+checkCommitted("coyoteResponse.setBufferSize.ise");
 response.setBufferSize(size);
-
 }
 
 
 @Override
 public int getBufferSize() {
-
-if (response == null) {
-throw new IllegalStateException(
-sm.getString("responseFacade.nullResponse"));
-}
-
+checkFacade();
 return response.getBufferSize();
 }
 
 
 @Override
 public void flushBuffer() throws IOException {
-
 if (isFinished()) {
 return;
 }
@@ -316,276 +267,179 @@ public class ResponseFacade implements 
HttpServletResponse {
 
 @Override
 public void resetBuffer() {
-
-if (isCommitted()) {
-throw new IllegalStateException
-(sm.getString("coyoteResponse.resetBuffer.ise"));
-}
-
+checkCommitted("coyoteResponse.resetBuffer.is

[tomcat] branch 9.0.x updated (de59d484db -> 1825ed0c8f)

2023-01-18 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 de59d484db Add missing "Not implemented" exception.
 new 20c4d5512e Refactor to reduce duplicate code
 new 5d4071b229 Add missing facade checks
 new 1825ed0c8f Refactor to reduce code duplication

The 3 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/catalina/connector/ResponseFacade.java  | 255 ++---
 .../apache/catalina/core/ApplicationContext.java   |  72 ++
 2 files changed, 86 insertions(+), 241 deletions(-)


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



[tomcat] 01/03: Refactor to reduce duplicate code

2023-01-18 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 4983c7ebf5fc542b712e159722a3ae46004a20b6
Author: Mark Thomas 
AuthorDate: Wed Jan 18 19:26:07 2023 +

Refactor to reduce duplicate code
---
 .../apache/catalina/connector/ResponseFacade.java  | 218 -
 1 file changed, 43 insertions(+), 175 deletions(-)

diff --git a/java/org/apache/catalina/connector/ResponseFacade.java 
b/java/org/apache/catalina/connector/ResponseFacade.java
index fa795660fa..1cc3e34501 100644
--- a/java/org/apache/catalina/connector/ResponseFacade.java
+++ b/java/org/apache/catalina/connector/ResponseFacade.java
@@ -132,7 +132,6 @@ public class ResponseFacade implements HttpServletResponse {
 
 // - Public Methods
 
-
 /**
  * Clear facade.
  */
@@ -145,90 +144,55 @@ public class ResponseFacade implements 
HttpServletResponse {
  * Prevent cloning the facade.
  */
 @Override
-protected Object clone()
-throws CloneNotSupportedException {
+protected Object clone() throws CloneNotSupportedException {
 throw new CloneNotSupportedException();
 }
 
 
 public void finish() {
-
-if (response == null) {
-throw new IllegalStateException(
-sm.getString("responseFacade.nullResponse"));
-}
-
+checkFacade();
 response.setSuspended(true);
 }
 
 
 public boolean isFinished() {
-
-if (response == null) {
-throw new IllegalStateException(
-sm.getString("responseFacade.nullResponse"));
-}
-
+checkFacade();
 return response.isSuspended();
 }
 
 
 public long getContentWritten() {
-
-if (response == null) {
-throw new IllegalStateException(
-sm.getString("responseFacade.nullResponse"));
-}
-
+checkFacade();
 return response.getContentWritten();
 }
 
-//  ServletResponse Methods
 
+//  ServletResponse Methods
 
 @Override
 public String getCharacterEncoding() {
-
-if (response == null) {
-throw new IllegalStateException(
-sm.getString("responseFacade.nullResponse"));
-}
-
+checkFacade();
 return response.getCharacterEncoding();
 }
 
 
 @Override
-public ServletOutputStream getOutputStream()
-throws IOException {
-
-//if (isFinished())
-//throw new IllegalStateException
-//(/*sm.getString("responseFacade.finished")*/);
-
+public ServletOutputStream getOutputStream() throws IOException {
 ServletOutputStream sos = response.getOutputStream();
 if (isFinished()) {
 response.setSuspended(true);
 }
 return sos;
-
 }
 
 
 @Override
-public PrintWriter getWriter()
-throws IOException {
-
-//if (isFinished())
-//throw new IllegalStateException
-//(/*sm.getString("responseFacade.finished")*/);
-
+public PrintWriter getWriter() throws IOException {
 PrintWriter writer = response.getWriter();
 if (isFinished()) {
 response.setSuspended(true);
 }
 return writer;
-
 }
 
 
@@ -252,7 +216,6 @@ public class ResponseFacade implements HttpServletResponse {
 
 @Override
 public void setContentType(String type) {
-
 if (isCommitted()) {
 return;
 }
@@ -267,32 +230,20 @@ public class ResponseFacade implements 
HttpServletResponse {
 
 @Override
 public void setBufferSize(int size) {
-
-if (isCommitted()) {
-throw new IllegalStateException
-(sm.getString("coyoteResponse.setBufferSize.ise"));
-}
-
+checkCommitted("coyoteResponse.setBufferSize.ise");
 response.setBufferSize(size);
-
 }
 
 
 @Override
 public int getBufferSize() {
-
-if (response == null) {
-throw new IllegalStateException(
-sm.getString("responseFacade.nullResponse"));
-}
-
+checkFacade();
 return response.getBufferSize();
 }
 
 
 @Override
 public void flushBuffer() throws IOException {
-
 if (isFinished()) {
 return;
 }
@@ -315,275 +266,178 @@ public class ResponseFacade implements 
HttpServletResponse {
 
 @Override
 public void resetBuffer() {
-
-if (isCommitted()) {
-throw new IllegalStateException
-(sm.getString("coyoteResponse.resetBuffer.ise"));
-}
-
+checkCommitted("coyoteResponse.resetBuffer.i

[tomcat] 03/03: Refactor to reduce code duplication

2023-01-18 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 81b91a42683ff72b8d15d0bdaf90a92fb41e3ef0
Author: Mark Thomas 
AuthorDate: Wed Jan 18 20:02:14 2023 +

Refactor to reduce code duplication
---
 .../apache/catalina/core/ApplicationContext.java   | 71 ++
 1 file changed, 18 insertions(+), 53 deletions(-)

diff --git a/java/org/apache/catalina/core/ApplicationContext.java 
b/java/org/apache/catalina/core/ApplicationContext.java
index 5cd5ad23a1..6a28ae8cdc 100644
--- a/java/org/apache/catalina/core/ApplicationContext.java
+++ b/java/org/apache/catalina/core/ApplicationContext.java
@@ -90,10 +90,8 @@ import org.apache.tomcat.util.res.StringManager;
  */
 public class ApplicationContext implements ServletContext {
 
-
 // --- Constructors
 
-
 /**
  * Construct a new instance of this class, associated with the specified
  * Context instance.
@@ -735,12 +733,8 @@ public class ApplicationContext implements ServletContext {
 "applicationContext.invalidFilterName", filterName));
 }
 
-if (!context.getState().equals(LifecycleState.STARTING_PREP)) {
-//TODO Spec breaking enhancement to ignore this restriction
-throw new IllegalStateException(
-sm.getString("applicationContext.addFilter.ise",
-getContextPath()));
-}
+// TODO Spec breaking enhancement to ignore this restriction
+checkState("applicationContext.addFilter.ise");
 
 FilterDef filterDef = context.findFilterDef(filterName);
 
@@ -856,12 +850,8 @@ public class ApplicationContext implements ServletContext {
 "applicationContext.invalidServletName", servletName));
 }
 
-if (!context.getState().equals(LifecycleState.STARTING_PREP)) {
-//TODO Spec breaking enhancement to ignore this restriction
-throw new IllegalStateException(
-sm.getString("applicationContext.addServlet.ise",
-getContextPath()));
-}
+// TODO Spec breaking enhancement to ignore this restriction
+checkState("applicationContext.addServlet.ise");
 
 Wrapper wrapper = (Wrapper) context.findChild(servletName);
 
@@ -986,11 +976,7 @@ public class ApplicationContext implements ServletContext {
 @Override
 public void setSessionTrackingModes(Set 
sessionTrackingModes) {
 
-if (!context.getState().equals(LifecycleState.STARTING_PREP)) {
-throw new IllegalStateException(
-sm.getString("applicationContext.setSessionTracking.ise",
-getContextPath()));
-}
+checkState("applicationContext.setSessionTracking.ise");
 
 // Check that only supported tracking modes have been requested
 for (SessionTrackingMode sessionTrackingMode : sessionTrackingModes) {
@@ -1020,12 +1006,7 @@ public class ApplicationContext implements 
ServletContext {
 if (name == null) {
 throw new 
NullPointerException(sm.getString("applicationContext.setAttribute.namenull"));
 }
-if (!context.getState().equals(LifecycleState.STARTING_PREP)) {
-throw new IllegalStateException(
-sm.getString("applicationContext.setInitParam.ise",
-getContextPath()));
-}
-
+checkState("applicationContext.setInitParam.ise");
 return parameters.putIfAbsent(name, value) == null;
 }
 
@@ -1076,11 +1057,7 @@ public class ApplicationContext implements 
ServletContext {
 
 @Override
 public  void addListener(T t) {
-if (!context.getState().equals(LifecycleState.STARTING_PREP)) {
-throw new IllegalStateException(
-sm.getString("applicationContext.addListener.ise",
-getContextPath()));
-}
+checkState("applicationContext.addListener.ise");
 
 boolean match = false;
 if (t instanceof ServletContextAttributeListener ||
@@ -1146,12 +1123,8 @@ public class ApplicationContext implements 
ServletContext {
 @Override
 public void declareRoles(String... roleNames) {
 
-if (!context.getState().equals(LifecycleState.STARTING_PREP)) {
-//TODO Spec breaking enhancement to ignore this restriction
-throw new IllegalStateException(
-sm.getString("applicationContext.addRole.ise",
-getContextPath()));
-}
+// TODO Spec breaking enhancement to ignore this restriction
+checkState("applicationContext.addRole.ise");
 
 if (roleNames == null) {
 throw new IllegalArgumentException(
@@ -1256,12 +1229,7 @@ public class ApplicationContext 

[tomcat] 02/03: Add missing facade checks

2023-01-18 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 7fb42ee701056ae3b6ebc561b5ded5a2bd6f4517
Author: Mark Thomas 
AuthorDate: Wed Jan 18 19:29:37 2023 +

Add missing facade checks
---
 .../apache/catalina/connector/ResponseFacade.java  | 23 +-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/java/org/apache/catalina/connector/ResponseFacade.java 
b/java/org/apache/catalina/connector/ResponseFacade.java
index 1cc3e34501..8d97f83db4 100644
--- a/java/org/apache/catalina/connector/ResponseFacade.java
+++ b/java/org/apache/catalina/connector/ResponseFacade.java
@@ -110,7 +110,6 @@ public class ResponseFacade implements HttpServletResponse {
  * @param response The response to be wrapped
  */
 public ResponseFacade(Response response) {
-
  this.response = response;
 }
 
@@ -178,6 +177,7 @@ public class ResponseFacade implements HttpServletResponse {
 
 @Override
 public ServletOutputStream getOutputStream() throws IOException {
+checkFacade();
 ServletOutputStream sos = response.getOutputStream();
 if (isFinished()) {
 response.setSuspended(true);
@@ -188,6 +188,7 @@ public class ResponseFacade implements HttpServletResponse {
 
 @Override
 public PrintWriter getWriter() throws IOException {
+checkFacade();
 PrintWriter writer = response.getWriter();
 if (isFinished()) {
 response.setSuspended(true);
@@ -198,6 +199,7 @@ public class ResponseFacade implements HttpServletResponse {
 
 @Override
 public void setContentLength(int len) {
+checkFacade();
 if (isCommitted()) {
 return;
 }
@@ -207,6 +209,7 @@ public class ResponseFacade implements HttpServletResponse {
 
 @Override
 public void setContentLengthLong(long length) {
+checkFacade();
 if (isCommitted()) {
 return;
 }
@@ -216,6 +219,7 @@ public class ResponseFacade implements HttpServletResponse {
 
 @Override
 public void setContentType(String type) {
+checkFacade();
 if (isCommitted()) {
 return;
 }
@@ -244,6 +248,7 @@ public class ResponseFacade implements HttpServletResponse {
 
 @Override
 public void flushBuffer() throws IOException {
+checkFacade();
 if (isFinished()) {
 return;
 }
@@ -287,6 +292,7 @@ public class ResponseFacade implements HttpServletResponse {
 
 @Override
 public void setLocale(Locale loc) {
+checkFacade();
 if (isCommitted()) {
 return;
 }
@@ -303,6 +309,7 @@ public class ResponseFacade implements HttpServletResponse {
 
 @Override
 public void addCookie(Cookie cookie) {
+checkFacade();
 if (isCommitted()) {
 return;
 }
@@ -357,6 +364,7 @@ public class ResponseFacade implements HttpServletResponse {
 
 @Override
 public void setDateHeader(String name, long date) {
+checkFacade();
 if (isCommitted()) {
 return;
 }
@@ -371,6 +379,7 @@ public class ResponseFacade implements HttpServletResponse {
 
 @Override
 public void addDateHeader(String name, long date) {
+checkFacade();
 if (isCommitted()) {
 return;
 }
@@ -385,6 +394,7 @@ public class ResponseFacade implements HttpServletResponse {
 
 @Override
 public void setHeader(String name, String value) {
+checkFacade();
 if (isCommitted()) {
 return;
 }
@@ -394,6 +404,7 @@ public class ResponseFacade implements HttpServletResponse {
 
 @Override
 public void addHeader(String name, String value) {
+checkFacade();
 if (isCommitted()) {
 return;
 }
@@ -403,6 +414,7 @@ public class ResponseFacade implements HttpServletResponse {
 
 @Override
 public void setIntHeader(String name, int value) {
+checkFacade();
 if (isCommitted()) {
 return;
 }
@@ -412,6 +424,7 @@ public class ResponseFacade implements HttpServletResponse {
 
 @Override
 public void addIntHeader(String name, int value) {
+checkFacade();
 if (isCommitted()) {
 return;
 }
@@ -421,6 +434,7 @@ public class ResponseFacade implements HttpServletResponse {
 
 @Override
 public void setStatus(int sc) {
+checkFacade();
 if (isCommitted()) {
 return;
 }
@@ -443,33 +457,39 @@ public class ResponseFacade implements 
HttpServletResponse {
 
 @Override
 public int getStatus() {
+checkFacade();
 return response.getStatus();
 }
 
 @Override
 public String getHeader(String name) {
+checkFacade();
 return response.getHeader(name);
 }
 
 @Override

[tomcat] branch 10.1.x updated (257125c5eb -> 81b91a4268)

2023-01-18 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 257125c5eb Add missing "Not implemented" exception.
 new 4983c7ebf5 Refactor to reduce duplicate code
 new 7fb42ee701 Add missing facade checks
 new 81b91a4268 Refactor to reduce code duplication

The 3 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/catalina/connector/ResponseFacade.java  | 241 ++---
 .../apache/catalina/core/ApplicationContext.java   |  71 ++
 2 files changed, 83 insertions(+), 229 deletions(-)


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



[tomcat] 03/06: Refactor to reduce duplicate code

2023-01-18 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 254ca3dc91f73c56f2e1f296424335cf3ae762d7
Author: Mark Thomas 
AuthorDate: Wed Jan 18 19:26:07 2023 +

Refactor to reduce duplicate code
---
 .../apache/catalina/connector/ResponseFacade.java  | 208 -
 1 file changed, 39 insertions(+), 169 deletions(-)

diff --git a/java/org/apache/catalina/connector/ResponseFacade.java 
b/java/org/apache/catalina/connector/ResponseFacade.java
index 48d6ea5dc2..aaff23b62b 100644
--- a/java/org/apache/catalina/connector/ResponseFacade.java
+++ b/java/org/apache/catalina/connector/ResponseFacade.java
@@ -66,7 +66,6 @@ public class ResponseFacade implements HttpServletResponse {
 
 // - Public Methods
 
-
 /**
  * Clear facade.
  */
@@ -79,90 +78,55 @@ public class ResponseFacade implements HttpServletResponse {
  * Prevent cloning the facade.
  */
 @Override
-protected Object clone()
-throws CloneNotSupportedException {
+protected Object clone() throws CloneNotSupportedException {
 throw new CloneNotSupportedException();
 }
 
 
 public void finish() {
-
-if (response == null) {
-throw new IllegalStateException(
-sm.getString("responseFacade.nullResponse"));
-}
-
+checkFacade();
 response.setSuspended(true);
 }
 
 
 public boolean isFinished() {
-
-if (response == null) {
-throw new IllegalStateException(
-sm.getString("responseFacade.nullResponse"));
-}
-
+checkFacade();
 return response.isSuspended();
 }
 
 
 public long getContentWritten() {
-
-if (response == null) {
-throw new IllegalStateException(
-sm.getString("responseFacade.nullResponse"));
-}
-
+checkFacade();
 return response.getContentWritten();
 }
 
-//  ServletResponse Methods
 
+//  ServletResponse Methods
 
 @Override
 public String getCharacterEncoding() {
-
-if (response == null) {
-throw new IllegalStateException(
-sm.getString("responseFacade.nullResponse"));
-}
-
+checkFacade();
 return response.getCharacterEncoding();
 }
 
 
 @Override
-public ServletOutputStream getOutputStream()
-throws IOException {
-
-//if (isFinished())
-//throw new IllegalStateException
-//(/*sm.getString("responseFacade.finished")*/);
-
+public ServletOutputStream getOutputStream() throws IOException {
 ServletOutputStream sos = response.getOutputStream();
 if (isFinished()) {
 response.setSuspended(true);
 }
 return sos;
-
 }
 
 
 @Override
-public PrintWriter getWriter()
-throws IOException {
-
-//if (isFinished())
-//throw new IllegalStateException
-//(/*sm.getString("responseFacade.finished")*/);
-
+public PrintWriter getWriter() throws IOException {
 PrintWriter writer = response.getWriter();
 if (isFinished()) {
 response.setSuspended(true);
 }
 return writer;
-
 }
 
 
@@ -186,7 +150,6 @@ public class ResponseFacade implements HttpServletResponse {
 
 @Override
 public void setContentType(String type) {
-
 if (isCommitted()) {
 return;
 }
@@ -196,32 +159,20 @@ public class ResponseFacade implements 
HttpServletResponse {
 
 @Override
 public void setBufferSize(int size) {
-
-if (isCommitted()) {
-throw new IllegalStateException
-(sm.getString("coyoteResponse.setBufferSize.ise"));
-}
-
+checkCommitted("coyoteResponse.setBufferSize.ise");
 response.setBufferSize(size);
-
 }
 
 
 @Override
 public int getBufferSize() {
-
-if (response == null) {
-throw new IllegalStateException(
-sm.getString("responseFacade.nullResponse"));
-}
-
+checkFacade();
 return response.getBufferSize();
 }
 
 
 @Override
 public void flushBuffer() throws IOException {
-
 if (isFinished()) {
 return;
 }
@@ -233,263 +184,168 @@ public class ResponseFacade implements 
HttpServletResponse {
 
 @Override
 public void resetBuffer() {
-
-if (isCommitted()) {
-throw new IllegalStateException
-(sm.getString("coyoteResponse.resetBuffer.ise"));
-}
-
+checkCommitted("coyoteResponse.resetBuffer.ise");
 

[tomcat] 05/06: Refactor to reduce code duplication

2023-01-18 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 1bfffde19c0bfd25321580d8d98b48f9a4d942ed
Author: Mark Thomas 
AuthorDate: Wed Jan 18 20:02:14 2023 +

Refactor to reduce code duplication
---
 .../apache/catalina/core/ApplicationContext.java   | 71 ++
 1 file changed, 18 insertions(+), 53 deletions(-)

diff --git a/java/org/apache/catalina/core/ApplicationContext.java 
b/java/org/apache/catalina/core/ApplicationContext.java
index e43d7c6343..c91a62392d 100644
--- a/java/org/apache/catalina/core/ApplicationContext.java
+++ b/java/org/apache/catalina/core/ApplicationContext.java
@@ -90,10 +90,8 @@ import org.apache.tomcat.util.res.StringManager;
  */
 public class ApplicationContext implements ServletContext {
 
-
 // --- Constructors
 
-
 /**
  * Construct a new instance of this class, associated with the specified
  * Context instance.
@@ -735,12 +733,8 @@ public class ApplicationContext implements ServletContext {
 "applicationContext.invalidFilterName", filterName));
 }
 
-if (!context.getState().equals(LifecycleState.STARTING_PREP)) {
-//TODO Spec breaking enhancement to ignore this restriction
-throw new IllegalStateException(
-sm.getString("applicationContext.addFilter.ise",
-getContextPath()));
-}
+// TODO Spec breaking enhancement to ignore this restriction
+checkState("applicationContext.addFilter.ise");
 
 FilterDef filterDef = context.findFilterDef(filterName);
 
@@ -856,12 +850,8 @@ public class ApplicationContext implements ServletContext {
 "applicationContext.invalidServletName", servletName));
 }
 
-if (!context.getState().equals(LifecycleState.STARTING_PREP)) {
-//TODO Spec breaking enhancement to ignore this restriction
-throw new IllegalStateException(
-sm.getString("applicationContext.addServlet.ise",
-getContextPath()));
-}
+// TODO Spec breaking enhancement to ignore this restriction
+checkState("applicationContext.addServlet.ise");
 
 Wrapper wrapper = (Wrapper) context.findChild(servletName);
 
@@ -986,11 +976,7 @@ public class ApplicationContext implements ServletContext {
 @Override
 public void setSessionTrackingModes(Set 
sessionTrackingModes) {
 
-if (!context.getState().equals(LifecycleState.STARTING_PREP)) {
-throw new IllegalStateException(
-sm.getString("applicationContext.setSessionTracking.ise",
-getContextPath()));
-}
+checkState("applicationContext.setSessionTracking.ise");
 
 // Check that only supported tracking modes have been requested
 for (SessionTrackingMode sessionTrackingMode : sessionTrackingModes) {
@@ -1020,12 +1006,7 @@ public class ApplicationContext implements 
ServletContext {
 if (name == null) {
 throw new 
NullPointerException(sm.getString("applicationContext.setAttribute.namenull"));
 }
-if (!context.getState().equals(LifecycleState.STARTING_PREP)) {
-throw new IllegalStateException(
-sm.getString("applicationContext.setInitParam.ise",
-getContextPath()));
-}
-
+checkState("applicationContext.setInitParam.ise");
 return parameters.putIfAbsent(name, value) == null;
 }
 
@@ -1076,11 +1057,7 @@ public class ApplicationContext implements 
ServletContext {
 
 @Override
 public  void addListener(T t) {
-if (!context.getState().equals(LifecycleState.STARTING_PREP)) {
-throw new IllegalStateException(
-sm.getString("applicationContext.addListener.ise",
-getContextPath()));
-}
+checkState("applicationContext.addListener.ise");
 
 boolean match = false;
 if (t instanceof ServletContextAttributeListener ||
@@ -1146,12 +1123,8 @@ public class ApplicationContext implements 
ServletContext {
 @Override
 public void declareRoles(String... roleNames) {
 
-if (!context.getState().equals(LifecycleState.STARTING_PREP)) {
-//TODO Spec breaking enhancement to ignore this restriction
-throw new IllegalStateException(
-sm.getString("applicationContext.addRole.ise",
-getContextPath()));
-}
+// TODO Spec breaking enhancement to ignore this restriction
+checkState("applicationContext.addRole.ise");
 
 if (roleNames == null) {
 throw new IllegalArgumentException(
@@ -1240,12 +1213,7 @@ public class ApplicationContext im

[tomcat] 06/06: Refactor so CoyoteResponse only uses CharsetHolder

2023-01-18 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 3944507b61e4db7aab588793cefef167ddce452a
Author: Mark Thomas 
AuthorDate: Wed Jan 18 20:05:16 2023 +

Refactor so CoyoteResponse only uses CharsetHolder
---
 .../apache/catalina/connector/OutputBuffer.java| 13 ++--
 java/org/apache/catalina/connector/Response.java   | 76 ++
 .../apache/catalina/connector/ResponseFacade.java  | 11 +++-
 java/org/apache/coyote/Response.java   | 26 
 4 files changed, 89 insertions(+), 37 deletions(-)

diff --git a/java/org/apache/catalina/connector/OutputBuffer.java 
b/java/org/apache/catalina/connector/OutputBuffer.java
index e3fd2b705c..cba68cee37 100644
--- a/java/org/apache/catalina/connector/OutputBuffer.java
+++ b/java/org/apache/catalina/connector/OutputBuffer.java
@@ -31,8 +31,8 @@ import jakarta.servlet.http.HttpServletResponse;
 import org.apache.coyote.ActionCode;
 import org.apache.coyote.CloseNowException;
 import org.apache.coyote.Response;
-import org.apache.tomcat.util.buf.B2CConverter;
 import org.apache.tomcat.util.buf.C2BConverter;
+import org.apache.tomcat.util.buf.CharsetHolder;
 import org.apache.tomcat.util.res.StringManager;
 
 /**
@@ -551,15 +551,14 @@ public class OutputBuffer extends Writer {
 Charset charset = null;
 
 if (coyoteResponse != null) {
-charset = coyoteResponse.getCharset();
+CharsetHolder charsetHolder = coyoteResponse.getCharsetHolder();
+// setCharacterEncoding() was called with an invalid character set
+// Trigger an UnsupportedEncodingException
+charsetHolder.validate();
+charset = charsetHolder.getCharset();
 }
 
 if (charset == null) {
-if (coyoteResponse.getCharacterEncoding() != null) {
-// setCharacterEncoding() was called with an invalid character 
set
-// Trigger an UnsupportedEncodingException
-charset = 
B2CConverter.getCharset(coyoteResponse.getCharacterEncoding());
-}
 charset = org.apache.coyote.Constants.DEFAULT_BODY_CHARSET;
 }
 
diff --git a/java/org/apache/catalina/connector/Response.java 
b/java/org/apache/catalina/connector/Response.java
index 38ddd83640..6c47a21f40 100644
--- a/java/org/apache/catalina/connector/Response.java
+++ b/java/org/apache/catalina/connector/Response.java
@@ -50,6 +50,7 @@ import org.apache.coyote.ContinueResponseTiming;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
 import org.apache.tomcat.util.buf.CharChunk;
+import org.apache.tomcat.util.buf.CharsetHolder;
 import org.apache.tomcat.util.buf.UEncoder;
 import org.apache.tomcat.util.buf.UEncoder.SafeCharsSet;
 import org.apache.tomcat.util.buf.UriUtil;
@@ -486,22 +487,19 @@ public class Response implements HttpServletResponse {
  */
 @Override
 public String getCharacterEncoding() {
-String charset = getCoyoteResponse().getCharacterEncoding();
-if (charset != null) {
-return charset;
-}
-
-Context context = getContext();
-String result = null;
-if (context != null) {
-result =  context.getResponseCharacterEncoding();
+String charset = getCoyoteResponse().getCharsetHolder().getName();
+if (charset == null) {
+Context context = getContext();
+if (context != null) {
+charset = context.getResponseCharacterEncoding();
+}
 }
 
-if (result == null) {
-result = org.apache.coyote.Constants.DEFAULT_BODY_CHARSET.name();
+if (charset == null) {
+charset = org.apache.coyote.Constants.DEFAULT_BODY_CHARSET.name();
 }
 
-return result;
+return charset;
 }
 
 
@@ -720,11 +718,7 @@ public class Response implements HttpServletResponse {
 
 if (type == null) {
 getCoyoteResponse().setContentType(null);
-try {
-getCoyoteResponse().setCharacterEncoding(null);
-} catch (UnsupportedEncodingException e) {
-// Can never happen when calling with null
-}
+getCoyoteResponse().setCharsetHolder(CharsetHolder.EMPTY);
 isCharacterEncodingSet = false;
 return;
 }
@@ -750,8 +744,9 @@ public class Response implements HttpServletResponse {
 
 // Ignore charset if getWriter() has already been called
 if (!usingWriter) {
+
getCoyoteResponse().setCharsetHolder(CharsetHolder.getInstance(m[1]));
 try {
-getCoyoteResponse().setCharacterEncoding(m[1]);
+getCoyoteResponse().getCharsetHolder().validate();
 } catch (UnsupportedEncodingException e) {

[tomcat] 02/06: Refactor CoyoteRequest to only use CharsetHolder

2023-01-18 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 76e3fe20dd8a38220f703214a5455d63878e8ac4
Author: Mark Thomas 
AuthorDate: Wed Jan 18 19:15:52 2023 +

Refactor CoyoteRequest to only use CharsetHolder
---
 .../org/apache/catalina/connector/InputBuffer.java |  2 +-
 java/org/apache/catalina/connector/Request.java| 55 +-
 .../catalina/ssi/SSIServletExternalResolver.java   |  7 +--
 java/org/apache/coyote/Request.java| 27 +++
 4 files changed, 52 insertions(+), 39 deletions(-)

diff --git a/java/org/apache/catalina/connector/InputBuffer.java 
b/java/org/apache/catalina/connector/InputBuffer.java
index d193775a2b..4512a8c0be 100644
--- a/java/org/apache/catalina/connector/InputBuffer.java
+++ b/java/org/apache/catalina/connector/InputBuffer.java
@@ -536,7 +536,7 @@ public class InputBuffer extends Reader
 
 Charset charset = null;
 if (coyoteRequest != null) {
-charset = coyoteRequest.getCharset();
+charset = coyoteRequest.getCharsetHolder().getValidatedCharset();
 }
 
 if (charset == null) {
diff --git a/java/org/apache/catalina/connector/Request.java 
b/java/org/apache/catalina/connector/Request.java
index bb3d1897d9..b943bfe0e8 100644
--- a/java/org/apache/catalina/connector/Request.java
+++ b/java/org/apache/catalina/connector/Request.java
@@ -95,6 +95,7 @@ import org.apache.tomcat.InstanceManager;
 import org.apache.tomcat.util.ExceptionUtils;
 import org.apache.tomcat.util.buf.B2CConverter;
 import org.apache.tomcat.util.buf.ByteChunk;
+import org.apache.tomcat.util.buf.CharsetHolder;
 import org.apache.tomcat.util.buf.EncodedSolidusHandling;
 import org.apache.tomcat.util.buf.MessageBytes;
 import org.apache.tomcat.util.buf.StringUtils;
@@ -958,44 +959,34 @@ public class Request implements HttpServletRequest {
  */
 @Override
 public String getCharacterEncoding() {
-String characterEncoding = coyoteRequest.getCharacterEncoding();
-if (characterEncoding != null) {
-return characterEncoding;
-}
+String characterEncoding = coyoteRequest.getCharsetHolder().getName();
 
-Context context = getContext();
-if (context != null) {
-return context.getRequestCharacterEncoding();
+if (characterEncoding == null) {
+Context context = getContext();
+if (context != null) {
+characterEncoding = context.getRequestCharacterEncoding();
+}
 }
 
-return null;
+return characterEncoding;
 }
 
 
 private Charset getCharset() {
-Charset charset = null;
-try {
-charset = coyoteRequest.getCharset();
-} catch (UnsupportedEncodingException e) {
-// Ignore
-}
-if (charset != null) {
-return charset;
-}
+Charset charset = coyoteRequest.getCharsetHolder().getCharset();
 
-Context context = getContext();
-if (context != null) {
-String encoding = context.getRequestCharacterEncoding();
-if (encoding != null) {
-try {
-return B2CConverter.getCharset(encoding);
-} catch (UnsupportedEncodingException e) {
-// Ignore
-}
+if (charset == null) {
+Context context = getContext();
+if (context != null) {
+charset = 
CharsetHolder.getInstance(context.getRequestCharacterEncoding()).getCharset() ;
 }
 }
 
-return org.apache.coyote.Constants.DEFAULT_BODY_CHARSET;
+if (charset == null) {
+charset = org.apache.coyote.Constants.DEFAULT_BODY_CHARSET;
+}
+
+return charset;
 }
 
 
@@ -1209,7 +1200,7 @@ public class Request implements HttpServletRequest {
 // to check for a default request character encoding at the Context.
 // Therefore, if a Context default should be used, it is set explicitly
 // here. Need to do this before setting usingReader.
-if (coyoteRequest.getCharacterEncoding() == null) {
+if (coyoteRequest.getCharsetHolder().getName() == null) {
 // Nothing currently set explicitly.
 // Check the context
 Context context = getContext();
@@ -1612,11 +1603,11 @@ public class Request implements HttpServletRequest {
 return;
 }
 
-// Confirm that the encoding name is valid
-Charset charset = B2CConverter.getCharset(enc);
+CharsetHolder charsetHolder = CharsetHolder.getInstance(enc);
+charsetHolder.validate();
 
 // Save the validated encoding
-coyoteRequest.setCharset(charset);
+coyoteRequest.setCharsetHolder(charsetHolder);
 }
 
 
@@ -1628,7 +1619,7 @@ public c

[tomcat] branch main updated (492bedc6f9 -> 3944507b61)

2023-01-18 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 492bedc6f9 Add missing "Not implemented" exception.
 new 6c4de89924 Override the default implementation where it makes sense to 
do so
 new 76e3fe20dd Refactor CoyoteRequest to only use CharsetHolder
 new 254ca3dc91 Refactor to reduce duplicate code
 new dd098521b3 Add missing facade checks
 new 1bfffde19c Refactor to reduce code duplication
 new 3944507b61 Refactor so CoyoteResponse only uses CharsetHolder

The 6 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:
 .../org/apache/catalina/connector/InputBuffer.java |   2 +-
 .../apache/catalina/connector/OutputBuffer.java|  13 +-
 java/org/apache/catalina/connector/Request.java|  65 +++---
 .../apache/catalina/connector/RequestFacade.java   |  12 +-
 java/org/apache/catalina/connector/Response.java   |  76 ---
 .../apache/catalina/connector/ResponseFacade.java  | 241 ++---
 .../apache/catalina/core/ApplicationContext.java   |  71 ++
 .../catalina/ssi/SSIServletExternalResolver.java   |   7 +-
 java/org/apache/coyote/Request.java|  27 +++
 java/org/apache/coyote/Response.java   |  26 +++
 10 files changed, 240 insertions(+), 300 deletions(-)


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



[tomcat] 04/06: Add missing facade checks

2023-01-18 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 dd098521b31216aca8b2807c01962ca179d2e364
Author: Mark Thomas 
AuthorDate: Wed Jan 18 19:29:37 2023 +

Add missing facade checks
---
 .../apache/catalina/connector/ResponseFacade.java  | 24 --
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/catalina/connector/ResponseFacade.java 
b/java/org/apache/catalina/connector/ResponseFacade.java
index aaff23b62b..a6adbb5851 100644
--- a/java/org/apache/catalina/connector/ResponseFacade.java
+++ b/java/org/apache/catalina/connector/ResponseFacade.java
@@ -45,7 +45,6 @@ public class ResponseFacade implements HttpServletResponse {
  * @param response The response to be wrapped
  */
 public ResponseFacade(Response response) {
-
  this.response = response;
 }
 
@@ -112,6 +111,7 @@ public class ResponseFacade implements HttpServletResponse {
 
 @Override
 public ServletOutputStream getOutputStream() throws IOException {
+checkFacade();
 ServletOutputStream sos = response.getOutputStream();
 if (isFinished()) {
 response.setSuspended(true);
@@ -122,6 +122,7 @@ public class ResponseFacade implements HttpServletResponse {
 
 @Override
 public PrintWriter getWriter() throws IOException {
+checkFacade();
 PrintWriter writer = response.getWriter();
 if (isFinished()) {
 response.setSuspended(true);
@@ -132,6 +133,7 @@ public class ResponseFacade implements HttpServletResponse {
 
 @Override
 public void setContentLength(int len) {
+checkFacade();
 if (isCommitted()) {
 return;
 }
@@ -141,6 +143,7 @@ public class ResponseFacade implements HttpServletResponse {
 
 @Override
 public void setContentLengthLong(long length) {
+checkFacade();
 if (isCommitted()) {
 return;
 }
@@ -150,6 +153,7 @@ public class ResponseFacade implements HttpServletResponse {
 
 @Override
 public void setContentType(String type) {
+checkFacade();
 if (isCommitted()) {
 return;
 }
@@ -173,10 +177,10 @@ public class ResponseFacade implements 
HttpServletResponse {
 
 @Override
 public void flushBuffer() throws IOException {
+checkFacade();
 if (isFinished()) {
 return;
 }
-
 response.setAppCommitted(true);
 response.flushBuffer();
 }
@@ -205,6 +209,7 @@ public class ResponseFacade implements HttpServletResponse {
 
 @Override
 public void setLocale(Locale loc) {
+checkFacade();
 if (isCommitted()) {
 return;
 }
@@ -221,6 +226,7 @@ public class ResponseFacade implements HttpServletResponse {
 
 @Override
 public void addCookie(Cookie cookie) {
+checkFacade();
 if (isCommitted()) {
 return;
 }
@@ -275,6 +281,7 @@ public class ResponseFacade implements HttpServletResponse {
 
 @Override
 public void setDateHeader(String name, long date) {
+checkFacade();
 if (isCommitted()) {
 return;
 }
@@ -284,6 +291,7 @@ public class ResponseFacade implements HttpServletResponse {
 
 @Override
 public void addDateHeader(String name, long date) {
+checkFacade();
 if (isCommitted()) {
 return;
 }
@@ -293,6 +301,7 @@ public class ResponseFacade implements HttpServletResponse {
 
 @Override
 public void setHeader(String name, String value) {
+checkFacade();
 if (isCommitted()) {
 return;
 }
@@ -302,6 +311,7 @@ public class ResponseFacade implements HttpServletResponse {
 
 @Override
 public void addHeader(String name, String value) {
+checkFacade();
 if (isCommitted()) {
 return;
 }
@@ -311,6 +321,7 @@ public class ResponseFacade implements HttpServletResponse {
 
 @Override
 public void setIntHeader(String name, int value) {
+checkFacade();
 if (isCommitted()) {
 return;
 }
@@ -320,6 +331,7 @@ public class ResponseFacade implements HttpServletResponse {
 
 @Override
 public void addIntHeader(String name, int value) {
+checkFacade();
 if (isCommitted()) {
 return;
 }
@@ -329,6 +341,7 @@ public class ResponseFacade implements HttpServletResponse {
 
 @Override
 public void setStatus(int sc) {
+checkFacade();
 if (isCommitted()) {
 return;
 }
@@ -351,33 +364,39 @@ public class ResponseFacade implements 
HttpServletResponse {
 
 @Override
 public int getStatus() {
+checkFacade();
 return response.getStatus();
 }
 
 @Override
 public String getHeader(String name) {
+ch

[tomcat] 01/06: Override the default implementation where it makes sense to do so

2023-01-18 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 6c4de89924457956589d60d922d3766afc31896d
Author: Mark Thomas 
AuthorDate: Wed Jan 18 18:51:57 2023 +

Override the default implementation where it makes sense to do so

Just for HttpServletRequest.setCharacterEncoding(Charset)
---
 java/org/apache/catalina/connector/Request.java   | 12 
 java/org/apache/catalina/connector/RequestFacade.java | 12 ++--
 2 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/catalina/connector/Request.java 
b/java/org/apache/catalina/connector/Request.java
index 9dfd6725b6..bb3d1897d9 100644
--- a/java/org/apache/catalina/connector/Request.java
+++ b/java/org/apache/catalina/connector/Request.java
@@ -1620,6 +1620,18 @@ public class Request implements HttpServletRequest {
 }
 
 
+@Override
+public void setCharacterEncoding(Charset charset) {
+
+if (usingReader) {
+return;
+}
+
+// Save the validated encoding
+coyoteRequest.setCharset(charset);
+}
+
+
 @Override
 public ServletContext getServletContext() {
 return getContext().getServletContext();
diff --git a/java/org/apache/catalina/connector/RequestFacade.java 
b/java/org/apache/catalina/connector/RequestFacade.java
index 4b8540dc1d..382dda04ba 100644
--- a/java/org/apache/catalina/connector/RequestFacade.java
+++ b/java/org/apache/catalina/connector/RequestFacade.java
@@ -18,6 +18,7 @@ package org.apache.catalina.connector;
 
 import java.io.BufferedReader;
 import java.io.IOException;
+import java.nio.charset.Charset;
 import java.util.Collection;
 import java.util.Enumeration;
 import java.util.Locale;
@@ -114,9 +115,16 @@ public class RequestFacade implements HttpServletRequest {
 
 
 @Override
-public void setCharacterEncoding(String env) throws 
java.io.UnsupportedEncodingException {
+public void setCharacterEncoding(String encoding) throws 
java.io.UnsupportedEncodingException {
 checkFacade();
-request.setCharacterEncoding(env);
+request.setCharacterEncoding(encoding);
+}
+
+
+@Override
+public void setCharacterEncoding(Charset encoding) {
+checkFacade();
+request.setCharacterEncoding(encoding);
 }
 
 


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



Buildbot success in on tomcat-11.0.x

2023-01-18 Thread buildbot
Build status: Build succeeded!
Worker used: bb2_worker2_ubuntu
URL: https://ci2.apache.org/#builders/112/builds/131
Blamelist: Mark Thomas 
Build Text: build successful
Status Detected: restored build
Build Source Stamp: [branch main] 492bedc6f92bb000ac29953d04b21a33181e5a1b


Steps:

  worker_preparation: 0

  git: 0

  shell: 0

  shell_1: 0

  shell_2: 0

  shell_3: 0

  shell_4: 0

  shell_5: 0

  compile: 1

  shell_6: 0

  shell_7: 0

  shell_8: 0

  shell_9: 0

  Rsync docs to nightlies.apache.org: 0

  shell_10: 0

  Rsync RAT to nightlies.apache.org: 0

  compile_1: 1

  shell_11: 0

  Rsync Logs to nightlies.apache.org: 0


-- ASF Buildbot


-
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: Add missing "Not implemented" exception.

2023-01-18 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


The following commit(s) were added to refs/heads/8.5.x by this push:
 new c8ffc35997 Add missing "Not implemented" exception.
c8ffc35997 is described below

commit c8ffc359972acc9bfbf3c1300b9055bbb0c41ccf
Author: Mark Thomas 
AuthorDate: Wed Jan 18 18:11:29 2023 +

Add missing "Not implemented" exception.
---
 test/org/apache/catalina/filters/TesterHttpServletRequest.java | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/test/org/apache/catalina/filters/TesterHttpServletRequest.java 
b/test/org/apache/catalina/filters/TesterHttpServletRequest.java
index d486519f48..79b4237376 100644
--- a/test/org/apache/catalina/filters/TesterHttpServletRequest.java
+++ b/test/org/apache/catalina/filters/TesterHttpServletRequest.java
@@ -72,8 +72,8 @@ public class TesterHttpServletRequest implements 
HttpServletRequest {
 }
 
 @Override
-public void setCharacterEncoding(String env)
-throws UnsupportedEncodingException {
+public void setCharacterEncoding(String env) throws 
UnsupportedEncodingException {
+throw new RuntimeException("Not implemented");
 }
 
 @Override


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



[tomcat] branch 9.0.x updated: Add missing "Not implemented" exception.

2023-01-18 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


The following commit(s) were added to refs/heads/9.0.x by this push:
 new de59d484db Add missing "Not implemented" exception.
de59d484db is described below

commit de59d484db51403f8d93d90c31a614a70b952803
Author: Mark Thomas 
AuthorDate: Wed Jan 18 18:11:29 2023 +

Add missing "Not implemented" exception.
---
 test/org/apache/catalina/filters/TesterHttpServletRequest.java | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/test/org/apache/catalina/filters/TesterHttpServletRequest.java 
b/test/org/apache/catalina/filters/TesterHttpServletRequest.java
index 1995a998c8..58dc4ed29e 100644
--- a/test/org/apache/catalina/filters/TesterHttpServletRequest.java
+++ b/test/org/apache/catalina/filters/TesterHttpServletRequest.java
@@ -72,8 +72,8 @@ public class TesterHttpServletRequest implements 
HttpServletRequest {
 }
 
 @Override
-public void setCharacterEncoding(String env)
-throws UnsupportedEncodingException {
+public void setCharacterEncoding(String env) throws 
UnsupportedEncodingException {
+throw new RuntimeException("Not implemented");
 }
 
 @Override


-
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: Add missing "Not implemented" exception.

2023-01-18 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


The following commit(s) were added to refs/heads/10.1.x by this push:
 new 257125c5eb Add missing "Not implemented" exception.
257125c5eb is described below

commit 257125c5ebead528993d30c2f8c123b045483a51
Author: Mark Thomas 
AuthorDate: Wed Jan 18 18:11:29 2023 +

Add missing "Not implemented" exception.
---
 test/org/apache/catalina/filters/TesterHttpServletRequest.java | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/test/org/apache/catalina/filters/TesterHttpServletRequest.java 
b/test/org/apache/catalina/filters/TesterHttpServletRequest.java
index 1e733c8caf..e4350e1d89 100644
--- a/test/org/apache/catalina/filters/TesterHttpServletRequest.java
+++ b/test/org/apache/catalina/filters/TesterHttpServletRequest.java
@@ -73,8 +73,8 @@ public class TesterHttpServletRequest implements 
HttpServletRequest {
 }
 
 @Override
-public void setCharacterEncoding(String env)
-throws UnsupportedEncodingException {
+public void setCharacterEncoding(String env) throws 
UnsupportedEncodingException {
+throw new RuntimeException("Not implemented");
 }
 
 @Override


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



[tomcat] 01/02: Refactor to retain original behaviour

2023-01-18 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 3cdfd45e5049a23a0414ab53e5f7f952243e5018
Author: Mark Thomas 
AuthorDate: Wed Jan 18 18:10:00 2023 +

Refactor to retain original behaviour

Setting an invalid encoding should still set the encoding name
---
 java/org/apache/coyote/Response.java   |  6 --
 java/org/apache/tomcat/util/buf/CharsetHolder.java | 23 --
 2 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/java/org/apache/coyote/Response.java 
b/java/org/apache/coyote/Response.java
index f5fb215c22..1c9008765b 100644
--- a/java/org/apache/coyote/Response.java
+++ b/java/org/apache/coyote/Response.java
@@ -502,7 +502,8 @@ public final class Response {
 return;
 }
 
-charsetHolder = CharsetHolder.getValidatedInstance(characterEncoding);
+charsetHolder = CharsetHolder.getInstance(characterEncoding);
+charsetHolder.validate();
 }
 
 
@@ -562,8 +563,9 @@ public final class Response {
 this.contentType = m.toStringNoCharset();
 charsetValue = charsetValue.trim();
 if (charsetValue.length() > 0) {
+charsetHolder = CharsetHolder.getInstance(charsetValue);
 try {
-charsetHolder = 
CharsetHolder.getValidatedInstance(charsetValue);
+charsetHolder.validate();
 } catch (UnsupportedEncodingException e) {
 log.warn(sm.getString("response.encoding.invalid", 
charsetValue), e);
 }
diff --git a/java/org/apache/tomcat/util/buf/CharsetHolder.java 
b/java/org/apache/tomcat/util/buf/CharsetHolder.java
index da0f912565..953925ce13 100755
--- a/java/org/apache/tomcat/util/buf/CharsetHolder.java
+++ b/java/org/apache/tomcat/util/buf/CharsetHolder.java
@@ -51,15 +51,6 @@ public class CharsetHolder {
 }
 
 
-public static CharsetHolder getValidatedInstance(String name) throws 
UnsupportedEncodingException {
-if (name == null) {
-return EMPTY;
-}
-
-return new CharsetHolder(name, B2CConverter.getCharset(name));
-}
-
-
 public static CharsetHolder getInstance(Charset encoding) {
 if (encoding == null) {
 return EMPTY;
@@ -105,9 +96,21 @@ public class CharsetHolder {
  * name of a Charset that the JRE does not recognise
  */
 public Charset getValidatedCharset() throws UnsupportedEncodingException {
+validate();
+return charset;
+}
+
+
+/**
+ * Throws an exception if the instance holds a name that without a matching
+ * Charset.
+ *
+ * @throws UnsupportedEncodingException if the holder contains a name
+ * without a matching Charset
+ */
+public void validate() throws UnsupportedEncodingException {
 if (name != null && charset == null) {
 throw new UnsupportedEncodingException(name);
 }
-return charset;
 }
 }


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



[tomcat] 02/02: Add missing "Not implemented" exception.

2023-01-18 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 492bedc6f92bb000ac29953d04b21a33181e5a1b
Author: Mark Thomas 
AuthorDate: Wed Jan 18 18:11:29 2023 +

Add missing "Not implemented" exception.
---
 test/org/apache/catalina/filters/TesterHttpServletRequest.java | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/test/org/apache/catalina/filters/TesterHttpServletRequest.java 
b/test/org/apache/catalina/filters/TesterHttpServletRequest.java
index 1e733c8caf..e4350e1d89 100644
--- a/test/org/apache/catalina/filters/TesterHttpServletRequest.java
+++ b/test/org/apache/catalina/filters/TesterHttpServletRequest.java
@@ -73,8 +73,8 @@ public class TesterHttpServletRequest implements 
HttpServletRequest {
 }
 
 @Override
-public void setCharacterEncoding(String env)
-throws UnsupportedEncodingException {
+public void setCharacterEncoding(String env) throws 
UnsupportedEncodingException {
+throw new RuntimeException("Not implemented");
 }
 
 @Override


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



[tomcat] branch main updated (021b1696b3 -> 492bedc6f9)

2023-01-18 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 021b1696b3 Refactor storage of current character encoding for 
request/response
 new 3cdfd45e50 Refactor to retain original behaviour
 new 492bedc6f9 Add missing "Not implemented" exception.

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/Response.java   |  6 --
 java/org/apache/tomcat/util/buf/CharsetHolder.java | 23 --
 .../catalina/filters/TesterHttpServletRequest.java |  4 ++--
 3 files changed, 19 insertions(+), 14 deletions(-)


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



Buildbot failure in on tomcat-11.0.x

2023-01-18 Thread buildbot
Build status: BUILD FAILED: failed compile (failure)
Worker used: bb2_worker2_ubuntu
URL: https://ci2.apache.org/#builders/112/builds/130
Blamelist: Mark Thomas 
Build Text: failed compile (failure)
Status Detected: new failure
Build Source Stamp: [branch main] 021b1696b3d71f9feed77c048fe7a8e7cf243ae8


Steps:

  worker_preparation: 0

  git: 0

  shell: 0

  shell_1: 0

  shell_2: 0

  shell_3: 0

  shell_4: 0

  shell_5: 0

  compile: 1

  shell_6: 0

  shell_7: 0

  shell_8: 0

  shell_9: 0

  Rsync docs to nightlies.apache.org: 0

  shell_10: 0

  Rsync RAT to nightlies.apache.org: 0

  compile_1: 2

  shell_11: 0

  Rsync Logs to nightlies.apache.org: 0


-- ASF Buildbot


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



Buildbot success in on tomcat-10.1.x

2023-01-18 Thread buildbot
Build status: Build succeeded!
Worker used: bb2_worker2_ubuntu
URL: https://ci2.apache.org/#builders/44/builds/634
Blamelist: Mark Thomas , remm 
Build Text: build successful
Status Detected: restored build
Build Source Stamp: [branch 10.1.x] 0e0b90a592dddc3c48db2b5e6dd99660b74272f0


Steps:

  worker_preparation: 0

  git: 0

  shell: 0

  shell_1: 0

  shell_2: 0

  shell_3: 0

  shell_4: 0

  shell_5: 0

  compile: 1

  shell_6: 0

  shell_7: 0

  shell_8: 0

  shell_9: 0

  Rsync docs to nightlies.apache.org: 0

  shell_10: 0

  Rsync RAT to nightlies.apache.org: 0

  compile_1: 1

  shell_11: 0

  Rsync Logs to nightlies.apache.org: 0


-- ASF Buildbot


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



[tomcat] branch main updated: Refactor storage of current character encoding for request/response

2023-01-18 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


The following commit(s) were added to refs/heads/main by this push:
 new 021b1696b3 Refactor storage of current character encoding for 
request/response
021b1696b3 is described below

commit 021b1696b3d71f9feed77c048fe7a8e7cf243ae8
Author: Mark Thomas 
AuthorDate: Wed Jan 18 16:05:50 2023 +

Refactor storage of current character encoding for request/response
---
 java/org/apache/coyote/Request.java|  27 ++---
 java/org/apache/coyote/Response.java   |  33 +++---
 java/org/apache/tomcat/util/buf/CharsetHolder.java | 113 +
 3 files changed, 135 insertions(+), 38 deletions(-)

diff --git a/java/org/apache/coyote/Request.java 
b/java/org/apache/coyote/Request.java
index 6908cdb7f0..8fdcfdb6ed 100644
--- a/java/org/apache/coyote/Request.java
+++ b/java/org/apache/coyote/Request.java
@@ -29,7 +29,7 @@ import java.util.concurrent.atomic.AtomicReference;
 import jakarta.servlet.ReadListener;
 import jakarta.servlet.ServletConnection;
 
-import org.apache.tomcat.util.buf.B2CConverter;
+import org.apache.tomcat.util.buf.CharsetHolder;
 import org.apache.tomcat.util.buf.MessageBytes;
 import org.apache.tomcat.util.buf.UDecoder;
 import org.apache.tomcat.util.http.MimeHeaders;
@@ -148,10 +148,7 @@ public final class Request {
  */
 private long contentLength = -1;
 private MessageBytes contentTypeMB = null;
-private Charset charset = null;
-// Retain the original, user specified character encoding so it can be
-// returned even if it is invalid
-private String characterEncoding = null;
+private CharsetHolder charsetHolder = CharsetHolder.EMPTY;
 
 /**
  * Is there an expectation ?
@@ -409,11 +406,11 @@ public final class Request {
  * content type.
  */
 public String getCharacterEncoding() {
-if (characterEncoding == null) {
-characterEncoding = getCharsetFromContentType(getContentType());
+if (charsetHolder.getName() == null) {
+charsetHolder = 
CharsetHolder.getInstance(getCharsetFromContentType(getContentType()));
 }
 
-return characterEncoding;
+return charsetHolder.getName();
 }
 
 
@@ -428,20 +425,17 @@ public final class Request {
  * invalid character encoding
  */
 public Charset getCharset() throws UnsupportedEncodingException {
-if (charset == null) {
+if (charsetHolder.getName() == null) {
+// Populates charsetHolder
 getCharacterEncoding();
-if (characterEncoding != null) {
-charset = B2CConverter.getCharset(characterEncoding);
-}
  }
 
-return charset;
+return charsetHolder.getValidatedCharset();
 }
 
 
 public void setCharset(Charset charset) {
-this.charset = charset;
-this.characterEncoding = charset.name();
+charsetHolder = CharsetHolder.getInstance(charset);
 }
 
 
@@ -784,8 +778,7 @@ public final class Request {
 
 contentLength = -1;
 contentTypeMB = null;
-charset = null;
-characterEncoding = null;
+charsetHolder = CharsetHolder.EMPTY;
 expectation = false;
 headers.recycle();
 trailerFields.clear();
diff --git a/java/org/apache/coyote/Response.java 
b/java/org/apache/coyote/Response.java
index b2a32387d7..f5fb215c22 100644
--- a/java/org/apache/coyote/Response.java
+++ b/java/org/apache/coyote/Response.java
@@ -32,7 +32,7 @@ import jakarta.servlet.WriteListener;
 
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
-import org.apache.tomcat.util.buf.B2CConverter;
+import org.apache.tomcat.util.buf.CharsetHolder;
 import org.apache.tomcat.util.buf.MessageBytes;
 import org.apache.tomcat.util.http.MimeHeaders;
 import org.apache.tomcat.util.http.parser.MediaType;
@@ -113,11 +113,7 @@ public final class Response {
  */
 String contentType = null;
 String contentLanguage = null;
-Charset charset = null;
-// Retain the original name used to set the charset so exactly that name is
-// used in the ContentType header. Some (arguably non-specification
-// compliant) user agents are very particular
-String characterEncoding = null;
+private CharsetHolder charsetHolder = CharsetHolder.EMPTY;
 long contentLength = -1;
 private Locale locale = DEFAULT_LOCALE;
 
@@ -505,19 +501,13 @@ public final class Response {
 if (isCommitted()) {
 return;
 }
-if (characterEncoding == null) {
-this.charset = null;
-this.characterEncoding = null;
-return;
-}
 
-this.characterEncoding = characterEncoding;
-this.charset = B2CConverter.getCharset(characterEncoding);
+charsetHolder =

Re: [tomcat] branch main updated: Implement new methods for setting character encoding

2023-01-18 Thread Mark Thomas

On 18/01/2023 15:35, ma...@apache.org wrote:

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


The following commit(s) were added to refs/heads/main by this push:
  new b1008bf815 Implement new methods for setting character encoding
b1008bf815 is described below

commit b1008bf81591d856368fdf5aa9a693e01bfdad3d
Author: Mark Thomas 
AuthorDate: Tue Jan 17 16:55:57 2023 +

 Implement new methods for setting character encoding


FYI I am currently exploring options to use some form of CharsetHolder 
internally rather than storing the Charset and the name separately in 
the request and response. I think that will simplify the code a little.


Mark

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



[tomcat] branch main updated: Implement new methods for setting character encoding

2023-01-18 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


The following commit(s) were added to refs/heads/main by this push:
 new b1008bf815 Implement new methods for setting character encoding
b1008bf815 is described below

commit b1008bf81591d856368fdf5aa9a693e01bfdad3d
Author: Mark Thomas 
AuthorDate: Tue Jan 17 16:55:57 2023 +

Implement new methods for setting character encoding
---
 java/jakarta/servlet/ServletContext.java   | 45 +
 java/jakarta/servlet/ServletRequest.java   | 34 ++---
 java/jakarta/servlet/ServletRequestWrapper.java| 10 
 java/jakarta/servlet/ServletResponse.java  | 58 +++---
 java/jakarta/servlet/ServletResponseWrapper.java   | 12 +
 .../apache/catalina/connector/TestResponse.java|  4 +-
 webapps/docs/changelog.xml |  4 ++
 7 files changed, 151 insertions(+), 16 deletions(-)

diff --git a/java/jakarta/servlet/ServletContext.java 
b/java/jakarta/servlet/ServletContext.java
index 97a99d6872..96d4a1dc52 100644
--- a/java/jakarta/servlet/ServletContext.java
+++ b/java/jakarta/servlet/ServletContext.java
@@ -19,6 +19,7 @@ package jakarta.servlet;
 import java.io.InputStream;
 import java.net.MalformedURLException;
 import java.net.URL;
+import java.nio.charset.Charset;
 import java.util.Enumeration;
 import java.util.EventListener;
 import java.util.Map;
@@ -969,6 +970,28 @@ public interface ServletContext {
  */
 public void setRequestCharacterEncoding(String encoding);
 
+/**
+ * Sets the request character encoding for this ServletContext.
+ *
+ * Implementations are strongly encouraged to override this default
+ * method and provide a more efficient implementation.
+ *
+ * @param encoding request character encoding
+ *
+ * @throws IllegalStateException if this ServletContext has already been
+ * initialized
+ * @throws UnsupportedOperationException if this ServletContext was passed
+ * to the {@link ServletContextListener#contextInitialized} method of a
+ * {@link ServletContextListener} that was neither declared in
+ * {@code web.xml} or {@code web-fragment.xml}, nor annotated with
+ * {@link jakarta.servlet.annotation.WebListener}
+ *
+ * @since Servlet 6.1
+ */
+public default void setRequestCharacterEncoding(Charset encoding) {
+setRequestCharacterEncoding(encoding.name());
+}
+
 /**
  * Get the default character encoding for writing response bodies.
  *
@@ -979,6 +1002,28 @@ public interface ServletContext {
  */
 public String getResponseCharacterEncoding();
 
+/**
+ * Sets the response character encoding for this ServletContext.
+ *
+ * Implementations are strongly encouraged to override this default
+ * method and provide a more efficient implementation.
+ *
+ * @param encoding response character encoding
+ *
+ * @throws IllegalStateException if this ServletContext has already been
+ * initialized
+ * @throws UnsupportedOperationException if this ServletContext was passed
+ * to the {@link ServletContextListener#contextInitialized} method of a
+ * {@link ServletContextListener} that was neither declared in
+ * {@code web.xml} or {@code web-fragment.xml}, nor annotated with
+ * {@link jakarta.servlet.annotation.WebListener}
+ *
+ * @since Servlet 6.1
+ */
+public default void setResponseCharacterEncoding(Charset encoding) {
+setResponseCharacterEncoding(encoding.name());
+}
+
 /**
  * Set the default character encoding to use for writing response bodies.
  * Calling this method will over-ride any value set in the deployment
diff --git a/java/jakarta/servlet/ServletRequest.java 
b/java/jakarta/servlet/ServletRequest.java
index ea0c549e4b..ed0272a528 100644
--- a/java/jakarta/servlet/ServletRequest.java
+++ b/java/jakarta/servlet/ServletRequest.java
@@ -18,6 +18,8 @@ package jakarta.servlet;
 
 import java.io.BufferedReader;
 import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.nio.charset.Charset;
 import java.util.Enumeration;
 import java.util.Locale;
 import java.util.Map;
@@ -97,14 +99,34 @@ public interface ServletRequest {
  * request. This method must be called prior to reading request parameters
  * or reading input using getReader().
  *
- * @param env
- *a String containing the name of the character
- *encoding.
- * @throws java.io.UnsupportedEncodingException
+ * @param encoding a {@code String} containing the name of the character
+ * encoding
+ *
+ * @throws UnsupportedEncodingException
  * if this is not a valid encoding
  */
-public void setCharacterEncoding(St

[tomcat] branch 9.0.x updated: Fix comment typo

2023-01-18 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


The following commit(s) were added to refs/heads/9.0.x by this push:
 new f3b9e719bb Fix comment typo
f3b9e719bb is described below

commit f3b9e719bb92dd95247878f8d623ff99daa03fd3
Author: Mark Thomas 
AuthorDate: Wed Jan 18 12:34:02 2023 +

Fix comment typo
---
 java/org/apache/catalina/connector/Request.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/java/org/apache/catalina/connector/Request.java 
b/java/org/apache/catalina/connector/Request.java
index 949f4353e1..6cb200f8ef 100644
--- a/java/org/apache/catalina/connector/Request.java
+++ b/java/org/apache/catalina/connector/Request.java
@@ -1243,7 +1243,7 @@ public class Request implements HttpServletRequest {
 // here. Need to do this before setting usingReader.
 if (coyoteRequest.getCharacterEncoding() == null) {
 // Nothing currently set explicitly.
-// Check the content
+// Check the context
 Context context = getContext();
 if (context != null) {
 String enc = context.getRequestCharacterEncoding();


-
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: Fix comment typo

2023-01-18 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


The following commit(s) were added to refs/heads/10.1.x by this push:
 new 0e0b90a592 Fix comment typo
0e0b90a592 is described below

commit 0e0b90a592dddc3c48db2b5e6dd99660b74272f0
Author: Mark Thomas 
AuthorDate: Wed Jan 18 12:34:02 2023 +

Fix comment typo
---
 java/org/apache/catalina/connector/Request.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/java/org/apache/catalina/connector/Request.java 
b/java/org/apache/catalina/connector/Request.java
index 6aa07d54e1..7a7373bb8e 100644
--- a/java/org/apache/catalina/connector/Request.java
+++ b/java/org/apache/catalina/connector/Request.java
@@ -1211,7 +1211,7 @@ public class Request implements HttpServletRequest {
 // here. Need to do this before setting usingReader.
 if (coyoteRequest.getCharacterEncoding() == null) {
 // Nothing currently set explicitly.
-// Check the content
+// Check the context
 Context context = getContext();
 if (context != null) {
 String enc = context.getRequestCharacterEncoding();


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



[tomcat] branch main updated: Fix comment typo

2023-01-18 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


The following commit(s) were added to refs/heads/main by this push:
 new 08d37215e0 Fix comment typo
08d37215e0 is described below

commit 08d37215e0fbb52c1275f9f21d9c802d534f45f4
Author: Mark Thomas 
AuthorDate: Wed Jan 18 12:34:02 2023 +

Fix comment typo
---
 java/org/apache/catalina/connector/Request.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/java/org/apache/catalina/connector/Request.java 
b/java/org/apache/catalina/connector/Request.java
index ba7611d5c3..9dfd6725b6 100644
--- a/java/org/apache/catalina/connector/Request.java
+++ b/java/org/apache/catalina/connector/Request.java
@@ -1211,7 +1211,7 @@ public class Request implements HttpServletRequest {
 // here. Need to do this before setting usingReader.
 if (coyoteRequest.getCharacterEncoding() == null) {
 // Nothing currently set explicitly.
-// Check the content
+// Check the context
 Context context = getContext();
 if (context != null) {
 String enc = context.getRequestCharacterEncoding();


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



[VOTE][RESULT] Release Apache Tomcat 8.5.85 (round 2)

2023-01-18 Thread Christopher Schultz

All,

The following votes were cast:

Binding:
+1: markt, schultz, remm, kkolinko

No other votes were cast, the vote therefore passes. Thanks to everyone 
who contributed to this release.


Thanks,
-chris

On 1/12/23 15:17, Christopher Schultz wrote:

The proposed Apache Tomcat 8.5.85 release is now available for voting.

[[[
Note that the previous tag has been replaced with a new one which 
contains the signature files produced during the release-build. The 
commit-id of the tag has therefore changed as noted later in this 
message. The files uploaded to the Tomcat release directory and to Maven 
are unchanged. There are no other changes to the tag from the previous 
8.5.85 tag. The files added are:


res/install-win/tomcat-installer.exe.sig
res/install-win/Uninstall.exe.sig
]]]

The notable changes compared to 8.5.84 are:

- The default value of AccessLogValue's file encoding is
   now UTF-8.

- Correct a regression in the refactoring that replaced the use of the
   URL constructors. The regression broke lookups for resources that
   contained one or more characters in their name that required escaping
   when used in a URI path.

- When an HTTP/2 stream was reset, the current active stream count was
   not reduced. If enough resets occurred on a connection, the current
   active stream count limit was reached and no new streams could be
   created on that connection.

- Change the default of the org.apache.el.GET_CLASSLOADER_USE_PRIVILEGED
   system property to true unless the EL library is running on Tomcat in
   which case the default remains false as the EL library is already
   called from within a privileged block and skipping the unnecessary
   privileged block improves performance.

Along with lots of other bug fixes and improvements.

For full details, see the changelog:
https://nightlies.apache.org/tomcat/tomcat-8.5.x/docs/changelog.html

It can be obtained from:
https://dist.apache.org/repos/dist/dev/tomcat/tomcat-8/v8.5.85/

The Maven staging repo is:
https://repository.apache.org/content/repositories/orgapachetomcat-1416

The tag is:
https://github.com/apache/tomcat/tree/8.5.85/
7b1f4ce0b82641bf76a3d763bd97d5522513b57b

The proposed 8.5.85 release is:
[ ] Broken - do not release
[ ] Stable - go ahead and release as 8.5.85 (stable)

-
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



Re: [VOTE] Release Apache Tomcat 8.5.85 (round 2)

2023-01-18 Thread Christopher Schultz

Konstantin,

On 1/18/23 02:03, Konstantin Kolinko wrote:

чт, 12 янв. 2023 г. в 23:17, Christopher Schultz :


The proposed Apache Tomcat 8.5.85 release is now available for voting.

[...]

The notable changes compared to 8.5.84 are:

- The default value of AccessLogValue's file encoding is
now UTF-8.


Chris,
1) a typo above, Value -> Valve


Thanks. I'll fix that in the release announcement.


2) Note the EOL announcement
https://tomcat.apache.org/tomcat-85-eol.html



Thanks for the reminder. I'll add this to the release announcement as well.

And thanks for the vote!

-chris


It can be obtained from:
https://dist.apache.org/repos/dist/dev/tomcat/tomcat-8/v8.5.85/

The Maven staging repo is:
https://repository.apache.org/content/repositories/orgapachetomcat-1416

The tag is:
https://github.com/apache/tomcat/tree/8.5.85/
7b1f4ce0b82641bf76a3d763bd97d5522513b57b

The proposed 8.5.85 release is:
[ ] Broken - do not release
[x] Stable - go ahead and release as 8.5.85 (stable)


Smoke tests OK.
(Installer, Java 7, Examples).

Best regards,
Konstantin Kolinko

-
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



Buildbot failure in on tomcat-10.1.x

2023-01-18 Thread buildbot
Build status: BUILD FAILED: update (failure)
Worker used: bb2_worker2_ubuntu
URL: https://ci2.apache.org/#builders/44/builds/633
Blamelist: remm 
Build Text: update (failure)
Status Detected: new failure
Build Source Stamp: [branch 10.1.x] 8eda56a35598e6dcc28f3374f8ace79b4d446e46


Steps:

  worker_preparation: 0

  git: 2


-- ASF Buildbot


-
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: Pull test validation in a separate validate step

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

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


The following commit(s) were added to refs/heads/8.5.x by this push:
 new 7421a600f6 Pull test validation in a separate validate step
7421a600f6 is described below

commit 7421a600f6933a6a117bd01965279399248b7afb
Author: remm 
AuthorDate: Wed Jan 18 10:37:18 2023 +0100

Pull test validation in a separate validate step

This will allow making the main validation tighter.
Document some validation options as less useful.
---
 build.xml  | 24 ++-
 res/checkstyle/checkstyle.xml  |  6 ++--
 .../{checkstyle.xml => test-checkstyle.xml}| 34 +++---
 3 files changed, 24 insertions(+), 40 deletions(-)

diff --git a/build.xml b/build.xml
index f66c834a00..5c07d2b80b 100644
--- a/build.xml
+++ b/build.xml
@@ -593,6 +593,7 @@
 
 
+
 
   
 
@@ -603,6 +604,7 @@
 
 
 
+
 
 
 
@@ -616,13 +618,6 @@
 
 
 
-
-
-
-
-
-
-
 
 
 
@@ -647,6 +642,21 @@
 
   
 
+
+
+  
+
+
+
+
+
+
+
+
+
+
+  
+
   
 
   
 
 
-
+
 
-
+
 
-
+
 
 
 
   
+
value="${tomcat.output}/res/checkstyle/cachefile-test-checkstyle.xml"/>
 
   
   
 
 
-
+
   
 
   
@@ -69,7 +69,7 @@
 
 
 
-
+
 
 
 
@@ -87,46 +87,20 @@
 
 
 
-
 
-
 
-
+
 
 
-
-
 
-
 
 
-
-
-
 
 
-
 
 
 
 
 
-
   
 


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



[tomcat] branch 9.0.x updated: Pull test validation in a separate validate step

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

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


The following commit(s) were added to refs/heads/9.0.x by this push:
 new 7e8598dc45 Pull test validation in a separate validate step
7e8598dc45 is described below

commit 7e8598dc45235c3215aae9f77609dc471ee88711
Author: remm 
AuthorDate: Wed Jan 18 10:37:18 2023 +0100

Pull test validation in a separate validate step

This will allow making the main validation tighter.
Document some validation options as less useful.
---
 build.xml  | 24 ++-
 res/checkstyle/checkstyle.xml  |  6 ++--
 .../{checkstyle.xml => test-checkstyle.xml}| 34 +++---
 3 files changed, 24 insertions(+), 40 deletions(-)

diff --git a/build.xml b/build.xml
index 1c263e09f9..3d7d43d2d1 100644
--- a/build.xml
+++ b/build.xml
@@ -833,6 +833,7 @@
 
 
+
 
   
 
@@ -843,6 +844,7 @@
 
 
 
+
 
 
 
@@ -857,13 +859,6 @@
 
 
 
-
-
-
-
-
-
-
 
 
 
@@ -888,6 +883,21 @@
 
   
 
+
+
+  
+
+
+
+
+
+
+
+
+
+
+  
+
   
 
   
 
 
-
+
 
-
+
 
-
+
 
 
 
   
+
value="${tomcat.output}/res/checkstyle/cachefile-test-checkstyle.xml"/>
 
   
   
 
 
-
+
   
 
   
@@ -69,7 +69,7 @@
 
 
 
-
+
 
 
 
@@ -87,46 +87,20 @@
 
 
 
-
 
-
 
-
+
 
 
-
-
 
-
 
 
-
-
-
 
 
-
 
 
 
 
 
-
   
 


-
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: Pull test validation in a separate validate step

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

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


The following commit(s) were added to refs/heads/10.1.x by this push:
 new 8eda56a355 Pull test validation in a separate validate step
8eda56a355 is described below

commit 8eda56a35598e6dcc28f3374f8ace79b4d446e46
Author: remm 
AuthorDate: Wed Jan 18 10:37:18 2023 +0100

Pull test validation in a separate validate step

This will allow making the main validation tighter.
Document some validation options as less useful.
---
 build.xml  | 24 -
 res/checkstyle/checkstyle.xml  |  6 ++---
 .../{checkstyle.xml => test-checkstyle.xml}| 30 ++
 3 files changed, 22 insertions(+), 38 deletions(-)

diff --git a/build.xml b/build.xml
index b7ab0282ca..cc5bdddada 100644
--- a/build.xml
+++ b/build.xml
@@ -839,6 +839,7 @@
 
 
+
 
   
 
@@ -849,6 +850,7 @@
 
 
 
+
 
 
 
@@ -863,13 +865,6 @@
 
 
 
-
-
-
-
-
-
-
 
 
 
@@ -894,6 +889,21 @@
 
   
 
+
+
+  
+
+
+
+
+
+
+
+
+
+
+  
+
   
 
   
 
 
-
+
 
-
+
 
-
+
 
 
 
   
+
value="${tomcat.output}/res/checkstyle/cachefile-test-checkstyle.xml"/>
 
   
   
@@ -87,46 +87,20 @@
 
 
 
-
 
-
 
-
+
 
 
-
-
 
-
 
 
-
-
-
 
 
-
 
 
 
 
 
-
   
 


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



[tomcat] branch main updated: Pull test validation in a separate validate step

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

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


The following commit(s) were added to refs/heads/main by this push:
 new 842a463c23 Pull test validation in a separate validate step
842a463c23 is described below

commit 842a463c23cad51be147a2c91d98b7c176093956
Author: remm 
AuthorDate: Wed Jan 18 10:37:18 2023 +0100

Pull test validation in a separate validate step

This will allow making the main validation tighter.
Document some validation options as less useful.
---
 build.xml  | 24 -
 res/checkstyle/checkstyle.xml  |  6 ++---
 .../{checkstyle.xml => test-checkstyle.xml}| 30 ++
 3 files changed, 22 insertions(+), 38 deletions(-)

diff --git a/build.xml b/build.xml
index 035be1ade6..9ed54055d5 100644
--- a/build.xml
+++ b/build.xml
@@ -836,6 +836,7 @@
 
 
+
 
   
 
@@ -846,6 +847,7 @@
 
 
 
+
 
 
 
@@ -860,13 +862,6 @@
 
 
 
-
-
-
-
-
-
-
 
 
 
@@ -891,6 +886,21 @@
 
   
 
+
+
+  
+
+
+
+
+
+
+
+
+
+
+  
+
   
 
   
 
 
-
+
 
-
+
 
-
+
 
 
 
   
+
value="${tomcat.output}/res/checkstyle/cachefile-test-checkstyle.xml"/>
 
   
   
@@ -87,46 +87,20 @@
 
 
 
-
 
-
 
-
+
 
 
-
-
 
-
 
 
-
-
-
 
 
-
 
 
 
 
 
-
   
 


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