directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1771364 - in /directory/shared/branches/shared-value/ldap/client/api/src/main/java/org/apache/directory/ldap/client: api/ api/future/ template/exception/
Date Fri, 25 Nov 2016 17:53:54 GMT
Author: elecharny
Date: Fri Nov 25 17:53:54 2016
New Revision: 1771364

URL: http://svn.apache.org/viewvc?rev=1771364&view=rev
Log:
Fixed Sonarlint warnings

Modified:
    directory/shared/branches/shared-value/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapConnection.java
    directory/shared/branches/shared-value/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapConnectionWrapper.java
    directory/shared/branches/shared-value/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
    directory/shared/branches/shared-value/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdifAnonymizer.java
    directory/shared/branches/shared-value/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/MonitoringLdapConnection.java
    directory/shared/branches/shared-value/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/SearchCursorImpl.java
    directory/shared/branches/shared-value/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/future/ResponseFuture.java
    directory/shared/branches/shared-value/ldap/client/api/src/main/java/org/apache/directory/ldap/client/template/exception/LdapRequestUnsuccessfulException.java

Modified: directory/shared/branches/shared-value/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapConnection.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-value/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapConnection.java?rev=1771364&r1=1771363&r2=1771364&view=diff
==============================================================================
--- directory/shared/branches/shared-value/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapConnection.java
(original)
+++ directory/shared/branches/shared-value/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapConnection.java
Fri Nov 25 17:53:54 2016
@@ -840,6 +840,7 @@ public interface LdapConnection extends
      * @return true if there is a non-null future exists, false otherwise
      * @deprecated Use {@link #isRequestCompleted(int)}
      */
+    @Deprecated
     boolean doesFutureExistFor( int messageId );
 
 

Modified: directory/shared/branches/shared-value/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapConnectionWrapper.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-value/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapConnectionWrapper.java?rev=1771364&r1=1771363&r2=1771364&view=diff
==============================================================================
--- directory/shared/branches/shared-value/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapConnectionWrapper.java
(original)
+++ directory/shared/branches/shared-value/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapConnectionWrapper.java
Fri Nov 25 17:53:54 2016
@@ -551,7 +551,7 @@ public class LdapConnectionWrapper imple
     @Override
     public boolean doesFutureExistFor( int messageId )
     {
-        return connection.doesFutureExistFor( messageId );
+        return connection.isRequestCompleted( messageId );
     }
 
 

Modified: directory/shared/branches/shared-value/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-value/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java?rev=1771364&r1=1771363&r2=1771364&view=diff
==============================================================================
--- directory/shared/branches/shared-value/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
(original)
+++ directory/shared/branches/shared-value/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
Fri Nov 25 17:53:54 2016
@@ -39,9 +39,7 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.locks.ReentrantLock;
 
@@ -620,7 +618,6 @@ public class LdapNetworkConnection exten
                             LOG.debug( "------>> Connection error: {}", connectionFuture.getException().getMessage()
);
                             
                             // We can quit the loop
-                            break;
                         }
 
                         LOG.debug( "------>>   Cannot get the connection... Retrying"
);
@@ -639,11 +636,6 @@ public class LdapNetworkConnection exten
                             throw new LdapOtherException( e.getMessage(), e );
                         }
                     }
-                    else
-                    {
-                        // We can quit the loop
-                        break;
-                    }
                 }
             }
         }
@@ -745,7 +737,7 @@ public class LdapNetworkConnection exten
                             ( ( SearchFuture ) responseFuture ).set( SearchNoDResponse.PROTOCOLERROR
);
                         }
                     }
-                    catch ( ExecutionException | InterruptedException e )
+                    catch ( InterruptedException e )
                     {
                         LOG.error( "Error while processing the NoD for {}", responseFuture,
e );
                     }
@@ -804,7 +796,7 @@ public class LdapNetworkConnection exten
         // Close the session
         if ( ( ldapSession != null ) && connected.get() )
         {
-            ldapSession.close( true );
+            ldapSession.closeNow();
             connected.set( false );
         }
 
@@ -924,18 +916,6 @@ public class LdapNetworkConnection exten
 
             return addResponse;
         }
