Skip to content

com.google.api.client.http.HttpRequest.execute doesn't close Span #788

Description

@abdolence

Environment details

  1. Core/Tracing API
  2. OS type and version: Linux
  3. Java version: 1.8
  4. google-http-client version(s): 1.30.1

Steps to reproduce

  1. Just call ServiceOptions.getDefaultProjectId() with opencensus Tracer enabled (I'm using Stackdriver). It apparently creates a span in com.google.api.client.http.HttpRequest.execute(), and throws inner exception `(UnknownHostException : metadata.google.internal) and forgetting to close span at this moment in the exception handler.
    For my version of google http client this place:
catch (IOException e) {
        if (!retryOnExecuteIOException
            && (ioExceptionHandler == null
                || !ioExceptionHandler.handleIOException(this, retryRequest))) {
          throw e;
        }
        // Save the exception in case the retries do not work and we need to re-throw it later.
        executeException = e;
        if (loggable) {
          logger.log(Level.WARNING, "exception thrown while executing request", e);
        }
      } finally {
        ws.close();
      }
  1. It also will be found by opencensus finalize afterwards:
Aug 10, 2019 7:45:59 PM io.opencensus.implcore.trace.RecordEventsSpanImpl finalize
SEVERE: Span Sent.com.google.api.client.http.HttpRequest.execute is GC'ed without being ended.

Code example

ServiceOptions.getDefaultProjectId()

Any additional information below

Metadata

Metadata

Assignees

Labels

priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions