directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1681265 - in /directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor: dialogs/TcpBufferDialog.java wrappers/TcpBufferWrapper.java
Date Sat, 23 May 2015 05:00:07 GMT
Author: elecharny
Date: Sat May 23 05:00:07 2015
New Revision: 1681265

URL: http://svn.apache.org/r1681265
Log:
Fixed the maximum buffer size, it's not 65535, but 2^32-1

Modified:
    directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/TcpBufferDialog.java
    directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/TcpBufferWrapper.java

Modified: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/TcpBufferDialog.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/TcpBufferDialog.java?rev=1681265&r1=1681264&r2=1681265&view=diff
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/TcpBufferDialog.java
(original)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/TcpBufferDialog.java
Sat May 23 05:00:07 2015
@@ -139,7 +139,7 @@ public class TcpBufferDialog extends Add
     /**
      * The listener for the size Text
      */
-    private ModifyListener idTextListener = new ModifyListener()
+    private ModifyListener sizeTextListener = new ModifyListener()
     {
         public void modifyText( ModifyEvent e )
         {
@@ -154,10 +154,10 @@ public class TcpBufferDialog extends Add
 
             try
             {
-                int sizeValue = Integer.parseInt( sizeText.getText() );
+                long sizeValue = Long.parseLong( sizeText.getText() );
 
-                // The size must be between 0 and 65535
-                if ( ( sizeValue < 0 ) || ( sizeValue > 65535 ) )
+                // The size must be between 0 and 2^32-1
+                if ( ( sizeValue < 0L ) || ( sizeValue > TcpBufferWrapper.MAX_TCP_BUFFER_SIZE
) )
                 {
                     sizeText.setForeground( display.getSystemColor( SWT.COLOR_RED ) );
                     tcpBufferText.setForeground( display.getSystemColor( SWT.COLOR_RED )
);
@@ -392,7 +392,7 @@ public class TcpBufferDialog extends Add
         // Size Text
         BaseWidgetUtils.createLabel( tcpBufferGroup, "Size :", 1 );
         sizeText = BaseWidgetUtils.createText( tcpBufferGroup, "", 1 );
-        sizeText.addModifyListener( idTextListener );
+        sizeText.addModifyListener( sizeTextListener );
 
         // Read checkbox Button
         readCheckbox = BaseWidgetUtils.createCheckbox( tcpBufferGroup, "read", 2 );
@@ -441,7 +441,7 @@ public class TcpBufferDialog extends Add
     {
         if ( getEditedElement() != null )
         {
-            sizeText.setText( Integer.toString( getEditedElement().getSize() ) );
+            sizeText.setText( Long.toString( getEditedElement().getSize() ) );
             
             URL listener =  getEditedElement().getListener();
             

Modified: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/TcpBufferWrapper.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/TcpBufferWrapper.java?rev=1681265&r1=1681264&r2=1681265&view=diff
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/TcpBufferWrapper.java
(original)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/TcpBufferWrapper.java
Sat May 23 05:00:07 2015
@@ -32,6 +32,9 @@ import java.net.URL;
  */
 public class TcpBufferWrapper
 {
+    /** The maximum buffer size (2^32-1) */
+    public static final long MAX_TCP_BUFFER_SIZE = 0xFFFFFFFFL;
+    
     /** The two kind of TCP buffer we can configure */
     public enum TcpType
     {
@@ -58,8 +61,8 @@ public class TcpBufferWrapper
     /** The type of TCP buffer (either read or write, or both ) (optional) */
     private TcpType tcpType;
     
-    /** The TCP Buffer size (between 0 and 65535) */
-    private int size; 
+    /** The TCP Buffer size (between 0 and 2^32-1) */
+    private long size; 
     
     
     /**
@@ -69,10 +72,11 @@ public class TcpBufferWrapper
      * @param tcpType read or write, but can be null for both
      * @param url The listener
      */
-    public TcpBufferWrapper( int size, TcpType tcpType, String url )
+    public TcpBufferWrapper( long size, TcpType tcpType, String url )
     {
         this.size = size;
         this.tcpType = tcpType;
+        
         try
         {
             listener = new URL( url );
@@ -148,15 +152,16 @@ public class TcpBufferWrapper
                 // get the integer
                 String sizeStr = lowerCaseTcpBuffer.substring( pos );
                 
-                size = Integer.valueOf( sizeStr );
+                size = Long.valueOf( sizeStr );
                 
-                if ( ( size < 0 ) ||( size > 65535 ) )
+                if ( ( size < 0L ) || ( size > MAX_TCP_BUFFER_SIZE ) )
                 {
                     // This is wrong
                 }
             }
         }
     }
+    
 
     /**
      * @return the listener
@@ -197,7 +202,7 @@ public class TcpBufferWrapper
     /**
      * @return the size
      */
-    public int getSize()
+    public long getSize()
     {
         return size;
     }
@@ -206,7 +211,7 @@ public class TcpBufferWrapper
     /**
      * @param size the size to set
      */
-    public void setSize( int size )
+    public void setSize( long size )
     {
         this.size = size;
     }
@@ -216,18 +221,18 @@ public class TcpBufferWrapper
      * Tells if the TcpBuffer element is valid or not
      * @param sizeStr the TCP buffer size
      * @param urlStr The listener as a String
-     * @return true if the value are correct, false otherwise
+     * @return true if the values are correct, false otherwise
      */
     public static boolean isValid( String sizeStr, String urlStr )
     {
         // the size must be positive and below 2^32-1
-        if ( ( sizeStr != null) && ( sizeStr.length() > 0 ) )
+        if ( ( sizeStr != null ) && ( sizeStr.length() > 0 ) )
         {
             try
             {
-                int size = Integer.valueOf( sizeStr );
+                long size = Long.valueOf( sizeStr );
             
-                if ( ( size < 0 ) || ( size > 65535 ) )
+                if ( ( size < 0L ) || ( size > MAX_TCP_BUFFER_SIZE ) )
                 {
                     return false;
                 }



Mime
View raw message