Skip to content

Commit

Permalink
[RESTEASY-1680]:Fix couple of mistakes after review. Thanks Rebecca a…
Browse files Browse the repository at this point in the history
…nd Ron
  • Loading branch information
jimma committed Sep 29, 2017
1 parent 1bbf2da commit 89a0cac
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Expand Up @@ -10,18 +10,18 @@ public synchronized byte[] getEventPayLoad()
// delimiter is \r or \n // delimiter is \r or \n
if (count >=2 && this.buf[count-2] == this.buf[count-1]) if (count >=2 && this.buf[count-2] == this.buf[count-1])
{ {
count = count -1; return Arrays.copyOf(buf, count -1);
} }
//delimiter is //delimiter is
if (count >= 1 && buf[count-2] == '\r' && buf[count-1] == '\n') { if (count >= 2 && buf[count-2] == '\r' && buf[count-1] == '\n') {
count = count -2; Arrays.copyOf(buf, count-2);
} }
return Arrays.copyOf(buf, count); return Arrays.copyOf(buf, count);
} }


public synchronized byte[] getEventData() public synchronized byte[] getEventData()
{ {
if (buf[count-1] == '\n') if (count >=1 && buf[count-1] == '\n')
{ {
return Arrays.copyOf(buf, count - 1); return Arrays.copyOf(buf, count - 1);
} }
Expand Down
Expand Up @@ -25,7 +25,7 @@ public class SseEventInputImpl implements EventInput, Closeable
private InputStream inputStream; private InputStream inputStream;
private volatile boolean isClosed = false; private volatile boolean isClosed = false;
private boolean lastFieldWasData; private boolean lastFieldWasData;
private final String DELIMIETER = new String(SseConstants.EVENT_DELIMITER, StandardCharsets.UTF_8); private final String DELIMITER = new String(SseConstants.EVENT_DELIMITER, StandardCharsets.UTF_8);
public SseEventInputImpl(Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, public SseEventInputImpl(Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders,
InputStream inputStream) InputStream inputStream)
{ {
Expand Down Expand Up @@ -230,7 +230,7 @@ public byte[] readEvent(final InputStream in) throws IOException
eolBuffer[pos] = b; eolBuffer[pos] = b;
//if it meets \r\r , \n\n , \r\n\r\n or \n\r\n\r\n //if it meets \r\r , \n\n , \r\n\r\n or \n\r\n\r\n
if ((pos > 0 && eolBuffer[pos] == eolBuffer[pos - 1]) if ((pos > 0 && eolBuffer[pos] == eolBuffer[pos - 1])
|| (pos >= 3 && new String(eolBuffer, 0, pos, StandardCharsets.UTF_8).contains(DELIMIETER))) || (pos >= 3 && new String(eolBuffer, 0, pos, StandardCharsets.UTF_8).contains(DELIMITER)))
{ {
boundary = true; boundary = true;
} }
Expand Down

0 comments on commit 89a0cac

Please sign in to comment.