-        catch ( TimeoutException te )
-        {
-            // Send an abandon request
-            if ( !addFuture.isCancelled() )
-            {
-                abandon( addRequest.getMessageId() );
-            }
-
-            // We didn't received anything : this is an error
-            LOG.error( "Add failed : timeout occurred" );
-            throw new LdapException( TIME_OUT_ERROR, te );
-        }
         catch ( Exception ie )
         {
             // Catch all other exceptions
@@ -1254,12 +1234,6 @@ public class LdapNetworkConnection exten
 
             return bindResponse;
         }
-        catch ( TimeoutException te )
-        {
-            // We didn't received anything : this is an error
-            LOG.error( "Bind failed : timeout occurred" );
-            throw new LdapException( TIME_OUT_ERROR, te );
-        }
         catch ( Exception ie )
         {
             // Catch all other exceptions
@@ -1397,12 +1371,6 @@ public class LdapNetworkConnection exten
 
             return bindResponse;
         }
-        catch ( TimeoutException te )
-        {
-            // We didn't received anything : this is an error
-            LOG.error( "Bind failed : timeout occurred" );
-            throw new LdapException( TIME_OUT_ERROR, te );
-        }
         catch ( Exception ie )
         {
             // Catch all other exceptions
@@ -1460,12 +1428,6 @@ public class LdapNetworkConnection exten
 
             return bindResponse;
         }
-        catch ( TimeoutException te )
-        {
-            // We didn't received anything : this is an error
-            LOG.error( "Bind failed : timeout occurred" );
-            throw new LdapException( TIME_OUT_ERROR, te );
-        }
         catch ( Exception ie )
         {
             // Catch all other exceptions
@@ -1537,12 +1499,6 @@ public class LdapNetworkConnection exten
 
             return bindResponse;
         }
-        catch ( TimeoutException te )
-        {
-            // We didn't received anything : this is an error
-            LOG.error( "Bind failed : timeout occurred" );
-            throw new LdapException( TIME_OUT_ERROR, te );
-        }
         catch ( Exception ie )
         {
             // Catch all other exceptions
@@ -1600,12 +1556,6 @@ public class LdapNetworkConnection exten
 
             return bindResponse;
         }
-        catch ( TimeoutException te )
-        {
-            // We didn't received anything : this is an error
-            LOG.error( "Bind failed : timeout occurred" );
-            throw new LdapException( TIME_OUT_ERROR, te );
-        }
         catch ( Exception ie )
         {
             // Catch all other exceptions
@@ -1878,7 +1828,8 @@ public class LdapNetworkConnection exten
         }
         catch ( IOException e )
         {
-            e.printStackTrace();
+            LOG.error( e.getMessage() );
+            throw new LdapException( e.getMessage() );
         }
 
         connected.set( false );
@@ -1947,7 +1898,7 @@ public class LdapNetworkConnection exten
             }
         }
 
-        session.close( true );
+        session.closeNow();
     }
 
 
@@ -2001,7 +1952,7 @@ public class LdapNetworkConnection exten
         if ( isNoD )
         {
             // close the session
-            session.close( true );
+            session.closeNow();
 
             return;
         }
@@ -2424,18 +2375,6 @@ public class LdapNetworkConnection exten
 
             return modifyResponse;
         }
-        catch ( TimeoutException te )
-        {
-            // Send an abandon request
-            if ( !modifyFuture.isCancelled() )
-            {
-                abandon( modRequest.getMessageId() );
-            }
-
-            // We didn't received anything : this is an error
-            LOG.error( "Modify failed : timeout occurred" );
-            throw new LdapException( TIME_OUT_ERROR, te );
-        }
         catch ( Exception ie )
         {
             // Catch all other exceptions
@@ -2627,7 +2566,6 @@ public class LdapNetworkConnection exten
         modDnRequest.setName( entryDn );
         modDnRequest.setNewSuperior( newSuperiorDn );
 
-        //TODO not setting the below value is resulting in error
         modDnRequest.setNewRdn( entryDn.getRdn() );
 
         ModifyDnResponse modifyDnResponse = modifyDn( modDnRequest );
@@ -2759,18 +2697,6 @@ public class LdapNetworkConnection exten
 
             return modifyDnResponse;
         }
-        catch ( TimeoutException te )
-        {
-            // Send an abandon request
-            if ( !modifyDnFuture.isCancelled() )
-            {
-                abandon( modDnRequest.getMessageId() );
-            }
-
-            // We didn't received anything : this is an error
-            LOG.error( "Modify failed : timeout occurred" );
-            throw new LdapException( TIME_OUT_ERROR, te );
-        }
         catch ( Exception ie )
         {
             // Catch all other exceptions
@@ -2964,18 +2890,6 @@ public class LdapNetworkConnection exten
 
             return delResponse;
         }
