Rafael Winterhalter
Rafael Winterhalter

Reputation: 44032

Hot-fixing a bug in a third-party library dependency

I found a minor bug in a bigger application framework that I am using. Fixing requires only to change two lines in a single class. I fixed the issue and pushed the changes to the project's repository.

However, I need to release tomorrow. Therefore, I cannot wait until the library is releasing a new version. I am wondering what would be the best way to integrate the patched version into my project:

Thanks for any input on this.

Upvotes: 5

Views: 1290

Answers (3)

LiberQuack
LiberQuack

Reputation: 161

TL;DR;

Visit https://jitpack.io and read how it works


Steps to solve the problem

Supposing the third-party library is on github, simply clone the project, and fix it.

Then use https://jitpack.io. JitPack creates a .jar from your repo (where you fixed the code) and generates a dependency for you like

<dependency>
    <groupId>GITHUB_USER</groupId>
    <artifactId>REPOSITORY</artifactId>
    <version>COMMIT</version>
</dependency>

also you need to explicitly add this remote repository

<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>
  • Fast work-around
  • Simple to do
  • Simple to undo

Upvotes: 2

I think moving dependencies of your project into custom namespaces is not optimal, for several reasons:

  • your modifications will likely not be sent back to the original developers of the dependency.
  • it will be hard to keep up with new dependency versions, so no more bugfixes, no new features, no vulnerability fixes from third-party developers and contributors.
  • my experience is that over time it gets forgotten how and why the custom namespaced dependency got modified. This will result in this part of the project being not only deprecated, but also untouchable, as no one will know what'll break when replacing it.

I agree that a workflow using Jitpack is the best solution. I wrote a blog post with a detailed guide for doing it with only a couple minutes of overhead: https://5am.technology/2016/12/fix-bugs-third-party-dependency-jitpack/

Upvotes: 1

Rafael Winterhalter
Rafael Winterhalter

Reputation: 44032

I ended up building the project separately and moving this version to another namespace. This is apparently not so uncommon. For example Hibernate keeps cglib in its own namespace in order to avoid version conflicts due to API changes.

  • The first suggested solution had a problem when the project I used was also used in another dependency what led to that both my modified version and the normal version were on the class path what led to very strange behavior due to naming conflicts.

  • The second and third suggestion had similar problems as the first suggestion. Additionally, I broke compatibility to other versions of the dependency.

Even it sounds painful: Moving out of the namespace and providing a seperate build is a must, even if you only change a few lines of code.

Upvotes: 3

Related Questions