Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port ee9 BlockingTest to ee10/11 #12635

Merged
merged 26 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
771e3d1
port ee9 BlockingTest to ee10 and ee11 + fix bugs
lorban Dec 12, 2024
81089c0
improve locking and logging
lorban Dec 17, 2024
cc07972
cleanup test
lorban Dec 17, 2024
b6a73b9
Merge remote-tracking branch 'origin/jetty-12.1.x' into jetty-12.1.x-…
lorban Dec 18, 2024
9d2ab16
revert
lorban Dec 18, 2024
01b15a4
cleanups + tolerate AsyncContext.complete() throwing
lorban Dec 18, 2024
b6a7854
revert
lorban Dec 18, 2024
3332a6d
Revert "revert"
lorban Dec 18, 2024
048d5e1
fix potential usage of buffer after release in close
lorban Dec 18, 2024
e3ce806
Merge remote-tracking branch 'origin/jetty-12.1.x' into jetty-12.1.x-…
lorban Jan 7, 2025
054f268
Merge remote-tracking branch 'origin/jetty-12.1.x' into jetty-12.1.x-…
lorban Jan 8, 2025
111337f
fix BlockingContentProducer staying blocked on semaphore when an erro…
lorban Jan 8, 2025
ca45a0b
add missing retains
lorban Jan 8, 2025
4e81267
fix retains
lorban Jan 8, 2025
2289f42
add null check
lorban Jan 8, 2025
f2636dd
revert extra retains
lorban Jan 8, 2025
d23d183
mark test as flaky for now
lorban Jan 8, 2025
7d0e380
fix fail
lorban Jan 8, 2025
d1ec294
Merge remote-tracking branch 'origin/jetty-12.1.x' into jetty-12.1.x-…
lorban Jan 9, 2025
f7c834d
Merge remote-tracking branch 'origin/jetty-12.1.x' into jetty-12.1.x-…
lorban Jan 14, 2025
14e12f0
disable flaky test
lorban Jan 23, 2025
67e4ade
Merge remote-tracking branch 'origin/jetty-12.1.x' into jetty-12.1.x-…
lorban Jan 23, 2025
c49c42c
add javadoc
lorban Jan 24, 2025
8e45e5b
add javadoc
lorban Jan 24, 2025
51c1d29
do not throw when writing 100-continue is not necessary
lorban Jan 24, 2025
a17584e
use RBB.writeTo() to write aggregate & fix retain/release bug exposed…
lorban Jan 24, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ public Throwable fillInStackTrace()
{
return this;
}

@Override
public String toString()
{
return "ACQUIRED";
}
};
private static final Throwable SUCCEEDED = new Throwable()
{
Expand All @@ -88,6 +94,12 @@ public Throwable fillInStackTrace()
{
return this;
}

@Override
public String toString()
{
return "SUCCEEDED";
}
};

public interface Runnable extends java.lang.Runnable, AutoCloseable, Invocable
Expand Down Expand Up @@ -434,5 +446,11 @@ public Runnable runnable() throws IOException
_lock.unlock();
}
}

@Override
public String toString()
{
return "%s@%x[c=%s]".formatted(getClass().getSimpleName(), hashCode(), _completed);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

package org.eclipse.jetty.util;

import java.io.PrintWriter;
import java.io.StringWriter;
import java.lang.reflect.Constructor;
import java.util.Arrays;
import java.util.List;
Expand Down Expand Up @@ -466,6 +468,20 @@ public static <T> T get(CompletableFuture<T> completableFuture)
}
}

/**
* <p>Convert a {@link Throwable} to a string equivalent to what {@link Throwable#printStackTrace()} prints.</p>
* @param throwable The {@link Throwable} or null
* @return a string containing the throwable's full stack trace
*/
public static String toString(Throwable throwable)
{
if (throwable == null)
return "null";
StringWriter sw = new StringWriter();
throwable.printStackTrace(new PrintWriter(sw));
return sw.toString();
}

private ExceptionUtil()
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,30 +371,58 @@ private LockedSemaphore()
this._condition = _lock.newCondition();
}

void assertLocked()
/**
* Checks that the {@link HttpInput} lock scope is correct.
* @throws IllegalStateException if the {@link HttpInput} lock is not held
*/
void assertLocked() throws IllegalStateException
{
if (!_lock.isHeldByCurrentThread())
throw new IllegalStateException("LockedSemaphore must be called within lock scope");
}

/**
* Resets the semaphore's permit count to 0.
*/
void drainPermits()
{
_permits = 0;
}

/**
* Acquires a permit from the semaphore by decreasing the permit count by 1 without ever going negative.
* This method returns immediately when the permit count is >= 1 or it blocks until {@link #release} or {@link #fail()}
* is called to increase the permit count.
* @throws InterruptedException if this call was blocked waiting for the permit count to go above 0 and the thread
* got interrupted.
*/
void acquire() throws InterruptedException
{
while (_permits == 0)
_condition.await();
_permits--;
}

/**
* Releases a permit to the semaphore by increasing the permit count by 1, potentially unblocking one thread
* blocked in {@link #acquire()}.
*/
void release()
{
_permits++;
_condition.signal();
}

/**
* Unblock all threads blocked in {@link #acquire()} and prevent all further calls to {@link #acquire()}
* from blocking until {@link #drainPermits()} is called.
*/
void fail()
{
_permits = Integer.MAX_VALUE;
_condition.signalAll();
}

@Override
public String toString()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,9 @@ public boolean onContentProducible()
// Calling _asyncContentProducer.onContentProducible() changes the channel state from WAITING to WOKEN which
// would prevent the async error thread from noticing that a redispatching is needed.
boolean unready = _asyncContentProducer.isUnready();
boolean error = _asyncContentProducer.isError();
if (LOG.isDebugEnabled())
LOG.debug("onContentProducible releasing semaphore {} unready={}", _semaphore, unready);
LOG.debug("onContentProducible releasing semaphore {} unready={} error={}", _semaphore, unready, error);
// Do not release the semaphore if we are not unready, as certain protocols may call this method
// just after having received the request, not only when they have read all the available content.
if (unready)
Expand All @@ -163,6 +164,8 @@ public boolean onContentProducible()
_asyncContentProducer.getServletChannel().getServletRequestState().onReadIdle();
_semaphore.release();
}
if (error)
_semaphore.fail();
return false;
}
}
Loading
Loading