question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

java: ByteArrayConstructor should graciously handle existing byte arrays

See original GitHub issue

The 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:closed
  • Created 7 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
irmencommented, May 25, 2016

new versions have been relased to maven and nuget.

1reaction
vruusmanncommented, May 25, 2016

I can confirm that the current Pyrolite version 4.12-SNAPSHOT works fine with my tests.

Read more comments on GitHub >

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

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found