[jcifs] DcerpcHandle thread safety

Michael B Allen ioplex at gmail.com
Sun Jan 11 20:25:01 MST 2015


On Fri, Jan 9, 2015 at 4:02 AM, Mateusz Kołodziej
<mateusz.kolodziej at outlook.com> wrote:
> Hi
>
> Is class DcerpcHandle thread safe?
>
> There is a field:
>
> private static int call_id = 1;
>
>
>
> and a method:
>
>
>
> public void sendrecv(DcerpcMessage msg){
>
>
>
> ...
>
> msg.call_id = call_id++;
>
> ...
>
> }
>
>
> I guess it is not thread safe. Is this a bug or it will work anyway?

Hi Mateusz,

Yeah, that code looks dubious. In practice there are locks (bind()
locks 'this') but other calls lock on different objects so it looks
like it is very possible for the same call_id to be used.

It might be sufficient to make call_id volatile but I think there
should probably be a synchronized(this) {} around at least that one
line.

I have added this to the TODO list for further investigation.

Thanks for reporting it.

Mike

-- 
Michael B Allen
Java Active Directory Integration
http://www.ioplex.com/


More information about the jCIFS mailing list