Skip to content

Commit

Permalink
Merge pull request #5345 from pkriens/issue/5240
Browse files Browse the repository at this point in the history
[remote link] Made tracing optional
  • Loading branch information
pkriens committed Aug 19, 2022
2 parents b545b94 + 252e1db commit 0f84dc5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 6 additions & 2 deletions biz.aQute.remote/src/aQute/remote/util/Link.java
Expand Up @@ -44,6 +44,7 @@ public class Link<L, R> extends Thread implements Closeable {
final AtomicInteger id = new AtomicInteger(10000);
final ConcurrentMap<Integer, Result> promises = new ConcurrentHashMap<>();
final AtomicBoolean quit = new AtomicBoolean(false);
final boolean tracing;
volatile boolean transfer = false;
private ThreadLocal<Integer> msgid = new ThreadLocal<>();

Expand All @@ -69,6 +70,8 @@ public Link(Class<R> remoteType, L local, DataInputStream in, DataOutputStream o
this.local = local == null ? (L) this : local;
this.in = new DataInputStream(in);
this.out = new DataOutputStream(out);
this.tracing = Boolean.getBoolean(Link.class.getName() + ".trace");

}

public Link(Class<R> type, L local, Socket socket) throws IOException {
Expand Down Expand Up @@ -276,7 +279,7 @@ <T> T waitForResult(int id, Type type) throws Exception {
String msg = codec.dec()
.from(result.value)
.get(String.class);
System.out.println("Exception " + msg);
trace("Exception " + msg);
throw new RuntimeException(msg);
}

Expand Down Expand Up @@ -307,7 +310,8 @@ <T> T waitForResult(int id, Type type) throws Exception {
}

private void trace(String string) {
System.out.println("# " + string);
if (tracing)
System.out.println("# " + string);
}

/*
Expand Down
2 changes: 2 additions & 0 deletions docs/_chapters/300-launching.md
Expand Up @@ -266,6 +266,8 @@ It is possible to specity multiple remote clauses. All sections are started simu
* `agent` – The port on which the agent is listening, the default is ${aQute.agent.server.port}.
* `timeout` – Timeout in seconds for the debug connection

Additionally, the communication can be traced by setting the `aQute.remote.util.Link.trace` system property to `true` on the target system.

### Example bndrun

An example remote bndrun file:
Expand Down

0 comments on commit 0f84dc5

Please sign in to comment.