Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jgit-dev] ObjectInserter#idFor() question


I filed this bug report: https://bugs.eclipse.org/bugs/show_bug.cgi?id=448531


----- Original Message -----
> From: Robin Rosenberg <robin.rosenberg.lists@xxxxxxxxxx>
> To: Rüdiger Herrmann <ruediger.herrmann@xxxxxx>
> Cc: jgit-dev@xxxxxxxxxxx
> Sent: Thursday, October 23, 2014 2:50 PM
> Subject: Re: [jgit-dev] ObjectInserter#idFor() question
> 
> 
> 
> ----- Ursprungligt meddelande -----
>>  Från: "Rüdiger Herrmann" <ruediger.herrmann@xxxxxx>
>>  Till: jgit-dev@xxxxxxxxxxx, jgit-dev@xxxxxxxxxxx
>>  Skickat: torsdag, 23 okt 2014 10:24:45
>>  Ämne: [jgit-dev] ObjectInserter#idFor() question
>> 
>>  Hi JGit devs,
>>  I stumbled upon what I would call an inconsistency in how idFor() behaves,
>>  but maybe this by design. The idFor( objectType, lenth, inputStream ) 
> method
>>  checks if the given length and the actual length of the inputStream match
>>  and throws an IOException if not. But only if the given length is greater
>>  than the actual length. If the inputSteam has less bytes than specified by
>>  the length argument the method succeeds.
>>  Here is some code to illustrate:
>>    InputStream twoByteStream = new ByteArrayInputStream( new byte[] { 
> 1, 2 } )
>>    ;
>>    Formatter idCalculator = new Formatter();
>>    // Succeeds, i.e. silently ignores the difference between given and 
> actual
>>    length
>>    idCalculator.idFor( Constants.OBJ_BLOB, 1, twoByteStream );
>>    // Fails with an IOException
>>    idCalculator.idFor( Constants.OBJ_BLOB, 3, twoByteStream );
>>  IMO the method should behave consistently and either always or never throw 
> an
>>  exception if there is a mismatch between the specified and the actual
>>  length.
>>  Any thoughts?
>>  Rüdiger
> 
> That's a bug. I can think of no reason we would actually want this. 
> Hopefully
> we haven't broken too many repos this way.
> 
> -- robin
> 
> 
>>  _______________________________________________
>>  jgit-dev mailing list
>>  jgit-dev@xxxxxxxxxxx
>>  To change your delivery options, retrieve your password, or unsubscribe 
> from
>>  this list, visit
>>  https://dev.eclipse.org/mailman/listinfo/jgit-dev
>> 
>


Back to the top