Package ca.cdr.test.app.clients.common
Record Class HttpClientOwnership
java.lang.Object
java.lang.Record
ca.cdr.test.app.clients.common.HttpClientOwnership
- Record Components:
client- the client to issue requests onowned- true in the owned case, socloseIfOwned()closesclient
public record HttpClientOwnership(@Nonnull SmileTestHttpClient client, boolean owned)
extends Record
The HTTP client a test client issues on, and whether closing that test client should close the
HTTP client with it. There are two cases, decided by
resolve(SmileTestHttpClient):
- Borrowed ? the caller supplied a
SmileTestHttpClient, typically a harness lending one client to everything it hands out. The connection pool and cookie store stay the supplier's, so closing the test client must leave them up for the siblings still using them. - Owned ? the caller supplied null, so a client was built here. Nothing else holds a reference, so closing the test client is the only thing that can release the pool.
-
Constructor Summary
ConstructorsConstructorDescriptionHttpClientOwnership(SmileTestHttpClient client, boolean owned) Creates an instance of aHttpClientOwnershiprecord class. -
Method Summary
Modifier and TypeMethodDescriptionclient()Returns the value of theclientrecord component.voidReleases the connection pool when this client built it, and does nothing when the pool was supplied by a caller that still needs it.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.booleanowned()Returns the value of theownedrecord component.static HttpClientOwnershipresolve(SmileTestHttpClient theSuppliedClient) Decides which of the two cases applies for a client built withtheSuppliedClient, building a client when the caller supplied none.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
Method Details
-
resolve
Decides which of the two cases applies for a client built withtheSuppliedClient, building a client when the caller supplied none.- Parameters:
theSuppliedClient- the client the caller supplied, or null to build one
-
closeIfOwned
Releases the connection pool when this client built it, and does nothing when the pool was supplied by a caller that still needs it. -
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
client
Returns the value of theclientrecord component.- Returns:
- the value of the
clientrecord component
-
owned
Returns the value of theownedrecord component.- Returns:
- the value of the
ownedrecord component
-