Skip to content
This repository has been archived by the owner on Feb 5, 2019. It is now read-only.

Incorrect exception thrown by javax.xml.bind.DatatypeConverter #1188

Open
LanceAndersen opened this issue Apr 25, 2018 · 0 comments
Open

Incorrect exception thrown by javax.xml.bind.DatatypeConverter #1188

LanceAndersen opened this issue Apr 25, 2018 · 0 comments

Comments

@LanceAndersen
Copy link

Previously tracked: https://bugs.openjdk.java.net/browse/JDK-8168456

FULL PRODUCT VERSION :
java version "1.8.0_101"
Java(TM) SE Runtime Environment (build 1.8.0_101-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Darwin Andrews-MacBook-Pro.local 16.0.0 Darwin Kernel Version 16.0.0: Mon Aug 29 17:56:20 PDT 2016; root:xnu-3789.1.32~3/RELEASE_X86_64 x86_64

A DESCRIPTION OF THE PROBLEM :
When passing a string with invalid Base64, an IllegalArgumentException should be thrown, according to the docs:
https://docs.oracle.com/javase/7/docs/api/javax/xml/bind/DatatypeConverter.html#parseBase64Binary(java.lang.String)

Instead, for many strings e.g. "Qxx==", a java.lang.ArrayIndexOutOfBoundsException is thrown instead.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run this program:

import javax.xml.bind.DatatypeConverter;

public class Test {
public static void main(String[] args) {
System.out.print(DatatypeConverter.parseBase64Binary("Qxx=="));
//javax.xml.bind.DatatypeConverter.printDecimal(null);
}
}

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
IllegalArgumentException
ACTUAL -
ArrayIndexOutOfBoundsException

ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1
at javax.xml.bind.DatatypeConverterImpl._parseBase64Binary(DatatypeConverterImpl.java:715)
at javax.xml.bind.DatatypeConverterImpl.parseBase64Binary(DatatypeConverterImpl.java:434)
at javax.xml.bind.DatatypeConverter.parseBase64Binary(DatatypeConverter.java:342)
at Test.main(Test.java:5)

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import javax.xml.bind.DatatypeConverter;

public class Test {
public static void main(String[] args) {
System.out.print(DatatypeConverter.parseBase64Binary("Qxx=="));
//javax.xml.bind.DatatypeConverter.printDecimal(null);
}
}
---------- END SOURCE ----------

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant