This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Patch: java.net


Hi list,


I write a patch fixing warnings/bugs found by FindBugs. 

Okay to commit to trunk ?


Michael


2004-02-10  Michael Koch  <konqueror@gmx.de>

	* java/net/DatagramSocket.java
	(setReuseAddress): Use Boolean.valueOf() instead of creating a new
	Boolean object.
	(setBroadcast): Likewise.
	* java/net/MulticastSocket.java
	(setLoopbackMode): Likewise.
	* java/net/ServerSocket.java
	(setReuseAddress): Likewise.
	* java/net/Socket.java
	(setTcpNoDelay): Likewise.
	(setSoLinger): Likewise.
	(setOOBInline): Likewise.
	(setKeepAlive): Likewise.
	(setReuseAddress): Likewise.
	* java/net/URLConnection.java
	(setContentHandler): Replace == with equals().
	* java/net/URLStreamHandler.java
	(hostSEquals): Fix checking host addresses.
	(toExternalForm): Dont check protocol for null. We know already its
	not null.
Index: java/net/DatagramSocket.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/net/DatagramSocket.java,v
retrieving revision 1.36
diff -u -b -B -r1.36 DatagramSocket.java
--- java/net/DatagramSocket.java	3 Feb 2004 16:07:24 -0000	1.36
+++ java/net/DatagramSocket.java	10 Feb 2004 18:18:49 -0000
@@ -798,7 +798,7 @@
     if (isClosed())
       throw new SocketException("socket is closed");
 
-    getImpl().setOption (SocketOptions.SO_REUSEADDR, new Boolean (on));
+    getImpl().setOption (SocketOptions.SO_REUSEADDR, Boolean.valueOf(on));
   }
 
   /**
@@ -837,7 +837,7 @@
     if (isClosed())
       throw new SocketException("socket is closed");
 
-    getImpl().setOption(SocketOptions.SO_BROADCAST, new Boolean(enable));
+    getImpl().setOption(SocketOptions.SO_BROADCAST, Boolean.valueOf(enable));
   }
 
   /**
Index: java/net/MulticastSocket.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/net/MulticastSocket.java,v
retrieving revision 1.26
diff -u -b -B -r1.26 MulticastSocket.java
--- java/net/MulticastSocket.java	26 Nov 2003 14:33:41 -0000	1.26
+++ java/net/MulticastSocket.java	10 Feb 2004 18:18:49 -0000
@@ -255,7 +255,7 @@
     if (isClosed())
       throw new SocketException("socket is closed");
 
-    getImpl().setOption (SocketOptions.IP_MULTICAST_LOOP, new Boolean (disable));
+    getImpl().setOption (SocketOptions.IP_MULTICAST_LOOP, Boolean.valueOf(disable));
   }
 
   /**
Index: java/net/ServerSocket.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/net/ServerSocket.java,v
retrieving revision 1.35
diff -u -b -B -r1.35 ServerSocket.java
--- java/net/ServerSocket.java	30 Jan 2004 13:43:19 -0000	1.35
+++ java/net/ServerSocket.java	10 Feb 2004 18:18:49 -0000
@@ -471,7 +471,7 @@
     if (isClosed())
       throw new SocketException("ServerSocket is closed");
     
-    impl.setOption (SocketOptions.SO_REUSEADDR, new Boolean (on));
+    impl.setOption (SocketOptions.SO_REUSEADDR, Boolean.valueOf(on));
   }
 
   /**
Index: java/net/Socket.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/net/Socket.java,v
retrieving revision 1.34
diff -u -b -B -r1.34 Socket.java
--- java/net/Socket.java	30 Jan 2004 13:43:20 -0000	1.34
+++ java/net/Socket.java	10 Feb 2004 18:18:49 -0000
@@ -657,7 +657,7 @@
     if (isClosed())
       throw new SocketException("socket is closed");
     
-    getImpl().setOption(SocketOptions.TCP_NODELAY, new Boolean(on));
+    getImpl().setOption(SocketOptions.TCP_NODELAY, Boolean.valueOf(on));
   }
 
   /**
@@ -719,7 +719,7 @@
       }
     else
       {
-        getImpl().setOption(SocketOptions.SO_LINGER, new Boolean(false));
+        getImpl().setOption(SocketOptions.SO_LINGER, Boolean.valueOf(false));
       }
   }
 
@@ -784,7 +784,7 @@
     if (isClosed())
       throw new SocketException("socket is closed");
     
-    getImpl().setOption(SocketOptions.SO_OOBINLINE, new Boolean(on));
+    getImpl().setOption(SocketOptions.SO_OOBINLINE, Boolean.valueOf(on));
   }
 
   /**
@@ -975,7 +975,7 @@
     if (isClosed())
       throw new SocketException("socket is closed");
     
-    getImpl().setOption(SocketOptions.SO_KEEPALIVE, new Boolean(on));
+    getImpl().setOption(SocketOptions.SO_KEEPALIVE, Boolean.valueOf(on));
   }
 
   /**
@@ -1150,7 +1150,7 @@
    */
   public void setReuseAddress (boolean on) throws SocketException
   {
-    getImpl().setOption (SocketOptions.SO_REUSEADDR, new Boolean (on));
+    getImpl().setOption (SocketOptions.SO_REUSEADDR, Boolean.valueOf(on));
   }
 
   /**
Index: java/net/URLConnection.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/net/URLConnection.java,v
retrieving revision 1.26
diff -u -b -B -r1.26 URLConnection.java
--- java/net/URLConnection.java	6 Jan 2004 08:54:20 -0000	1.26
+++ java/net/URLConnection.java	10 Feb 2004 18:18:50 -0000
@@ -956,7 +956,7 @@
     ContentHandler handler;
 
     // No content type so just handle it as the default.
-    if (contentType == null || contentType == "")
+    if (contentType == null || contentType.equals(""))
       return null;
 
     // See if a handler has been cached for this content type.
Index: java/net/URLStreamHandler.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/net/URLStreamHandler.java,v
retrieving revision 1.25
diff -u -b -B -r1.25 URLStreamHandler.java
--- java/net/URLStreamHandler.java	26 Nov 2003 21:25:41 -0000	1.25
+++ java/net/URLStreamHandler.java	10 Feb 2004 18:18:50 -0000
@@ -415,7 +415,7 @@
     InetAddress addr1 = getHostAddress (url1);
     InetAddress addr2 = getHostAddress (url2);
 
-    if (addr1 != null || addr2 != null)
+    if (addr1 != null && addr2 != null)
       return addr1.equals (addr2);
 
     String host1 = url1.getHost();
@@ -511,7 +511,7 @@
     int size = protocol.length() + host.length() + file.length() + 24;
     StringBuffer sb = new StringBuffer(size);
 
-    if (protocol != null && protocol.length() > 0)
+    if (protocol.length() != 0)
       {
 	sb.append(protocol);
 	sb.append(":");

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]