-        catch ( TimeoutException te )
-        {
-            // Send an abandon request
-            if ( !deleteFuture.isCancelled() )
-            {
-                abandon( deleteRequest.getMessageId() );
-            }
-
-            // We didn't received anything : this is an error
-            LOG.error( "Del failed : timeout occurred" );
-            throw new LdapException( TIME_OUT_ERROR, te );
-        }
         catch ( Exception ie )
         {
             // Catch all other exceptions
@@ -3160,18 +3074,6 @@ public class LdapNetworkConnection exten
 
             return compareResponse;
         }
-        catch ( TimeoutException te )
-        {
-            // Send an abandon request
-            if ( !compareFuture.isCancelled() )
-            {
-                abandon( compareRequest.getMessageId() );
-            }
-
-            // We didn't received anything : this is an error
-            LOG.error( "Compare failed : timeout occurred" );
-            throw new LdapException( TIME_OUT_ERROR, te );
-        }
         catch ( Exception ie )
         {
             // Catch all other exceptions
@@ -3326,18 +3228,6 @@ public class LdapNetworkConnection exten
             // Decode the payload now
             return codec.decorate( response );
         }
-        catch ( TimeoutException te )
-        {
-            // Send an abandon request
-            if ( !extendedFuture.isCancelled() )
-            {
-                abandon( extendedRequest.getMessageId() );
-            }
-
-            // We didn't received anything : this is an error
-            LOG.error( "Extended failed : timeout occurred" );
-            throw new LdapException( TIME_OUT_ERROR, te );
-        }
         catch ( Exception ie )
         {
             // Catch all other exceptions
@@ -3671,6 +3561,11 @@ public class LdapNetworkConnection exten
             {
                 loadSchema();
             }
+            
+            if ( schemaManager == null )
+            {
+                throw new LdapException( "Cannot load the schema" );
+            }
 
             OpenLdapSchemaParser olsp = new OpenLdapSchemaParser();
             olsp.setQuirksMode( true );
@@ -3837,6 +3732,7 @@ public class LdapNetworkConnection exten
     /**
      * {@inheritDoc}
      */
+    @Override
     public boolean isRequestCompleted( int messageId )
     {
         ResponseFuture<?> responseFuture = futureMap.get( messageId );
@@ -3878,7 +3774,7 @@ public class LdapNetworkConnection exten
     @Override
     public void inputClosed( IoSession session ) throws Exception 
     {
-        session.close( true );
+        session.closeNow();
     }
 
 
@@ -3912,7 +3808,7 @@ public class LdapNetworkConnection exten
             return;
         }
 
-        ldapSession.close( true );
+        ldapSession.closeNow();
         connected.set( false );
         // Reset the messageId
         messageId.set( 0 );
@@ -4220,7 +4116,7 @@ public class LdapNetworkConnection exten
         }
         catch ( Exception e )
         {
-            e.printStackTrace();
+            LOG.error( e.getMessage() );
             throw new LdapException( e );
         }
     }

Modified: directory/shared/branches/shared-value/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdifAnonymizer.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-value/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdifAnonymizer.java?rev=1771364&r1=1771363&r2=1771364&view=diff
==============================================================================
--- directory/shared/branches/shared-value/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdifAnonymizer.java
(original)
+++ directory/shared/branches/shared-value/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdifAnonymizer.java
Fri Nov 25 17:53:54 2016
@@ -1056,9 +1056,9 @@ public class LdifAnonymizer
         LdifAnonymizer anonymizer = new LdifAnonymizer();
 
         String ldifString = null;
+        FileInputStream fis = new FileInputStream( args[0] );
 
-        try ( BufferedReader br = new BufferedReader( new InputStreamReader( new FileInputStream(
args[0] ),
-            Charset.defaultCharset() ) ) )
+        try ( BufferedReader br = new BufferedReader( new InputStreamReader( fis, Charset.defaultCharset()
) ) )
         {
             StringBuilder sb = new StringBuilder();
             String line = br.readLine();
@@ -1072,6 +1072,10 @@ public class LdifAnonymizer
 
             ldifString = sb.toString();
         }
