Skip to content

Commit

Permalink
#8885 fix NPE
Browse files Browse the repository at this point in the history
Signed-off-by: Ludovic Orban <[email protected]>
  • Loading branch information
lorban committed Jun 13, 2023
1 parent 59cb9e7 commit 86e6580
Showing 1 changed file with 162 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,18 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.stream.Stream;

import org.awaitility.Awaitility;
import org.eclipse.jetty.http.HttpCookie;
import org.eclipse.jetty.http.HttpFields;
import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.http.HttpStatus;
Expand All @@ -41,6 +45,7 @@
import org.eclipse.jetty.io.Content;
import org.eclipse.jetty.io.QuietException;
import org.eclipse.jetty.logging.StacklessLogging;
import org.eclipse.jetty.server.Components;
import org.eclipse.jetty.server.ConnectionMetaData;
import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.server.Context;
Expand All @@ -54,6 +59,8 @@
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.Response;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.Session;
import org.eclipse.jetty.server.TunnelSupport;
import org.eclipse.jetty.server.internal.HttpChannelState;
import org.eclipse.jetty.toolchain.test.FS;
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
Expand Down Expand Up @@ -873,7 +880,7 @@ public void testSetTempDirectoryBad(boolean persistent, File badTempDir)

private static class ScopeListener implements ContextHandler.ContextScopeListener
{
private static final Request NULL = new Request.Wrapper(null);
private static final Request NULL = new Request.Wrapper(new TestableRequest());
private final ThreadLocal<Context> _context = new ThreadLocal<>();
private final ThreadLocal<Request> _request = new ThreadLocal<>();

Expand Down Expand Up @@ -902,6 +909,160 @@ void assertInContext(Context context, Request request)
}
}

private static class TestableRequest implements Request
{
@Override
public Object removeAttribute(String name)
{
return null;
}

@Override
public Object setAttribute(String name, Object attribute)
{
return null;
}

@Override
public Object getAttribute(String name)
{
return null;
}

@Override
public Set<String> getAttributeNameSet()
{
return null;
}

@Override
public void clearAttributes()
{
}

@Override
public String getId()
{
return null;
}

@Override
public Components getComponents()
{
return null;
}

@Override
public ConnectionMetaData getConnectionMetaData()
{
return null;
}

@Override
public String getMethod()
{
return null;
}

@Override
public HttpURI getHttpURI()
{
return null;
}

@Override
public Context getContext()
{
return null;
}

@Override
public HttpFields getHeaders()
{
return null;
}

@Override
public HttpFields getTrailers()
{
return null;
}

public List<HttpCookie> getCookies()
{
return null;
}

@Override
public long getBeginNanoTime()
{
return 0;
}

@Override
public long getHeadersNanoTime()
{
return 0;
}

@Override
public boolean isSecure()
{
return false;
}

@Override
public long getLength()
{
return 0;
}

@Override
public Content.Chunk read()
{
return null;
}

@Override
public boolean consumeAvailable()
{
return false;
}

@Override
public void demand(Runnable demandCallback)
{
}

@Override
public void fail(Throwable failure)
{
}

@Override
public boolean addErrorListener(Predicate<Throwable> onError)
{
return false;
}

@Override
public TunnelSupport getTunnelSupport()
{
return null;
}

@Override
public void addHttpStreamWrapper(Function<HttpStream, HttpStream> wrapper)
{
}

@Override
public Session getSession(boolean create)
{
return null;
}
}

@Test
public void testGraceful() throws Exception
{
Expand Down

0 comments on commit 86e6580

Please sign in to comment.