[JAVA-2961] Get ObjectId from bytes not throwing exception if bytes.length > 12 Created: 05/Sep/18  Updated: 28/Oct/23  Resolved: 08/Jan/19

Status: Closed
Project: Java Driver
Component/s: BSON
Affects Version/s: None
Fix Version/s: 3.10.0

Type: Bug Priority: Major - P3
Reporter: Umang Jalan Assignee: Jeffrey Yemin
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible

 Comments   
Comment by Githook User [ 14/Jan/19 ]

Author:

{'username': 'jyemin', 'email': 'jeff.yemin@10gen.com', 'name': 'Jeff Yemin'}

Message: Conform to ObjectId(byte[] bytes) contract

The Javadoc states that it throws IllegalArgumentException if array is
null or not of length 12. The implementation now conforms to that
contract and throws the specified exception the byte array is not of
length 12.

JAVA-2961
Branch: 3.10.x
https://github.com/mongodb/mongo-java-driver/commit/468bcb95a3d1904c2033a52453476b56b94d9bff

Comment by Githook User [ 08/Jan/19 ]

Author:

{'username': 'jyemin', 'email': 'jeff.yemin@10gen.com', 'name': 'Jeff Yemin'}

Message: Conform to ObjectId(byte[] bytes) contract

The Javadoc states that it throws IllegalArgumentException if array is
null or not of length 12. The implementation now conforms to that
contract and throws the specified exception the byte array is not of
length 12.

JAVA-2961
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/911470a80c2e408db70b5db88bffc0393b937f29

Comment by Umang Jalan [ 05/Sep/18 ]

jeff.yemin I think its already broken and it needs to be fixed.

Everyone refers to java doc before integration to get the expected output. So I am assuming whoever is using it is actually is getting wrong output than expected as was in my case.

Whenever this change was made , it was not communicated in change log either about the new behaviour. So if someone is relying on current behavior , I believe thats the wrong expectation and its need to be notified.

Comment by Jeffrey Yemin [ 05/Sep/18 ]

I'm not convinced that this change should be made. Although it would make the implementation match the Javadoc description of the bytes parameter, it would break existing applications relying on the current behavior, which is consistent with the behavior and documentation of the constructor that takes a ByteBuffer.

umang can you present a counter-argument?

Comment by Umang Jalan [ 05/Sep/18 ]

https://github.com/mongodb/mongo-java-driver/pull/484

Generated at Thu Feb 08 08:58:28 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.