Please sign in to comment.
Prepare for git client plugin 2.0.0 coexistence
The git client plugin 2.0.0 release will switch from delivering JGit 3 to JGit 4. JGit 4 requires Java 7 and provides Closeable implementations of its methods that open external resources (like files). JGit 4 removes certain methods (like release()) because they are superseded by the JGit 4 Closeable implementation. Other plugins depend on the git client plugin implementation of JGit. They currently (correctly) assume the JGit provided by the git client plugin is JGit 3. If no changes are made to the plugins which depend on the JGit provided by the git client plugin, those plugins will be broken by the upgrade from JGit 3 to JGit 4. They will report NoSuchMethodError exceptions at run time or may report LinkageError exceptions during class loading on some JVM implementations. This change shows how a plugin which depends on the JGit provided with the git client plugin can be adapted to run with either git client plugin 1.x (JGit 3) to git client plugin 2.x (JGit 4). This is a temporary change until the git plugin (and other plugins) are updated to depend on git client plugin 2.0. Once they depend on git client plugin 2.0, this change can be reverted. Uses reflection to find the close method of RevWalk and TreeWalk classes. When RevWalk and TreeWalk from JGit 3 are loaded, their release() methods are called. When RevWalk and TreeWalk from JGit 4 are loaded, their close() methods are called. Use release(), not dispose() when ending AbstractGitSCMSource.retrieve() The javadoc for dispose() hints that release() is a superset. Using release() is consistent with the rest of the code (and with most git-client-plugin usages).
- Loading branch information...
Showing with 107 additions and 6 deletions.