zookeeper-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [zookeeper] symat opened a new pull request #1056: ZOOKEEPER-3495: fix SnapshotDigestTest to work with JDK12+
Date Thu, 15 Aug 2019 16:45:22 GMT
symat opened a new pull request #1056: ZOOKEEPER-3495: fix SnapshotDigestTest to work with
JDK12+
URL: https://github.com/apache/zookeeper/pull/1056
 
 
   The problem with the test `SnapshotDigestTest.testDifferentDigestVersion` was that it used
reflection to change a final static value in `DigestCalculator`, what is no longer supported
with JDK 12+ (see [JDK-8210522](https://bugs.openjdk.java.net/browse/JDK-8210522))
   
   I think there are still some hacky solutions to go behind these limitations (with [PowerMock](https://github.com/powermock/powermock)
maybe or using [VarHandle as suggested here](https://stackoverflow.com/questions/56039341/get-declared-fields-of-java-lang-reflect-fields-in-jdk12)),
but I think the best is to avoid the situation when we need to poke the static final field.
   
   I changed the fully static `DigestCalculator`, converting it to a static singleton object
with non-static methods / fields. The fields of the singleton object can not be modified from
production code, but we can change them from the tests even in JDK 12 / 13 (as they are not
static final fields).
   
   I tested it locally using openjdk, I hope it will also work in jenkins.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message