As a developer the worst 5 words that can ever come from your mouth is “It Works On My Machine”. Your code works, passes all its tests, but when the client runs it the code fails in some way and you can’t replicate the problem.
No need to wait for a conclusion before the story. Its your fault. Get used to it. It is unlikely that you have discovered a bug in Java or any language you are using. No need to waste time googling “Bugs in Java”. Look at your code, its your fault.
I had such an experience and thanks to the eagle eyes of one of my students the error was found quickly. Here is what happened.
I asked my students to run sample code that will send and receive a plain text email using the Jodd Email library. This program was initially written in 2015 but had not been updated since then. When I reviewed it for use this semester, I had to deal with changes to the Jodd API. Nothing serious, just annoying. With the changes made I ran the code. It only uses a unit test to send and receive. Success, it worked, and so I pushed the update to the repository and told my students about it.
It did not take long to get a report about the unit test failing. How could this be? I ran the code again and it worked fine for me “on my machine”. This is where a student spotted the problem. In the unit test I had a line that read:
I had used a literal string to define the To: field. The problem was that this address was going to be different for every student as they were told to use their Gmail accounts. The repo had my Gmail credentials removed. By neglecting this line I had a program that could only pass its test if it’s To: field read “firstname.lastname@example.org” which is what I used. Therefore, it always worked on my machine.
The fix was easy. The new line reads:
Case closed. Another case of “It works on my machine” resolved.