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
remove unnecessary VisibleForTesting annotation #850
Conversation
@@ -324,12 +322,10 @@ protected void touchParent( final String id ) { | |||
|
|||
/* Overriding so unit test can mock. */ | |||
@Override | |||
@VisibleForTesting |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These annotations are actually helpful... although there may be another way of accomplishing the same goal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If they are helpful, that's different, but may I ask how are they helpful? My understanding is that this annotation will relax the visibility of private methods during testing. All of our uses of it, though, are as decorators on protected and public functions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That annotation is purely informative. It's not within the power of any annotation to break visibility.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I find them helpful from an informational perspective. public
and protected
methods mean increased responsibility. It is useful to know that some methods have been relaxed from private
for the sake of unit testing.
Instead of simply removing these annotations, I would suggest replacing them with a prominent comment/javadoc that communicates the same idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I even want to remove the annotation. What is the advantage of so doing and adding Javadocs? Is it the Guava dependency that bugs you, @acoburn ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, well, if it's blocking OSGi, that's a good reason to remove it in favor of docs. Why on Earth is MODE loading Cassandra drivers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...and can we prevent such loading?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Modeshape allows you to optionally store binary files in Cassandra, so it lists this as a dependency. In principle, modeshape's MANIFEST.MF file should specify the dependency as optional, but we are not so lucky. That is, the dependency is unnecessary from the perspective of fcrepo-kernel-modeshape, but from the modeshape-jcr module, it is a hard dependency.
The confusing thing, though, is that the datastax module shows the guava import can be anything in the version range [14-19) https://github.com/datastax/java-driver/blob/2.0/driver-core/pom.xml#L192, but when I actually try to start that bundle in Karaf, it claims to require only version 16.
And no, I can't prevent the cassandra drivers from needing to be loaded. Nor have I had any luck with setting the resolution of that bundle to optional. The problem appears to be that it is a transitive dependency, and so it's rather out of our control unless we start doing things like creating a fat jar, shading, etc, etc (which I'd prefer to avoid).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OSGi trumps @VisibleForTesting.
...but please leave a comment or the like in the code to communicate the same idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm actually inclined to close this PR, leaving the @VisibleForTesting annotation in place. The issue I'm trying to resolve at present relates to version mismatches 18.0 != 16.0.1, but @VisibleForTesting is available in both versions, so even if we downgraded to guava 16.0.1, we could still use this annotation.
See: https://jira.duraspace.org/browse/FCREPO-1647