Skip to content
This repository has been archived by the owner on Jun 1, 2022. It is now read-only.

Commit

Permalink
Df/1.3.1 (#468)
Browse files Browse the repository at this point in the history
* Fix flaky unit test. (#465)
* Override `toString` in various places for better logging (#467)
* Expose `outgoingHttpUrl` for better logging.
* Fix Java14 build

Signed-off-by: David Fuelling <sappenin@gmail.com>
  • Loading branch information
sappenin authored Aug 17, 2020
1 parent c27038a commit 29cf648
Show file tree
Hide file tree
Showing 37 changed files with 137 additions and 69 deletions.
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ _run:
JDK14_URL=$(curl -s https://jdk.java.net/14/ | egrep -o "https://download.java.net/java/GA/jdk14.*?/.*?linux-x64.*?tar.gz" | head -1)
wget $JDK14_URL -O /tmp/openjdk14.tar.gz
tar -xvzf /tmp/openjdk14.tar.gz
sudo mv jdk-14.0.1/ /usr/lib/jvm/
sudo mv jdk-14.0.2/ /usr/lib/jvm/
jobs:
build:
Expand Down Expand Up @@ -272,7 +272,7 @@ jobs:
environment:
# Customize the JVM maximum heap limit
MAVEN_OPTS: -Xmx3200m
JAVA_HOME: /usr/lib/jvm/jdk-14.0.1/
JAVA_HOME: /usr/lib/jvm/jdk-14.0.2/

steps:
- run:
Expand Down
2 changes: 1 addition & 1 deletion btp-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>quilt-parent</artifactId>
<groupId>org.interledger</groupId>
<version>1.3.0</version>
<version>1.3.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion codecs-parent/codecs-btp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.interledger</groupId>
<artifactId>codecs-parent</artifactId>
<version>1.3.0</version>
<version>1.3.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion codecs-parent/codecs-framework/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.interledger</groupId>
<artifactId>codecs-parent</artifactId>
<version>1.3.0</version>
<version>1.3.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion codecs-parent/codecs-ildcp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.interledger</groupId>
<artifactId>codecs-parent</artifactId>
<version>1.3.0</version>
<version>1.3.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion codecs-parent/codecs-ilp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.interledger</groupId>
<artifactId>codecs-parent</artifactId>
<version>1.3.0</version>
<version>1.3.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion codecs-parent/codecs-stream/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.interledger</groupId>
<artifactId>codecs-parent</artifactId>
<version>1.3.0</version>
<version>1.3.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion codecs-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.interledger</groupId>
<artifactId>quilt-parent</artifactId>
<version>1.3.0</version>
<version>1.3.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion examples-parent/ilp-emitters/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.interledger</groupId>
<artifactId>examples-parent</artifactId>
<version>1.3.0</version>
<version>1.3.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion examples-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.interledger</groupId>
<artifactId>quilt-parent</artifactId>
<version>1.3.0</version>
<version>1.3.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion examples-parent/send-money/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.interledger</groupId>
<artifactId>examples-parent</artifactId>
<version>1.3.0</version>
<version>1.3.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion ildcp-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>quilt-parent</artifactId>
<groupId>org.interledger</groupId>
<version>1.3.0</version>
<version>1.3.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion ilp-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.interledger</groupId>
<artifactId>quilt-parent</artifactId>
<version>1.3.0</version>
<version>1.3.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion jackson-datatypes/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.interledger</groupId>
<artifactId>quilt-parent</artifactId>
<version>1.3.0</version>
<version>1.3.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion link-parent/link-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.interledger</groupId>
<artifactId>link-parent</artifactId>
<version>1.3.0</version>
<version>1.3.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import java.util.Objects;
import java.util.Optional;
import java.util.StringJoiner;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Supplier;

Expand Down Expand Up @@ -98,4 +99,13 @@ public void unregisterLinkHandler() {
public Optional<LinkHandler> getLinkHandler() {
return Optional.ofNullable(linkHandlerAtomicReference.get());
}

@Override
public String toString() {
return new StringJoiner(", ", AbstractLink.class.getSimpleName() + "[", "]")
.add("linkId=" + linkId)
.add("linkSettings=" + linkSettings)
.add("operatorAddressSupplier=" + operatorAddressSupplier)
.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,20 @@ public interface LinkFactory {
/**
* Construct a new instance of {@link Link} using the supplied inputs.
*
* @param clazz A {@link Class} to satisfy Java generics.
* @param operatorAddressSupplier A supplier for the ILP address of this node operating this Link. This value may be
* uninitialized, for example, in cases where the Link obtains its address from a *
* parent node using IL-DCP. If an ILP address has not been assigned, or it has not
* been obtained via IL-DCP, then this value will by default be {@link Link#SELF}.
* @param linkSettings A {@link LinkSettings} to use in order to construct a {@link Link}.
* @param <LS> A type that extends {@link LinkSettings}.
* @param <L> A type that extends {@link Link}.
* @param clazz A {@link Class} to satisfy Java generics.
*
* @return An instance of {@code L}.
*/
@SuppressWarnings("MethodTypeParameterName")
default <LS extends LinkSettings, L extends Link<LS>> L constructLink(
final Class<L> clazz, Supplier<InterledgerAddress> operatorAddressSupplier, final LS linkSettings
Supplier<InterledgerAddress> operatorAddressSupplier, final LS linkSettings, final Class<L> clazz
) {
return (L) this.constructLink(operatorAddressSupplier, linkSettings);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import org.immutables.value.Value;

import java.util.Map;
import java.util.StringJoiner;

/**
* Configuration information relating to a {@link Link}.
Expand Down Expand Up @@ -56,5 +57,12 @@ public AbstractLinkSettings normalize() {
}
}

@Override
public String toString() {
return new StringJoiner(", ", AbstractLinkSettings.class.getSimpleName() + "[", "]")
.add("linkType=" + getLinkType())
.add("customSettings=" + getCustomSettings())
.toString();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import java.util.Objects;
import java.util.Optional;
import java.util.StringJoiner;
import java.util.function.Supplier;

/**
Expand Down Expand Up @@ -94,4 +95,13 @@ InterledgerResponsePacket sleepAndReject(InterledgerPreparePacket preparePacket,
return packetRejector.reject(this.getLinkId(), preparePacket, InterledgerErrorCode.T03_CONNECTOR_BUSY,
"Loopback set to exceed timeout via simulate_timeout=T03");
}

@Override
public String toString() {
return new StringJoiner(", ", LoopbackLink.class.getSimpleName() + "[", "]")
.add("linkId=" + getLinkId())
.add("operatorAddressSupplier=" + getOperatorAddressSupplier())
.add("linkSettings=" + getLinkSettings())
.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import java.util.Base64;
import java.util.Objects;
import java.util.StringJoiner;
import java.util.function.Supplier;

/**
Expand Down Expand Up @@ -78,4 +79,13 @@ public InterledgerResponsePacket sendPacket(final InterledgerPreparePacket prepa
return rejectPacket;
}
}

@Override
public String toString() {
return new StringJoiner(", ", PingLoopbackLink.class.getSimpleName() + "[", "]")
.add("linkId=" + getLinkId())
.add("operatorAddressSupplier=" + getOperatorAddressSupplier())
.add("linkSettings=" + getLinkSettings())
.toString();
}
}
2 changes: 1 addition & 1 deletion link-parent/link-ilp-over-http/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.interledger</groupId>
<artifactId>link-parent</artifactId>
<version>1.3.0</version>
<version>1.3.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import java.time.Instant;
import java.util.Objects;
import java.util.Optional;
import java.util.StringJoiner;
import java.util.function.Supplier;
import java.util.stream.Stream;

Expand All @@ -58,6 +59,7 @@
*/
public class IlpOverHttpLink extends AbstractLink<IlpOverHttpLinkSettings> implements Link<IlpOverHttpLinkSettings> {

private static final String BEARER_WITH_SPACE = BEARER + " ";
public static final String LINK_TYPE_STRING = "ILP_OVER_HTTP";
public static final LinkType LINK_TYPE = LinkType.of(LINK_TYPE_STRING);

Expand All @@ -83,6 +85,7 @@ public class IlpOverHttpLink extends AbstractLink<IlpOverHttpLinkSettings> imple

private final HttpUrl outgoingUrl;


/**
* Required-args Constructor.
*
Expand Down Expand Up @@ -123,9 +126,9 @@ public InterledgerResponsePacket sendPacket(final InterledgerPreparePacket prepa
Objects.requireNonNull(preparePacket);

if (preparePacket.getExpiresAt() != null &&
okHttpClient.readTimeoutMillis() <= Duration.between(Instant.now(), preparePacket.getExpiresAt()).toMillis()) {
okHttpClient.readTimeoutMillis() <= Duration.between(Instant.now(), preparePacket.getExpiresAt()).toMillis()) {
logger.warn("OkHttpClient read timeout is shorter than the Prepare Packet's timeout. " +
"This may result in an HTTP timeout while unexpired ILP packets are in flight.");
"This may result in an HTTP timeout while unexpired ILP packets are in flight.");
}

final Request okHttpRequest;
Expand Down Expand Up @@ -154,18 +157,18 @@ public InterledgerResponsePacket sendPacket(final InterledgerPreparePacket prepa
if (response.code() == 401 || response.code() == 403) {
// If this code is returned, we know the Link is misconfigured
customErrorMessage = String.format("Unable to connect to remote ILP-over-HTTP Link: Invalid Bearer " +
"Token. response=%s", response);
"Token. response=%s", response);
logger.error(customErrorMessage);
}

String message = Stream.of(
customErrorMessage,
problem.map(Problem::getTitle).orElse(null),
errorResponseBody
customErrorMessage,
problem.map(Problem::getTitle).orElse(null),
errorResponseBody
)
.filter(Objects::nonNull)
.findFirst()
.get();
.filter(Objects::nonNull)
.findFirst()
.get();
// The request was bad for some reason, likely due to whatever is in the packet.
rejectPacket = InterledgerRejectPacket.builder()
.triggeredBy(getOperatorAddressSupplier().get())
Expand Down Expand Up @@ -249,7 +252,6 @@ public void testConnection() {
}
}

private final String BEARER_WITH_SPACE = BEARER + " ";
/**
* Construct headers for an ILP-over-HTTP request.
*
Expand Down Expand Up @@ -326,4 +328,22 @@ private Request constructSendPacketRequest(final InterledgerPreparePacket prepar
}
}

@Override
public String toString() {
return new StringJoiner(", ", IlpOverHttpLink.class.getSimpleName() + "[", "]")
.add("linkId=" + getLinkId())
.add("operatorAddressSupplier=" + getOperatorAddressSupplier())
.add("outgoingUrl=" + outgoingUrl)
.add("linkSettings=" + getLinkSettings())
.toString();
}

/**
* Accessor for the "outgoing" URL that this link uses to make outgoing HTTP requests to its peer.
*
* @return A {@link okhttp3.HttpUrl}.
*/
public HttpUrl getOutgoingUrl() {
return this.outgoingUrl;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

import com.fasterxml.jackson.databind.ObjectMapper;
import okhttp3.OkHttpClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Objects;
import java.util.function.Supplier;
Expand All @@ -30,8 +28,6 @@ public class IlpOverHttpLinkFactory implements LinkFactory {
private final ObjectMapper objectMapper;
private final CodecContext ilpCodecContext;

private final Logger logger = LoggerFactory.getLogger(this.getClass());

/**
* Required-args Constructor.
*
Expand Down
Loading

0 comments on commit 29cf648

Please sign in to comment.