question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

System.NullReferenceException when using Oracle

See original GitHub issue

Describe the bug Hi guys, I am using oracle with devart provider and my string connection is:

Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=172.21.25.186)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=ORCLCDB)));User Id=SAJDDL; Direct=True;

When I try to get data from database, elastic apm throws a exception:

System.NullReferenceException: Object reference not set to an instance of an object. at Elastic.Apm.Model.DbSpanCommon.GetDestination(String dbConnectionString, Boolean isEmbeddedDb, Nullable1 defaultPort) at Elastic.Apm.Model.DbSpanCommon.EndSpan(Span span, IDbCommand dbCommand, Nullable1 duration) at Elastic.Apm.EntityFrameworkCore.EfCoreDiagnosticListener.OnNext(KeyValuePair`2 kv) at System.Diagnostics.DiagnosticListener.Write(String name, Object value)

The problem happen in this method:

    internal Destination GetDestination(
      string dbConnectionString,
      bool isEmbeddedDb,
      int? defaultPort)
    {
      if (isEmbeddedDb || dbConnectionString == null)
        return (Destination) null;
      Destination destination = this._dbConnectionStringParser.ExtractDestination(dbConnectionString);
      if (!destination.Port.HasValue)  <----- HERE
        destination.Port = defaultPort;
      return destination;
    }

Below I try explain why this happened:

Debuging:

In DbSpanCommon.cs: internal Destination GetDestination image

My string connection: image

DbConnectionStringParser.cs: image

When try to extract destination, I noticed that the value of “key/value” pair is null: image

image

The key is found but destination is null, and when he try to access destination.Port.HasValue:

image

The exception is thrown.

To Reproduce Steps to reproduce the behavior:

  1. Configure oracle string connection like this: Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=172.21.25.186)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=ORCLCDB)));User Id=SAJDDL; Direct=True;

  2. Try to retrieve value from database

Expected behavior

Find database destination and don´t throw NullPointReference exception

Thank you in advance, elastic apm is awesome!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
SergeyKleymancommented, Mar 27, 2020

@fernandolamp Could you please double check if indeed 1.4.0 resolves your issue? While we did include a fix (#749) for another issue (#746) in DB connection string parser I am not sure that fix could have done anything to resolve your issue.

1reaction
fernandolampcommented, Mar 26, 2020

After update to version 1.4.0 the problem was solved

Read more comments on GitHub >

github_iconTop Results From Across the Web

System.NullReferenceException' occurred in Oracle. ...
I've been trying codes and every time I execute it, the same error will appear :'An unhandled exception of type 'System.
Read more >
When opening an oracle connection, connection object is ...
To do this go to (Tools / Nugget Package Manager / Nugget Package Manager for Solution) browse for Oracle References and select Oracle. ......
Read more >
Copy activity Error when copy data from Oracle to Azure ...
Copy activity Error when copy data from Oracle to Azure Databricks. Type=System.NullReferenceException, Message=Object reference not set to ...
Read more >
System.NullReferenceException error - Toad Data Point
I have several critical schedule jobs and this unknown error frequently causes scheduled jobs from completing.
Read more >
Oracle.DataAccess.Client.OracleConnection.Open () error ...
Oracle.DataAccess.Client.OracleConnection.Open () error system. NullReferenceException ... When you use ODAC to link an Oracle database, Conn.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found