Fix to mend debug logging to allow programmatic level setting. #438
Conversation
…ready set. Allows the caller to detect when unset. Thus allowing connection Ctor to use programmatic log level value. Added test cases to check PGProperty method working properly.
@whitingjr not sure why it failed Travis CI ? |
The tests failed:
|
That testcase failed because the isPresent method was not working correctly beforehand. Then my commit corrected it. |
Thanks!!! Dave Cramer On 2 December 2015 at 10:44, Jeremy Whiting notifications@github.com
|
Looks like it is still failing Dave Cramer On 2 December 2015 at 10:54, Dave Cramer davecramer@gmail.com wrote:
|
Yes, looks like the CI build has ssl tests enabled. Which means the ssl property is set when the jvm starts. |
I see a way. Use the System.setProperties method to replace all the props. |
public String getSetString(Properties properties) | ||
{ | ||
Object o = properties.get(_name); | ||
if (o instanceof String) |
davecramer
Dec 2, 2015
Member
seems like you should check for null before checking instanceof ?
seems like you should check for null before checking instanceof ?
whitingjr
Dec 2, 2015
Author
Contributor
shouldn't be necessary. instanceof only works on the reference. not the object.
in the situation the reference is null then the instanceof condition returns false.
shouldn't be necessary. instanceof only works on the reference. not the object.
in the situation the reference is null then the instanceof condition returns false.
@@ -58,6 +58,11 @@ public static String getURL(String server, int port) | |||
sendBufferSize = "&sendBufferSize="+getSendBufferSize(); | |||
} | |||
|
|||
String ssl = ""; |
vlsi
Dec 2, 2015
Member
Please use spaces, not tabs
Please use spaces, not tabs
whitingjr
Dec 2, 2015
Author
Contributor
Yes will replace them with spaces.
Yes will replace them with spaces.
{ | ||
Properties empty = new Properties(); | ||
assertNull(PGProperty.LOG_LEVEL.getSetString(empty)); | ||
assertNull(PGProperty.LOG_LEVEL.getSetString(empty)); |
vlsi
Dec 2, 2015
Member
Do you really mean "double check" here?
Do you really mean "double check" here?
whitingjr
Dec 2, 2015
Author
Contributor
Well spotted. No I hadn't meant to duplicate line 238. Will remove the duplicate.
Well spotted. No I hadn't meant to duplicate line 238. Will remove the duplicate.
davecramer
Dec 2, 2015
Member
We must be able to avoid the NPE in the code, no ?
Dave Cramer
On 2 December 2015 at 11:41, Jeremy Whiting notifications@github.com
wrote:
In org/postgresql/test/jdbc2/PGPropertyTest.java
#438 (comment):
- /**
-
\* Check whether the isPresent method really works.
-
*/
- public void testPresenceCheck()
- {
-
Properties empty = new Properties();
-
Object value = PGProperty.LOG_LEVEL.get(empty);
-
assertNotNull(value);
-
Assert.assertFalse(PGProperty.LOG_LEVEL.isPresent(empty));
- }
- public void testNullValue()
- {
-
Properties empty = new Properties();
-
assertNull(PGProperty.LOG_LEVEL.getSetString(empty));
-
assertNull(PGProperty.LOG_LEVEL.getSetString(empty));
Well spotted. No I hadn't meant to duplicate line 238. Will remove the
duplicate.
—
Reply to this email directly or view it on GitHub
https://github.com/pgjdbc/pgjdbc/pull/438/files#r46438994.
We must be able to avoid the NPE in the code, no ?
Dave Cramer
On 2 December 2015 at 11:41, Jeremy Whiting notifications@github.com
wrote:
In org/postgresql/test/jdbc2/PGPropertyTest.java
#438 (comment):
- /**
\* Check whether the isPresent method really works.
*/
- public void testPresenceCheck()
- {
Properties empty = new Properties();
Object value = PGProperty.LOG_LEVEL.get(empty);
assertNotNull(value);
Assert.assertFalse(PGProperty.LOG_LEVEL.isPresent(empty));
- }
- public void testNullValue()
- {
Properties empty = new Properties();
assertNull(PGProperty.LOG_LEVEL.getSetString(empty));
assertNull(PGProperty.LOG_LEVEL.getSetString(empty));
Well spotted. No I hadn't meant to duplicate line 238. Will remove the
duplicate.—
Reply to this email directly or view it on GitHub
https://github.com/pgjdbc/pgjdbc/pull/438/files#r46438994.
getString() checks instanceof String before checking for null Dave Cramer On 2 December 2015 at 11:13, Jeremy Whiting notifications@github.com
|
assertNull(PGProperty.LOG_LEVEL.getSetString(empty)); | ||
Properties withLogging = new Properties(); | ||
withLogging.setProperty(PGProperty.LOG_LEVEL.getName(), "2"); | ||
assertNotNull(PGProperty.LOG_LEVEL.getSetString(withLogging)); |
vlsi
Dec 2, 2015
Member
Could you please move that to separate test method?
Could you please move that to separate test method?
…ge to assertion test. Safely remove existing ssl property.
@davecramer "getString() checks instanceof String before checking for null" |
Looks like this is passing now. |
Is there anything else considered necessary to make this PR suitable to pull into master ? |
no, it's fine. I was caught up with the maven pull |
Fix: to mend debug logging to allow programmatic level setting.
This PR fixes changes introduced in 1205 release.
It adds a new method to PGProperty to return a property value without using the default. Allowing NULL to be returned.
Changed the impl of isPresent method. To actually work.
Added two test cases. To check isPresent and getSetString methods both work.
The fixed isPresent method smokes out an issue in an SSL test case. Now the method is fixed this test fails now.