Bug #74690 ProfilerEvent hostName has no getter()
Submitted: 4 Nov 2014 21:47 Modified: 24 May 2019 18:14
Reporter: Jay W Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / J Severity:S4 (Feature request)
Version:5.1.33 OS:Any
Assigned to: Filipe Silva CPU Architecture:Any

[4 Nov 2014 21:47] Jay W
Description:
I am trying to write a custom logger/profiler for Connector/J. The objects it is receiving are ProfilerEvents[1]. This object generally contains what I want, except that I have no obvious way of getting the hostname. It appears that there is a protected hostName member variable, so I'm wondering if the lack of a getter is just an oversight. Most of the other protected member variables have public getters.

[1]: http://www.docjar.com/docs/api/com/mysql/jdbc/profiler/ProfilerEvent.html

How to repeat:
N/A

Suggested fix:
Add method to ProfilerEvent class: public String getHostName()
[11 Nov 2014 15:40] Jay W
Following up:

I coerced my ability to read the field via reflection. However, I found that it was always empty. I later discovered that I could obtain the same information from the MySQL connection with getHost() during the call to init().

I will leave this ticket open since I still don't see what hostName is being used for and may be a candidate for spring cleaning.
[11 Nov 2014 18:27] Filipe Silva
Hi Jay,

Thank you for this bug report.

The behavior observed is as you described. There is only one difference though. The host name in ProfilerEvent should identify the host where the event happened while in the Connection it identifies the host we are connected to.

At the end, knowing the host where the event happened shouldn't be hard to get by other means so maybe it isn't a big issue for the ProfilerEvent class, but, yes, this class could use a little spring cleaning.
[24 May 2019 18:14] Daniel So
Posted by developer:
 
Added the following entry to the C/J 8.0.17 and 5.1.48 changelog:

"A number of private parameters of ProfilerEvents(for example, hostname) had no getters for accessing them from outside of the class instance. Getter methods have now been added for all the parameters of the class."