diff --git a/exporters/common/src/main/java/io/opentelemetry/exporter/internal/marshal/ProtoSerializer.java b/exporters/common/src/main/java/io/opentelemetry/exporter/internal/marshal/ProtoSerializer.java index 79bcd861ddd..8d815e19a6c 100644 --- a/exporters/common/src/main/java/io/opentelemetry/exporter/internal/marshal/ProtoSerializer.java +++ b/exporters/common/src/main/java/io/opentelemetry/exporter/internal/marshal/ProtoSerializer.java @@ -277,9 +277,9 @@ public void writeSerializedMessage(byte[] protoSerialized, String jsonSerialized @Override public void close() throws IOException { + idCache.clear(); try { output.flush(); - idCache.clear(); } catch (IOException e) { // If close is called automatically as part of try-with-resources, it's possible that // output.flush() will throw the same exception. Re-throwing the same exception in a finally