Re: NullPointerException in CoyoteOutputStream

2020-06-12 Thread Konstantin Kolinko
пт, 12 июн. 2020 г. в 18:36, Mark A. Claassen :
>
> We were doing some load testing and we started getting a NullPointerException 
> at the stack trace below.  We don't get the NPE all the time, so I am 
> guessing some of these objects got corrupted somehow.
> One place the clear() method is called from is the recycle() method in the 
> Response object from the same package.
>
> Has anyone seen this before?  My Internet searches did not reveal any other 
> reports of this.  Is this something that has already been fixed in the course 
> of other changes?
>
> The version of Tomcat is 9.0.12 and we are using the openSSL underneath all 
> this.

Why not the current version (9.0.36)?

Also
https://cwiki.apache.org/confluence/display/TOMCAT/Troubleshooting+and+Diagnostics#TroubleshootingandDiagnostics-TroubleshootingunexpectedResponsestateproblems

Best regards,
Konstantin Kolinko

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



RE: NullPointerException in CoyoteOutputStream

2020-06-12 Thread Mark A. Claassen
Thanks for the reply, and sorry for the confusion.  I catch the error in my 
code and format it in a custom way, which is why it may look a bit different 
than what you expect.
That was not the complete stack, but the top is the top, which implies that 
'ob' is null

After the ByteCounterOutputStream line, there is more of my code until I 
eventually get to:
HttpServlet.service(HttpServlet.java:660)
The ByteCounterOutputStream wraps the HttpServletResponse.getOutputStream() and 
the error occurs when it is trying to write to the stream.


My code has been relatively unchanged for years. Additionally, this load test 
has succeeded using this version of tomcat of 10,000s of iterations.  
However, maybe some once-in-a-million occurrence happened and corrupted at 
least of one instance of the CoyoteOutputStream?  
And then whenever one of these gets reused, I can't write to the output stream.

CoyoteOutputStream.checkNonBlockingWrite(CoyoteOutputStream.java:134)
CoyoteOutputStream.write(CoyoteOutputStream.java:95)
CoyoteOutputStream.write(CoyoteOutputStream.java:89)
ByteCounterOutputStream.write(ByteCounterOutputStream.java:37) <-- My code 
doing a write()

private boolean checkNonBlockingWrite() {
boolean nonBlocking = !ob.isBlocking(); <-- 134 (NPE here implies ob is 
null)
if (nonBlocking && !ob.isReady()) {
throw new 
IllegalStateException(sm.getString("coyoteOutputStream.nbNotready"));
}
return nonBlocking;
}
public void write(byte[] b, int off, int len) throws IOException {
boolean nonBlocking = checkNonBlockingWrite(); <-- 95
ob.write(b, off, len);
if (nonBlocking) {
checkRegisterForWrite();
}
}
public void write(byte[] b) throws IOException {
write(b, 0, b.length); <-- 89
}

-Original Message-
From: calder  
Sent: Friday, June 12, 2020 12:31 PM
To: Tomcat Users List 
Subject: Re: NullPointerException in CoyoteOutputStream

On Fri, Jun 12, 2020, 10:36 Mark A. Claassen  wrote:

> We were doing some load testing and we started getting a 
> NullPointerException at the stack trace below.  We don't get the NPE 
> all the time, so I am guessing some of these objects got corrupted somehow.
> One place the clear() method is called from is the recycle() method in 
> the Response object from the same package.
>
> Has anyone seen this before?  My Internet searches did not reveal any 
> other reports of this.  Is this something that has already been fixed 
> in the course of other changes?
>
> The version of Tomcat is 9.0.12 and we are using the openSSL 
> underneath all this.
>
> ---
>  at
> org.apache.catalina.connector.CoyoteOutputStream.checkNonBlockingWrite
> (CoyoteOutputStream.java:134)
>  at
> org.apache.catalina.connector.CoyoteOutputStream.write(CoyoteOutputStr
> eam.java:95)
>  at
> org.apache.catalina.connector.CoyoteOutputStream.write(CoyoteOutputStr
> eam.java:89)
>  at dsi.core.io
> .ByteCounterOutputStream.write(ByteCounterOutputStream.java:37)
>


Apologies ... but this doesn't look like a complete stack trace, to include any 
"caused by" statements (and the originating statement)


 CoyoteOutputStream
> private boolean checkNonBlockingWrite() {
> boolean nonBlocking = !ob.isBlocking(); <-- Line 134
> if (nonBlocking && !ob.isReady()) {
> throw new
> IllegalStateException(sm.getString("coyoteOutputStream.nbNotready"));
> }
> return nonBlocking;
> }
> --- CoyoteOutputStream
> /**
>  * Clear facade.
>  */
> void clear() {
> ob = null;
> }
> --- CoyoteOutputStream
> @Override
> public void close() throws IOException {
> ob.close();
> }
> ---


Re: NullPointerException in CoyoteOutputStream

2020-06-12 Thread calder
On Fri, Jun 12, 2020, 10:36 Mark A. Claassen  wrote:

> We were doing some load testing and we started getting a
> NullPointerException at the stack trace below.  We don't get the NPE all
> the time, so I am guessing some of these objects got corrupted somehow.
> One place the clear() method is called from is the recycle() method in the
> Response object from the same package.
>
> Has anyone seen this before?  My Internet searches did not reveal any
> other reports of this.  Is this something that has already been fixed in
> the course of other changes?
>
> The version of Tomcat is 9.0.12 and we are using the openSSL underneath
> all this.
>
> ---
>  at
> org.apache.catalina.connector.CoyoteOutputStream.checkNonBlockingWrite(CoyoteOutputStream.java:134)
>  at
> org.apache.catalina.connector.CoyoteOutputStream.write(CoyoteOutputStream.java:95)
>  at
> org.apache.catalina.connector.CoyoteOutputStream.write(CoyoteOutputStream.java:89)
>  at dsi.core.io
> .ByteCounterOutputStream.write(ByteCounterOutputStream.java:37)
>


Apologies ... but this doesn't look like a complete stack trace, to include
any "caused by" statements (and the originating statement)


 CoyoteOutputStream
> private boolean checkNonBlockingWrite() {
> boolean nonBlocking = !ob.isBlocking(); <-- Line 134
> if (nonBlocking && !ob.isReady()) {
> throw new
> IllegalStateException(sm.getString("coyoteOutputStream.nbNotready"));
> }
> return nonBlocking;
> }
> --- CoyoteOutputStream
> /**
>  * Clear facade.
>  */
> void clear() {
> ob = null;
> }
> --- CoyoteOutputStream
> @Override
> public void close() throws IOException {
> ob.close();
> }
> ---