Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Tomas-Kraus opened this issue Apr 25, 2018 · 2 comments
Closed

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

Tomas-Kraus opened this issue Apr 25, 2018 · 2 comments

Comments

@Tomas-Kraus
Copy link
Contributor

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 ----------

@Tomas-Kraus
Copy link
Contributor Author

@amarinor
Copy link

amarinor commented May 20, 2021

How fix it?

@lukasj lukasj transferred this issue from eclipse-ee4j/jaxb-ri May 17, 2022
antoniosanct added a commit to antoniosanct/jaxb-api that referenced this issue Nov 13, 2023
Signed-off-by: Antonio Santos Izaguirre <antoniosanct@gmail.com>
@lukasj lukasj mentioned this issue Feb 15, 2024
@lukasj lukasj closed this as completed in 3eb7824 Feb 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants