You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Mark A. Claassen" <MC...@ocie.net> on 2020/06/12 15:36:05 UTC
NullPointerException in CoyoteOutputStream
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.
Thanks,
Mark
---------------
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)
--------------- 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();
}
---------------
Mark Claassen
Senior Software Engineer
Donnell Systems, Inc.
130 South Main Street
Leighton Plaza Suite 375
South Bend, IN 46601
E-mail: mailto:mclaassen@ocie.net
Voice: (574)232-3784
Fax: (574)232-4014
Disclaimer:
The opinions provided herein do not necessarily state or reflect
those of Donnell Systems, Inc.(DSI). DSI makes no warranty for and
assumes no legal liability or responsibility for the posting.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: NullPointerException in CoyoteOutputStream
Posted by Konstantin Kolinko <kn...@gmail.com>.
пт, 12 июн. 2020 г. в 18:36, Mark A. Claassen <MC...@ocie.net>:
>
> 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-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
RE: NullPointerException in CoyoteOutputStream
Posted by "Mark A. Claassen" <MC...@ocie.net>.
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 <ca...@gmail.com>
Sent: Friday, June 12, 2020 12:31 PM
To: Tomcat Users List <us...@tomcat.apache.org>
Subject: Re: NullPointerException in CoyoteOutputStream
On Fri, Jun 12, 2020, 10:36 Mark A. Claassen <MC...@ocie.net> 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
Posted by calder <ca...@gmail.com>.
On Fri, Jun 12, 2020, 10:36 Mark A. Claassen <MC...@ocie.net> 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();
> }
> ---------------