20

Took me 6+ full days.

The feature does not work. Repro is unknown, so only prod is experiencing the issue.. Which rules out the debugger option. Sometimes there's an entry seen in logs: "java.lang.StringIndexOutOfBoundsException". Nothing more - just that. No stack, no class, no nothing. Is it my code that's buggy? Is it some config? Integration? Unexpected response...? A bug in a lib? Is dimm faulty ir maybe server's shared libs are off?

Turns out I used a closing parentheses instead a closing curly bracket in an error message that's supposed to be interpolated...

String message = "{some-business-rule-related-error-message-key)";

took me 6+ full days... But I found it. Took the rest of that Friday off to walk in a park and enjoy my life :)

Comments
  • 3
    Why the fuck doesn't java complain about that at compile time?!
  • 6
    @Lensflare because it's a string literal, the interpolation resolves on runtime
  • 6
    @carboneum allow me to correct that
    Why the fuck doesn't Java complain about that properly at runtime?!
  • 1
    write a test
  • 1
    @RememberMe ? Why would it? it's a string.
    Why doesn't Python complain about a typo in

    msg = "Some message with application-specific syntax and a typo";

    at runtime?

    Should the PY compiler know that the string in that service representing a particular error message, shall not contain more than 6 words?
  • 0
    @netikras yes but instead of a random index OOB exception it could at least tell you where stuff is breaking, print out the starting parse loc maybe, or something
  • 1
    I don't know about Java but string interpolation in other languages is a special syntax within a string literal and will produce a syntax error if done wrong.
    Or maybe it will just fall back to a normal string literal. I really need to test it...
    But I suppose that's what Java does.
  • 1
    @Lensflare interpolation (at least in java) is not a java'as feature - it's managed by templating frameworks. The framework takes a string literal, interpolates it and returns a complete message. So unless an IDE is aware of that framework you're using and has a plugin for it to validate interpolation keys inside the string literals, you're working with just plain strings :)
  • 1
    @Marethyun with THAT I do agree
Add Comment