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

[remote link] Made tracing optional #5345

Merged
merged 1 commit into from Aug 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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