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

java.lang.IllegalArgumentException: Self-suppression not permitted #5239

Closed
971758118 opened this issue Feb 17, 2023 · 4 comments · Fixed by #5318
Closed

java.lang.IllegalArgumentException: Self-suppression not permitted #5239

971758118 opened this issue Feb 17, 2023 · 4 comments · Fixed by #5318
Labels
Bug Something isn't working help wanted

Comments

@971758118
Copy link

Describe the bug
java.lang.IllegalArgumentException: Self-suppression not permitted
at io.opentelemetry.exporter.internal.marshal.Marshaler.b(Marshaler.java:4)
at io.opentelemetry.exporter.internal.okhttp.ProtoRequestBody.writeTo

Steps to reproduce
ProtoRequestBody
public void writeTo(BufferedSink paramBufferedSink) throws IOException {
this.marshaler.writeBinaryTo(paramBufferedSink.outputStream());
}

Marshaler
public final void writeBinaryTo(OutputStream paramOutputStream) throws IOException {
ProtoSerializer protoSerializer = new ProtoSerializer(paramOutputStream);
try {
writeTo(protoSerializer);
return;
} finally {
try {
protoSerializer.close();
} finally {
protoSerializer = null;
}
}
}

ProtoSerializer implements AutoCloseable, so close() will execute
public void close() throws IOException {
this.output.flush();
this.idCache.clear();
}

in Marshaler.writeBinaryTo(), try() and close() throw a same Throwable instance , so Throwable.addSuppressed() will throw new IllegalArgumentException(SELF_SUPPRESSION_MESSAGE, exception);

What version are you using?
1.21.1

@971758118
Copy link
Author

971758118 commented Feb 20, 2023

@trask https://github.com/open-telemetry/opentelemetry-java/issues/7848 that is a duplicate question but not resove, so will there be a fix plan?
eg:
ProtoSerializer.java
@OverRide
public void close() throws IOException {
try {
output.flush();
idCache.clear();
} catch (IOException e) {
throw new IOException(e);
}
}

@971758118 971758118 reopened this Feb 20, 2023
@jkwatson
Copy link
Contributor

@971758118 are you able to provide a fix? Thanks!

@971758118
Copy link
Author

971758118 commented Mar 1, 2023

Here's a fix, but it requires an SDK fix

in ProtoSerializer.java

output.flush() and idCache.clear() surround with try/catch

@OverRide
public void close() throws IOException {
try {
output.flush();
idCache.clear();
} catch (IOException e) {
throw new IOException(e);
}
}

@jkwatson
Copy link
Contributor

jkwatson commented Mar 1, 2023

I meant, can you submit a PR for the fix?

971758118 pushed a commit to 971758118/opentelemetry-java that referenced this issue Mar 2, 2023
… permitted

Issues open-telemetry#5239

Signed-off-by: dujiaxu <dujiaxu@xiaomi.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working help wanted
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants