java: ByteArrayConstructor should graciously handle existing byte arrays
See original GitHub issueThe method ByteArrayConstructor#construct(Object[])
fails with a ClassCastException
if the argument is already a byte array. This situation should be handled by introducing an instanceof
type check:
if(args.length == 1){
if(args[0] instanceof byte[]){
return args[0];
}
// Proceed as usual
}
I’ve come across pickled xgboost.sklearn.XGBRegressor
object instances (using Python 3.4) where the builtins.bytearray
is already a byte array. For example, the following commit contains such joblib dump file XGBAuto.pkl
: https://github.com/jpmml/jpmml-sklearn/commit/bc022a3c6353a4eec5f377e6937237c73334c445
Issue Analytics
- State:
- Created 7 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
String constructor to handle byte array producing weird result
The String() constructor you are using is interpreting the bytes in the array according to the default character set for your Java ......
Read more >String to byte array, byte array to String in Java
We can use String class getBytes() method to encode the string into a sequence of bytes using the platform's default charset. This method...
Read more >Convert String to Byte Array and Reverse in Java
We refer to the above process as encoding. In Java, we can encode a String into a byte array in multiple ways. Let's...
Read more >ArrayUtils (Apache Commons Lang 3.9 API)
This class tries to handle null input gracefully. An exception will not be thrown for a null array input. However, an Object array...
Read more >From Arrays to Streams and Back with Java 8 - Code Affine
And with it comes the extra effort of obtaining a stream from an array to be able to elegantly filter, map, reduce, etc....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
new versions have been relased to maven and nuget.
I can confirm that the current Pyrolite version
4.12-SNAPSHOT
works fine with my tests.