You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by te...@apache.org on 2006/08/17 21:02:05 UTC
svn commit: r432340 - in
/incubator/harmony/enhanced/classlib/trunk/modules/luni/src:
main/java/java/net/Socket.java test/java/tests/api/java/net/SocketTest.java
Author: tellison
Date: Thu Aug 17 12:02:04 2006
New Revision: 432340
URL: http://svn.apache.org/viewvc?rev=432340&view=rev
Log:
Apply patch HARMONY-1136 ([classlib][net] unexpected NPE for Socket().setKeepAlive(true))
Modified:
incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/Socket.java
incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/SocketTest.java
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/Socket.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/Socket.java?rev=432340&r1=432339&r2=432340&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/Socket.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/Socket.java Thu Aug 17 12:02:04 2006
@@ -548,9 +548,11 @@
* if an error occurs setting the option
*/
public void setKeepAlive(boolean value) throws SocketException {
- checkClosedAndCreate(true);
- impl.setOption(SocketOptions.SO_KEEPALIVE, value ? Boolean.TRUE
- : Boolean.FALSE);
+ if (impl != null) {
+ checkClosedAndCreate(true);
+ impl.setOption(SocketOptions.SO_KEEPALIVE, value ? Boolean.TRUE
+ : Boolean.FALSE);
+ }
}
// static native int getSocketFlags();
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/SocketTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/SocketTest.java?rev=432340&r1=432339&r2=432340&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/SocketTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/net/SocketTest.java Thu Aug 17 12:02:04 2006
@@ -29,6 +29,7 @@
import java.net.Socket;
import java.net.SocketAddress;
import java.net.SocketException;
+import java.net.SocketImpl;
import java.net.SocketTimeoutException;
import java.net.UnknownHostException;
import java.security.Permission;
@@ -620,7 +621,7 @@
/**
* @tests java.net.Socket#setKeepAlive(boolean)
*/
- public void test_setKeepAliveZ() {
+ public void test_setKeepAliveZ() throws Exception {
// There is not really a good test for this as it is there to detect
// crashed machines. Just make sure we can set it
try {
@@ -634,7 +635,14 @@
} catch (Exception e) {
handleException(e, SO_KEEPALIVE);
}
+ // regression test for HARMONY-1136
+ new testSocket((SocketImpl) null).setKeepAlive(true);
}
+ class testSocket extends Socket {
+ public testSocket(SocketImpl impl) throws SocketException {
+ super(impl);
+ }
+ }
/**
* @tests java.net.Socket#setSocketImplFactory(java.net.SocketImplFactory)