Issue1316

classification
Title: sockets with timeout and -Dpython.security.respectJavaAccessibility=false don't work
Type: Severity: normal
Components: Library Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: amak, kfitch42, markku_hanninen
Priority: Keywords:

Created on 2009-04-14.14:47:08 by markku_hanninen, last changed 2009-05-15.16:53:08 by amak.

Messages
msg4506 (view) Author: Markku Hänninen (markku_hanninen) Date: 2009-04-14.14:47:06
Can be reproduced like this:

[hmm@bombadil ~]$ /opt/jython2.5b3/bin/jython
-Dpython.security.respectJavaAccessibility=false
Jython 2.5b3 (Release_2_5beta3:6092, Mar 10 2009, 15:34:57) 
[Java HotSpot(TM) Server VM (Sun Microsystems Inc.)] on java1.6.0_04
Type "help", "copyright", "credits" or "license" for more information.
>>> import urllib, socket
>>> socket.setdefaulttimeout(120)
>>> fp = urllib.urlopen("http://www.jython.org")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/jython2.5b3/Lib/urllib.py", line 82, in urlopen
    return opener.open(url)
  File "/opt/jython2.5b3/Lib/urllib.py", line 190, in open
    return getattr(self, name)(url)
  File "/opt/jython2.5b3/Lib/urllib.py", line 190, in open
    return getattr(self, name)(url)
  File "/opt/jython2.5b3/Lib/urllib.py", line 325, in open_http
    h.endheaders()
  File "/opt/jython2.5b3/Lib/httplib.py", line 860, in endheaders
    self._send_output()
  File "/opt/jython2.5b3/Lib/httplib.py", line 732, in _send_output
    self.send(msg)
  File "/opt/jython2.5b3/Lib/httplib.py", line 711, in send
    self.sock.sendall(str)
  File "/opt/jython2.5b3/Lib/httplib.py", line 711, in send
    self.sock.sendall(str)
  File "<string>", line 1, in sendall
  File "/opt/jython2.5b3/Lib/socket.py", line 867, in send
    numwritten = self.sock_impl.write(s)
  File "/opt/jython2.5b3/Lib/socket.py", line 867, in send
    numwritten = self.sock_impl.write(s)
  File "/opt/jython2.5b3/Lib/socket.py", line 323, in write
    return self._do_write_net(buf)
  File "/opt/jython2.5b3/Lib/socket.py", line 307, in _do_write_net
    self.jsocket.getOutputStream().write(buf)
TypeError: write(): 1st arg can't be coerced to int
>>>
msg4509 (view) Author: Kevin Fitch (kfitch42) Date: 2009-04-15.02:58:45
Hmm, it looks like you have found a curious corner. It seems that when
respectJavaAccessibility=false the wrong overloaded function gets
picked. The Java docs for OutputStream list two functions named write
that take a single argument. One takes a byte array the other takes an
int. Clearly the one we want to be calling from that line is the byte
array version.

On a side note, the reason setting a timeout makes a difference here is
that the networking code has two modes of operation (1) When no socket
level timeouts are set it uses the java.nio classes, (2) when a timeout
is set it uses java.net classes, because nio doesn't support timeouts.
msg4513 (view) Author: Kevin Fitch (kfitch42) Date: 2009-04-15.04:03:10
Probably related to Issue1285
msg4576 (view) Author: Kevin Fitch (kfitch42) Date: 2009-04-23.03:41:21
Potential fix for this over in issue1285 (just posted a patch over 
there), at least it seems to make things work for me.
msg4601 (view) Author: Kevin Fitch (kfitch42) Date: 2009-04-27.15:55:54
works as of r6266, thanks to cgroves.
msg4687 (view) Author: Alan Kennedy (amak) Date: 2009-05-15.16:53:08
Closing, because fixed.
History
Date User Action Args
2009-05-15 16:53:08amaksetstatus: open -> closed
resolution: fixed
messages: + msg4687
2009-04-27 15:55:55kfitch42setmessages: + msg4601
2009-04-23 03:41:21kfitch42setmessages: + msg4576
2009-04-18 12:54:26amaksetnosy: + amak
2009-04-15 04:03:10kfitch42setmessages: + msg4513
2009-04-15 02:58:46kfitch42setnosy: + kfitch42
messages: + msg4509
2009-04-14 14:47:08markku_hanninencreate