My code is broken

I’ve seen this posted in countless forms by countless people having countless issues. It’s sad: more often than not these are good people trying to learn, trying to fix their mistakes, or just trying to get their project working! But many forums and websites shut these people out because they “don’t know how to ask a question” or something along those lines.

Here are the unwritten rules of what you should try before you ask for help.

Continue reading “My code is broken”

ArrayIndexOutOfBoundsException in MiniDNS Version 0.3.3

I was working on a project that uses MiniDNS, a DNS services library for Java.  I noticed I was getting a strange error message when loading certain requests, with no noticeable correlation between them:

java.lang.ArrayIndexOutOfBoundsException: Index -1 out of bounds for length 32
	at minidns.core@0.3.3/org.minidns.record.NSEC.createTypeBitMap(NSEC.java:104)
	at minidns.core@0.3.3/org.minidns.record.NSEC3.<init>(NSEC3.java:132)
	at minidns.core@0.3.3/org.minidns.record.NSEC3.<init>(NSEC3.java:136)
	at minidns.core@0.3.3/org.minidns.record.NSEC3.parse(NSEC3.java:119)
	at minidns.core@0.3.3/org.minidns.record.Record.parse(Record.java:387)
	at minidns.core@0.3.3/org.minidns.dnsmessage.DnsMessage.<init>(DnsMessage.java:413)
	<snip>

This is an edge case where an unknown DNS response type being returned for an NSEC3 answer gets “un-resolved” down the road and crashes the parser.  It has been fixed in 0.4.0-alpha.

Fixing Java URL Authentication 401 Errors

I came across an issue the other day where my URL with inline authentication tokens was giving me a 401 Unauthorized error.  For the unfamiliar, URL authentication isn’t very heavily used, but it works like this:

https://username:password@protected.domain.example/resource

That username:password bit is known in Java as the User Info string, and Java handles it differently than web browsers do.

Continue reading “Fixing Java URL Authentication 401 Errors”