Skip to content

Commit

Permalink
Fix another NPE observed in logs during unit test runs
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1655812 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
markt-asf committed Jan 29, 2015
1 parent c9db3fe commit a895591
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 7 additions & 0 deletions java/org/apache/tomcat/util/net/SocketWrapperBase.java
Expand Up @@ -27,9 +27,13 @@
import java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock;

import org.apache.tomcat.util.buf.ByteBufferHolder;
import org.apache.tomcat.util.res.StringManager;

public abstract class SocketWrapperBase<E> {

protected static final StringManager sm = StringManager.getManager(
SocketWrapperBase.class.getPackage().getName());

private volatile E socket;
private final AbstractEndpoint<E> endpoint;

Expand Down Expand Up @@ -284,6 +288,9 @@ public boolean isReadyForWrite() {


public boolean canWrite() {
if (socketBufferHandler == null) {
throw new IllegalStateException(sm.getString("socket.closed"));
}
return socketBufferHandler.isWriteBufferWritable() && bufferedWrites.size() == 0;
}

Expand Down
Expand Up @@ -115,9 +115,9 @@ public void onWritePossible(boolean useDispatch) {
break;
}
}
} catch (IOException ioe) {
} catch (IOException | IllegalStateException e) {
wsWriteTimeout.unregister(this);
clearHandler(ioe, useDispatch);
clearHandler(e, useDispatch);
close();
}

Expand Down

0 comments on commit a895591

Please sign in to comment.