+        finally
+        {
+            fis.close();
+        }
 
         String result = anonymizer.anonymize( ldifString );
 

Modified: directory/shared/branches/shared-value/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/MonitoringLdapConnection.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-value/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/MonitoringLdapConnection.java?rev=1771364&r1=1771363&r2=1771364&view=diff
==============================================================================
--- directory/shared/branches/shared-value/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/MonitoringLdapConnection.java
(original)
+++ directory/shared/branches/shared-value/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/MonitoringLdapConnection.java
Fri Nov 25 17:53:54 2016
@@ -32,8 +32,7 @@ import org.apache.directory.api.ldap.mod
 
 
 /**
- * 
- * TODO MonitoringLdapConnection.
+ * A class used to monitor the use of a LdapConnection
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */

Modified: directory/shared/branches/shared-value/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/SearchCursorImpl.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-value/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/SearchCursorImpl.java?rev=1771364&r1=1771363&r2=1771364&view=diff
==============================================================================
--- directory/shared/branches/shared-value/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/SearchCursorImpl.java
(original)
+++ directory/shared/branches/shared-value/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/SearchCursorImpl.java
Fri Nov 25 17:53:54 2016
@@ -156,10 +156,6 @@ public class SearchCursorImpl extends Ab
         if ( done )
         {
             searchDoneResp = ( SearchResultDone ) response;
-
-            // Process the response and throw an exception if needed
-            //ResultCodeEnum.processResponse( searchDoneResp );
-
             response = null;
         }
 

Modified: directory/shared/branches/shared-value/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/future/ResponseFuture.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-value/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/future/ResponseFuture.java?rev=1771364&r1=1771363&r2=1771364&view=diff
==============================================================================
--- directory/shared/branches/shared-value/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/future/ResponseFuture.java
(original)
+++ directory/shared/branches/shared-value/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/future/ResponseFuture.java
Fri Nov 25 17:53:54 2016
@@ -22,11 +22,9 @@ package org.apache.directory.ldap.client
 
 
 import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
 import java.util.concurrent.LinkedBlockingQueue;
 import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
 
 import org.apache.directory.api.ldap.model.message.Response;
 import org.apache.directory.ldap.client.api.LdapConnection;
@@ -103,7 +101,7 @@ public class ResponseFuture<R extends Re
      * @throws InterruptedException if the operation has been cancelled by client
      */
     @Override
-    public R get() throws InterruptedException, ExecutionException
+    public R get() throws InterruptedException
     {
         return queue.take();
     }
@@ -113,7 +111,7 @@ public class ResponseFuture<R extends Re
      * {@inheritDoc}
      * @throws InterruptedException if the operation has been cancelled by client
      */
-    public void set( R response ) throws InterruptedException, ExecutionException
+    public void set( R response ) throws InterruptedException
     {
         queue.add( response );
     }
@@ -124,7 +122,7 @@ public class ResponseFuture<R extends Re
      * @throws InterruptedException if the operation has been cancelled by client
      */
     @Override
-    public R get( long timeout, TimeUnit unit ) throws InterruptedException, ExecutionException,
TimeoutException
+    public R get( long timeout, TimeUnit unit ) throws InterruptedException
     {
         return queue.poll( timeout, unit );
     }

Modified: directory/shared/branches/shared-value/ldap/client/api/src/main/java/org/apache/directory/ldap/client/template/exception/LdapRequestUnsuccessfulException.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-value/ldap/client/api/src/main/java/org/apache/directory/ldap/client/template/exception/LdapRequestUnsuccessfulException.java?rev=1771364&r1=1771363&r2=1771364&view=diff
==============================================================================
--- directory/shared/branches/shared-value/ldap/client/api/src/main/java/org/apache/directory/ldap/client/template/exception/LdapRequestUnsuccessfulException.java
(original)
+++ directory/shared/branches/shared-value/ldap/client/api/src/main/java/org/apache/directory/ldap/client/template/exception/LdapRequestUnsuccessfulException.java
Fri Nov 25 17:53:54 2016
@@ -34,7 +34,7 @@ public class LdapRequestUnsuccessfulExce
 {
     private static final long serialVersionUID = 1982294624076306127L;
 
-    private ResultResponse response;
+    private final transient ResultResponse response;
 
 
     public LdapRequestUnsuccessfulException( ResultResponse response )



Mime
View raw message