Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/jetty-10.0.x' into jetty-11.0.x
Browse files Browse the repository at this point in the history
  • Loading branch information
joakime committed Dec 6, 2022
2 parents ccdf6fb + e923123 commit d6b88e2
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -379,15 +379,15 @@ public void resolve(String host, int port, Promise<List<InetSocketAddress>> prom
@MethodSource("pools")
public void testConcurrentRequestsAllBlockedOnServerWithLargeConnectionPool(ConnectionPoolFactory factory) throws Exception
{
int count = 50;
int count = 10;
testConcurrentRequestsAllBlockedOnServer(factory, count, 2 * count);
}

@ParameterizedTest
@MethodSource("pools")
public void testConcurrentRequestsAllBlockedOnServerWithExactConnectionPool(ConnectionPoolFactory factory) throws Exception
{
int count = 50;
int count = 10;
testConcurrentRequestsAllBlockedOnServer(factory, count, count);
}

Expand Down Expand Up @@ -441,10 +441,12 @@ protected void service(String target, org.eclipse.jetty.server.Request jettyRequ
{
if (result.isSucceeded())
latch.countDown();
else
result.getFailure().printStackTrace();
}));
}

assertTrue(latch.await(5, TimeUnit.SECONDS), "server requests " + barrier.getNumberWaiting() + "<" + count + " - client: " + client.dump());
assertTrue(latch.await(15, TimeUnit.SECONDS), "server requests " + barrier.getNumberWaiting() + "<" + count + " - client: " + client.dump());
List<Destination> destinations = client.getDestinations();
assertEquals(1, destinations.size());
// The max duration connection pool aggressively closes expired connections upon release, which interferes with this assertion.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
package org.eclipse.jetty.http2.client;

import java.nio.ByteBuffer;
import java.time.Duration;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CountDownLatch;
Expand All @@ -38,6 +39,8 @@
import org.eclipse.jetty.util.Promise;
import org.junit.jupiter.api.Test;

import static org.awaitility.Awaitility.await;
import static org.hamcrest.Matchers.equalTo;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
Expand Down Expand Up @@ -179,7 +182,7 @@ public void succeeded()
assertTrue(serverDataLatch.await(5, TimeUnit.SECONDS));
assertTrue(completeLatch.await(5, TimeUnit.SECONDS));
assertTrue(stream.isClosed());
assertEquals(0, stream.getSession().getStreams().size());
await().atMost(Duration.ofSeconds(5)).until(() -> stream.getSession().getStreams().size(), equalTo(0));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -941,7 +941,7 @@ else if (_line.length() == 0)
_pos = 0;
}

return _buffer[_pos++];
return _buffer[_pos++] & 0xFF;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public int read() throws IOException
if (len < 0) // EOF
return -1;
if (len > 0) // did read something
return buf[0];
return buf[0] & 0xFF;
// reading nothing (len == 0) tries again
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTimeout;

Expand Down Expand Up @@ -279,4 +280,23 @@ public void testAppendNullPayloadRead() throws IOException
}
});
}

@Test
public void testReadSingleByteIsNotSigned() throws Exception
{
try (MessageInputStream stream = new MessageInputStream())
{
// Byte must be greater than 127.
int theByte = 200;
// Append a single message (simple, short)
Frame frame = new Frame(OpCode.BINARY);
frame.setPayload(new byte[]{(byte)theByte});
frame.setFin(true);
stream.accept(frame, Callback.NOOP);

// Single byte read must not return a signed byte.
int read = stream.read();
assertEquals(theByte, read);
}
}
}

0 comments on commit d6b88e2

Please sign in to comment.