Skip to content

Commit

Permalink
Issue #4331 Close Complete
Browse files Browse the repository at this point in the history
Removed old close on all content mechanism
Cleanups and some more TODOs

Signed-off-by: Greg Wilkins <gregw@webtide.com>
  • Loading branch information
gregw committed Dec 9, 2019
1 parent ca0e0c4 commit 1da0062
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 20 deletions.
Expand Up @@ -47,16 +47,11 @@ public EncodingHttpWriter(HttpOutput out, String encoding)
public void write(char[] s, int offset, int length) throws IOException
{
HttpOutput out = _out;
if (length == 0 && out.isAllContentWritten()) // TODO why is this needed?
{
out.close();
return;
}

while (length > 0)
{
_bytes.reset();
int chars = length > MAX_OUTPUT_CHARS ? MAX_OUTPUT_CHARS : length;
int chars = Math.min(length, MAX_OUTPUT_CHARS);

_converter.write(s, offset, chars);
_converter.flush();
Expand Down
Expand Up @@ -63,7 +63,7 @@ public class HttpOutput extends ServletOutputStream implements Runnable
private static final String LSTRING_FILE = "javax.servlet.LocalStrings";
private static ResourceBundle lStrings = ResourceBundle.getBundle(LSTRING_FILE);

/* TODO UPDATE!!!
/*
ACTION OPEN ASYNC READY PENDING UNREADY CLOSING CLOSED
--------------------------------------------------------------------------------------------------
setWriteListener() READY->owp ise ise ise ise ise ise
Expand All @@ -80,7 +80,7 @@ enum State
READY, // isReady() has returned true
PENDING, // write operating in progress
UNREADY, // write operating in progress, isReady has returned false
ERROR, // An error has occured
ERROR, // onError needs to be called
CLOSING, // Asynchronous close in progress
CLOSED // Closed
}
Expand Down Expand Up @@ -297,7 +297,8 @@ public void close(Callback callback)
return;

case ERROR:
// TODO is this right?
// TODO is this right? Perhaps the close should wait
// TODO until after onError callback?
Callback cb = Callback.combine(_closeCallback, callback);
_closeCallback = null;
cb.failed(_onError);
Expand Down Expand Up @@ -1195,6 +1196,7 @@ public void run()

synchronized (_channelState)
{
// TODO does this need to be a state or just non null _onError
if (_state == State.ERROR)
{
error = _onError;
Expand Down
Expand Up @@ -35,11 +35,6 @@ public Iso88591HttpWriter(HttpOutput out)
public void write(char[] s, int offset, int length) throws IOException
{
HttpOutput out = _out;
if (length == 0 && out.isAllContentWritten()) // TODO why is this needed?
{
close();
return;
}

if (length == 1)
{
Expand Down
Expand Up @@ -42,16 +42,11 @@ public Utf8HttpWriter(HttpOutput out)
public void write(char[] s, int offset, int length) throws IOException
{
HttpOutput out = _out;
if (length == 0 && out.isAllContentWritten()) // TODO why is this needed?
{
close();
return;
}

while (length > 0)
{
_bytes.reset();
int chars = length > MAX_OUTPUT_CHARS ? MAX_OUTPUT_CHARS : length;
int chars = Math.min(length, MAX_OUTPUT_CHARS);

byte[] buffer = _bytes.getBuf();
int bytes = _bytes.getCount();
Expand Down

0 comments on commit 1da0062

Please sign in to comment.