New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: avoid reflective access to TimeZone.defaultTimeZone in Java 9+ #1002

Merged
merged 1 commit into from Nov 28, 2017

Conversation

Projects
None yet
3 participants
@vlsi
Member

vlsi commented Oct 31, 2017

closes #986

@vlsi vlsi added this to the 42.1.5 milestone Oct 31, 2017

@jorsol

Is not better to use the preprocessor to do the version check?

tzField = null;
// Avoid reflective access in Java 9+
if (javaVersion.startsWith("1.") && javaVersion.length() == 3
&& javaVersion.charAt(2) >= '4' && javaVersion.charAt(2) <= 8) {

This comment has been minimized.

@jorsol

jorsol Oct 31, 2017

Contributor

it should be chatAt(2) >= '6' and you forgot the quotes for '8'.

This comment has been minimized.

@vlsi

vlsi Oct 31, 2017

Member

Thanks, makes sense

Object tzFromField = tzField.get(null);
if (defaultTz == null || !defaultTz.equals(tzFromField)) {
tzField = null;
String javaVersion = System.getProperty("java.version");

This comment has been minimized.

@jorsol

jorsol Oct 31, 2017

Contributor

I think the Java version check must be in an utility method.

@vlsi

This comment has been minimized.

Member

vlsi commented Oct 31, 2017

Is not better to use the preprocessor to do the version check?

preprocessor is compile-time thing, while the point is to check JRE at runtime.
We have no specific jar for Java 9, so the codebase for 8 and 9 is the same.

@codecov-io

This comment has been minimized.

codecov-io commented Oct 31, 2017

Codecov Report

Merging #1002 into master will increase coverage by 0.15%.
The diff coverage is 20%.

@@             Coverage Diff              @@
##             master    #1002      +/-   ##
============================================
+ Coverage     65.71%   65.87%   +0.15%     
+ Complexity     3604     3579      -25     
============================================
  Files           168      167       -1     
  Lines         15491    15320     -171     
  Branches       2494     2482      -12     
============================================
- Hits          10180    10092      -88     
+ Misses         4134     4050      -84     
- Partials       1177     1178       +1

@vlsi vlsi merged commit fd0eeee into pgjdbc:master Nov 28, 2017

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@vlsi vlsi modified the milestones: 42.1.5, 42.2.0 Jan 8, 2018

rhavermans added a commit to bolcom/pgjdbc that referenced this pull request Jul 13, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment