Skip to content

Commit

Permalink
Make Request.Wrapper implement Attributes instead of extending Attrib…
Browse files Browse the repository at this point in the history
…utes.Wrapper

Signed-off-by: Ludovic Orban <[email protected]>
  • Loading branch information
lorban committed Oct 30, 2023
1 parent c22166f commit fbb1524
Showing 1 changed file with 41 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeoutException;
import java.util.function.Consumer;
Expand Down Expand Up @@ -714,14 +716,13 @@ default InvocationType getInvocationType()
/**
* <p>A wrapper for {@code Request} instances.</p>
*/
class Wrapper extends Attributes.Wrapper implements Request
class Wrapper implements Request, Attributes
{
private final Request request;
private final Request wrapped;

public Wrapper(Request wrapped)
{
super(wrapped);
this.request = wrapped;
this.wrapped = Objects.requireNonNull(wrapped);
}

@Override
Expand Down Expand Up @@ -857,10 +858,44 @@ public Session getSession(boolean create)
}

@Override
public Object removeAttribute(String name)
{
return getWrapped().removeAttribute(name);
}

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

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

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

@Override
public Map<String, Object> asAttributeMap()
{
return getWrapped().asAttributeMap();
}

@Override
public void clearAttributes()
{
getWrapped().clearAttributes();
}

public Request getWrapped()
{
// Identical to (Request)super.getWrapped() except that the cast is costly here.
return request;
return wrapped;
}
}

Expand Down

0 comments on commit fbb1524

Please sign in to comment.