Fixed many SonarLint issues (and some potential bugs)
diff --git a/core-annotations/src/test/java/org/apache/directory/server/core/factory/DirectoryServiceAnnotationTest.java b/core-annotations/src/test/java/org/apache/directory/server/core/factory/DirectoryServiceAnnotationTest.java
index 37bf687..d15f4b6 100644
--- a/core-annotations/src/test/java/org/apache/directory/server/core/factory/DirectoryServiceAnnotationTest.java
+++ b/core-annotations/src/test/java/org/apache/directory/server/core/factory/DirectoryServiceAnnotationTest.java
@@ -213,7 +213,7 @@
DummyAuthenticator.class,
authenticators.iterator().next().getClass() );
service.getSession( new Dn( "uid=non-existant-user,ou=system" ), "wrong-password".getBytes() );
- assertTrue( "Expedted dummy authenticator to have been invoked", dummyAuthenticatorCalled );
+ assertTrue( "Expected dummy authenticator to have been invoked", dummyAuthenticatorCalled );
service.shutdown();
FileUtils.deleteDirectory( service.getInstanceLayout().getInstanceDirectory() );
}
diff --git a/core-api/src/main/java/org/apache/directory/server/core/api/AbstractLayout.java b/core-api/src/main/java/org/apache/directory/server/core/api/AbstractLayout.java
index cc87562..b8541e8 100644
--- a/core-api/src/main/java/org/apache/directory/server/core/api/AbstractLayout.java
+++ b/core-api/src/main/java/org/apache/directory/server/core/api/AbstractLayout.java
@@ -113,12 +113,9 @@
{
for ( File requiredDirectory : requiredDirectories )
{
- if ( !requiredDirectory.exists() )
+ if ( !requiredDirectory.exists() && !requiredDirectory.mkdirs() )
{
- if ( !requiredDirectory.mkdirs() )
- {
- throw new IOException( I18n.err( I18n.ERR_112_COULD_NOT_CREATE_DIRECTORY, requiredDirectory ) );
- }
+ throw new IOException( I18n.err( I18n.ERR_112_COULD_NOT_CREATE_DIRECTORY, requiredDirectory ) );
}
}
}
diff --git a/core-api/src/main/java/org/apache/directory/server/core/api/LdapPrincipalSerializer.java b/core-api/src/main/java/org/apache/directory/server/core/api/LdapPrincipalSerializer.java
index 8e42dfe..53ffe0d 100644
--- a/core-api/src/main/java/org/apache/directory/server/core/api/LdapPrincipalSerializer.java
+++ b/core-api/src/main/java/org/apache/directory/server/core/api/LdapPrincipalSerializer.java
@@ -102,8 +102,6 @@
throw ioe;
}
- LdapPrincipal principal = new LdapPrincipal( schemaManager, dn, authenticationLevel );
-
- return principal;
+ return new LdapPrincipal( schemaManager, dn, authenticationLevel );
}
}
diff --git a/core-api/src/main/java/org/apache/directory/server/core/api/administrative/AbstractAdministrativePoint.java b/core-api/src/main/java/org/apache/directory/server/core/api/administrative/AbstractAdministrativePoint.java
index 8fda04e..4bd19f8 100644
--- a/core-api/src/main/java/org/apache/directory/server/core/api/administrative/AbstractAdministrativePoint.java
+++ b/core-api/src/main/java/org/apache/directory/server/core/api/administrative/AbstractAdministrativePoint.java
@@ -106,18 +106,6 @@
/**
* {@inheritDoc}
*/
- public abstract boolean isInner();
-
-
- /**
- * {@inheritDoc}
- */
- public abstract boolean isSpecific();
-
-
- /**
- * {@inheritDoc}
- */
public AdministrativePoint getParent()
{
return parent;
diff --git a/core-api/src/main/java/org/apache/directory/server/core/api/administrative/AccessControlAAP.java b/core-api/src/main/java/org/apache/directory/server/core/api/administrative/AccessControlAAP.java
index edaff44..b42fb6d 100644
--- a/core-api/src/main/java/org/apache/directory/server/core/api/administrative/AccessControlAAP.java
+++ b/core-api/src/main/java/org/apache/directory/server/core/api/administrative/AccessControlAAP.java
@@ -46,6 +46,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public AdministrativePoint getParent()
{
return parent;
@@ -75,6 +76,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isAutonomous()
{
return true;
@@ -84,6 +86,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String toString()
{
return "AccessControl AAP : " + super.toString();
diff --git a/core-api/src/main/java/org/apache/directory/server/core/api/administrative/AccessControlIAP.java b/core-api/src/main/java/org/apache/directory/server/core/api/administrative/AccessControlIAP.java
index 48050d2..699a338 100644
--- a/core-api/src/main/java/org/apache/directory/server/core/api/administrative/AccessControlIAP.java
+++ b/core-api/src/main/java/org/apache/directory/server/core/api/administrative/AccessControlIAP.java
@@ -66,6 +66,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String toString()
{
return "AccessControl IAP : " + super.toString();
diff --git a/core-api/src/main/java/org/apache/directory/server/core/api/administrative/AccessControlSAP.java b/core-api/src/main/java/org/apache/directory/server/core/api/administrative/AccessControlSAP.java
index bedce8d..46ad4f6 100644
--- a/core-api/src/main/java/org/apache/directory/server/core/api/administrative/AccessControlSAP.java
+++ b/core-api/src/main/java/org/apache/directory/server/core/api/administrative/AccessControlSAP.java
@@ -47,6 +47,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public AdministrativePoint getParent()
{
return parent;
@@ -76,6 +77,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String toString()
{
return "AccessControl SAP : " + super.toString();
diff --git a/core-api/src/main/java/org/apache/directory/server/core/api/administrative/AutonomousAdministrativePoint.java b/core-api/src/main/java/org/apache/directory/server/core/api/administrative/AutonomousAdministrativePoint.java
index 75cb3d0..25f5074 100644
--- a/core-api/src/main/java/org/apache/directory/server/core/api/administrative/AutonomousAdministrativePoint.java
+++ b/core-api/src/main/java/org/apache/directory/server/core/api/administrative/AutonomousAdministrativePoint.java
@@ -58,6 +58,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isAutonomous()
{
return true;
@@ -165,6 +166,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String toString()
{
return "AAP : " + super.toString();
diff --git a/core-api/src/main/java/org/apache/directory/server/core/api/administrative/CollectiveAttributeIAP.java b/core-api/src/main/java/org/apache/directory/server/core/api/administrative/CollectiveAttributeIAP.java
index df507f4..5e15e4c 100644
--- a/core-api/src/main/java/org/apache/directory/server/core/api/administrative/CollectiveAttributeIAP.java
+++ b/core-api/src/main/java/org/apache/directory/server/core/api/administrative/CollectiveAttributeIAP.java
@@ -66,6 +66,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String toString()
{
return "CollectiveAttribute IAP : " + super.toString();
diff --git a/core-api/src/main/java/org/apache/directory/server/core/api/administrative/CollectiveAttributeSAP.java b/core-api/src/main/java/org/apache/directory/server/core/api/administrative/CollectiveAttributeSAP.java
index b89f676..dbc06ef 100644
--- a/core-api/src/main/java/org/apache/directory/server/core/api/administrative/CollectiveAttributeSAP.java
+++ b/core-api/src/main/java/org/apache/directory/server/core/api/administrative/CollectiveAttributeSAP.java
@@ -66,6 +66,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String toString()
{
return "CollectiveAttribute SAP : " + super.toString();
diff --git a/core-api/src/main/java/org/apache/directory/server/core/api/administrative/SubschemaAAP.java b/core-api/src/main/java/org/apache/directory/server/core/api/administrative/SubschemaAAP.java
index 7b65781..c7d0894 100644
--- a/core-api/src/main/java/org/apache/directory/server/core/api/administrative/SubschemaAAP.java
+++ b/core-api/src/main/java/org/apache/directory/server/core/api/administrative/SubschemaAAP.java
@@ -66,6 +66,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isAutonomous()
{
return true;
@@ -75,6 +76,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String toString()
{
return "Subschema AAP : " + super.toString();
diff --git a/core-api/src/main/java/org/apache/directory/server/core/api/administrative/SubschemaSAP.java b/core-api/src/main/java/org/apache/directory/server/core/api/administrative/SubschemaSAP.java
index fe50e0a..8d5f0fe 100644
--- a/core-api/src/main/java/org/apache/directory/server/core/api/administrative/SubschemaSAP.java
+++ b/core-api/src/main/java/org/apache/directory/server/core/api/administrative/SubschemaSAP.java
@@ -66,6 +66,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String toString()
{
return "Subschema SAP : " + super.toString();
diff --git a/core-api/src/main/java/org/apache/directory/server/core/api/administrative/TriggerExecutionAAP.java b/core-api/src/main/java/org/apache/directory/server/core/api/administrative/TriggerExecutionAAP.java
index 19171aa..02af492 100644
--- a/core-api/src/main/java/org/apache/directory/server/core/api/administrative/TriggerExecutionAAP.java
+++ b/core-api/src/main/java/org/apache/directory/server/core/api/administrative/TriggerExecutionAAP.java
@@ -66,6 +66,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isAutonomous()
{
return true;
@@ -75,6 +76,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String toString()
{
return "TriggerExecution AAP : " + super.toString();
diff --git a/core-api/src/main/java/org/apache/directory/server/core/api/administrative/TriggerExecutionIAP.java b/core-api/src/main/java/org/apache/directory/server/core/api/administrative/TriggerExecutionIAP.java
index 7302e3f..7c3fc68 100644
--- a/core-api/src/main/java/org/apache/directory/server/core/api/administrative/TriggerExecutionIAP.java
+++ b/core-api/src/main/java/org/apache/directory/server/core/api/administrative/TriggerExecutionIAP.java
@@ -66,6 +66,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String toString()
{
return "TriggerExecution IAP : " + super.toString();
diff --git a/core-api/src/main/java/org/apache/directory/server/core/api/administrative/TriggerExecutionSAP.java b/core-api/src/main/java/org/apache/directory/server/core/api/administrative/TriggerExecutionSAP.java
index 9ab8176..b418e9f 100644
--- a/core-api/src/main/java/org/apache/directory/server/core/api/administrative/TriggerExecutionSAP.java
+++ b/core-api/src/main/java/org/apache/directory/server/core/api/administrative/TriggerExecutionSAP.java
@@ -66,6 +66,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public String toString()
{
return "TriggerExecution SAP : " + super.toString();
diff --git a/core-api/src/main/java/org/apache/directory/server/core/api/changelog/ChangeLogEvent.java b/core-api/src/main/java/org/apache/directory/server/core/api/changelog/ChangeLogEvent.java
index 9a64092..d06ccdb 100644
--- a/core-api/src/main/java/org/apache/directory/server/core/api/changelog/ChangeLogEvent.java
+++ b/core-api/src/main/java/org/apache/directory/server/core/api/changelog/ChangeLogEvent.java
@@ -66,7 +66,7 @@
this.zuluTime = zuluTime;
this.revision = revision;
this.forwardLdif = forwardLdif;
- this.reverseLdifs = new ArrayList<LdifEntry>( 1 );
+ this.reverseLdifs = new ArrayList<>( 1 );
reverseLdifs.add( reverseLdif );
this.committer = committer;
}
diff --git a/core-api/src/main/java/org/apache/directory/server/core/api/changelog/ChangeLogEventSerializer.java b/core-api/src/main/java/org/apache/directory/server/core/api/changelog/ChangeLogEventSerializer.java
index a7b3836..0adb6f6 100644
--- a/core-api/src/main/java/org/apache/directory/server/core/api/changelog/ChangeLogEventSerializer.java
+++ b/core-api/src/main/java/org/apache/directory/server/core/api/changelog/ChangeLogEventSerializer.java
@@ -98,7 +98,7 @@
* @throws LdapInvalidDnException If the deserialization failed
*/
public static ChangeLogEvent deserialize( SchemaManager schemaManager, ObjectInput in )
- throws IOException, LdapInvalidDnException
+ throws IOException
{
// The date the change has been created, "yyyyMMddHHmmss'Z'"
String zuluTime = in.readUTF();
@@ -126,7 +126,7 @@
// The reverse LDIFs number
int nbReverses = in.readInt();
- List<LdifEntry> reverses = new ArrayList<LdifEntry>( nbReverses );
+ List<LdifEntry> reverses = new ArrayList<>( nbReverses );
for ( int i = 0; i < nbReverses; i++ )
{
@@ -146,9 +146,6 @@
reverses.add( reverseEntry );
}
- ChangeLogEvent changeLogEvent = new ChangeLogEvent( revision, zuluTime, committerPrincipal, forwardEntry,
- reverses );
-
- return changeLogEvent;
+ return new ChangeLogEvent( revision, zuluTime, committerPrincipal, forwardEntry, reverses );
}
}
diff --git a/core-api/src/main/java/org/apache/directory/server/core/api/entry/ServerEntryUtils.java b/core-api/src/main/java/org/apache/directory/server/core/api/entry/ServerEntryUtils.java
index f5232ec..9ef03bb 100644
--- a/core-api/src/main/java/org/apache/directory/server/core/api/entry/ServerEntryUtils.java
+++ b/core-api/src/main/java/org/apache/directory/server/core/api/entry/ServerEntryUtils.java
@@ -408,12 +408,8 @@
}
- Modification modification = new DefaultModification(
- operation,
+ return new DefaultModification( operation,
ServerEntryUtils.toServerAttribute( modificationImpl.getAttribute(), attributeType ) );
-
- return modification;
-
}
@@ -459,12 +455,9 @@
private static Modification toServerModification( Modification modification, AttributeType attributeType )
throws LdapException
{
- Modification serverModification = new DefaultModification(
+ return new DefaultModification(
modification.getOperation(),
new DefaultAttribute( attributeType, modification.getAttribute() ) );
-
- return serverModification;
-
}
@@ -481,7 +474,7 @@
{
if ( modifications != null )
{
- List<Modification> modificationsList = new ArrayList<Modification>();
+ List<Modification> modificationsList = new ArrayList<>();
for ( Modification modification : modifications )
{
@@ -533,7 +526,7 @@
{
if ( modifications != null )
{
- List<Modification> modificationsList = new ArrayList<Modification>();
+ List<Modification> modificationsList = new ArrayList<>();
for ( ModificationItem modification : modifications )
{
@@ -626,7 +619,7 @@
{
if ( result instanceof EmptyEnumeration<?> )
{
- return new EmptyEnumeration<SearchResult>();
+ return new EmptyEnumeration<>();
}
return new NamingEnumeration<SearchResult>()
@@ -653,13 +646,11 @@
{
ServerSearchResult rec = result.next();
- SearchResult searchResult = new SearchResult(
+ return new SearchResult(
rec.getDn().getName(),
rec.getObject(),
toBasicAttributes( rec.getServerEntry() ),
rec.isRelative() );
-
- return searchResult;
}
@@ -681,13 +672,11 @@
{
ServerSearchResult rec = result.next();
- SearchResult searchResult = new SearchResult(
+ return new SearchResult(
rec.getDn().getName(),
rec.getObject(),
toBasicAttributes( rec.getServerEntry() ),
rec.isRelative() );
-
- return searchResult;
}
catch ( NamingException ne )
{
@@ -739,7 +728,7 @@
if ( optionsPos != -1 )
{
- Set<String> options = new HashSet<String>();
+ Set<String> options = new HashSet<>();
String[] res = attributeId.substring( optionsPos + 1 ).split( ";" );
diff --git a/core-api/src/main/java/org/apache/directory/server/core/api/event/EventType.java b/core-api/src/main/java/org/apache/directory/server/core/api/event/EventType.java
index 0fcb3ca..bee5f7f 100644
--- a/core-api/src/main/java/org/apache/directory/server/core/api/event/EventType.java
+++ b/core-api/src/main/java/org/apache/directory/server/core/api/event/EventType.java
@@ -79,7 +79,7 @@
*/
public static EventType[] getEventTypes( int psearchChangeTypes )
{
- ArrayList<EventType> types = new ArrayList<EventType>();
+ ArrayList<EventType> types = new ArrayList<>();
if ( isAdd( psearchChangeTypes ) )
{
diff --git a/core-api/src/main/java/org/apache/directory/server/core/api/event/ExpressionEvaluator.java b/core-api/src/main/java/org/apache/directory/server/core/api/event/ExpressionEvaluator.java
index 865908e..9a360a4 100644
--- a/core-api/src/main/java/org/apache/directory/server/core/api/event/ExpressionEvaluator.java
+++ b/core-api/src/main/java/org/apache/directory/server/core/api/event/ExpressionEvaluator.java
@@ -69,7 +69,6 @@
{
SubstringEvaluator substringEvaluator = null;
substringEvaluator = new SubstringEvaluator();
- // leafEvaluator = new LeafEvaluator( schemaManager, substringEvaluator );
leafEvaluator = new LeafEvaluator( substringEvaluator );
}
diff --git a/core-api/src/main/java/org/apache/directory/server/core/api/event/LeafEvaluator.java b/core-api/src/main/java/org/apache/directory/server/core/api/event/LeafEvaluator.java
index 0100200..6173f05 100644
--- a/core-api/src/main/java/org/apache/directory/server/core/api/event/LeafEvaluator.java
+++ b/core-api/src/main/java/org/apache/directory/server/core/api/event/LeafEvaluator.java
@@ -27,6 +27,7 @@
import org.apache.directory.api.ldap.model.entry.Value;
import org.apache.directory.api.ldap.model.exception.LdapException;
import org.apache.directory.api.ldap.model.exception.LdapInvalidSearchFilterException;
+import org.apache.directory.api.ldap.model.exception.LdapUnwillingToPerformException;
import org.apache.directory.api.ldap.model.filter.ApproximateNode;
import org.apache.directory.api.ldap.model.filter.EqualityNode;
import org.apache.directory.api.ldap.model.filter.ExprNode;
@@ -62,9 +63,6 @@
/** substring matching type constant */
private static final int SUBSTRING_MATCH = 3;
- // /** SchemaManager needed for normalizing and comparing values */
- // private SchemaManager schemaManager;
-
/** Substring node evaluator we depend on */
private SubstringEvaluator substringEvaluator;
@@ -88,19 +86,6 @@
}
- // /**
- // * Creates a leaf expression node evaluator.
- // *
- // * @param schemaManager The server schemaManager
- // */
- // public LeafEvaluator( SchemaManager schemaManager,
- // SubstringEvaluator substringEvaluator )
- // {
- // this.schemaManager = schemaManager;
- // this.scopeEvaluator = new ScopeEvaluator();
- // this.substringEvaluator = substringEvaluator;
- // }
-
public ScopeEvaluator getScopeEvaluator()
{
return scopeEvaluator;
@@ -165,7 +150,6 @@
* @return the ava evaluation on the perspective candidate
* @throws LdapException if there is a database access failure
*/
- @SuppressWarnings("unchecked")
private boolean evalGreaterOrLesser( SimpleNode<?> node, Entry entry, boolean isGreaterOrLesser )
throws LdapException
{
@@ -227,7 +211,7 @@
* @param entry the perspective candidate
* @return the ava evaluation on the perspective candidate
*/
- private boolean evalPresence( AttributeType attributeType, Entry entry ) throws LdapException
+ private boolean evalPresence( AttributeType attributeType, Entry entry )
{
if ( entry == null )
{
@@ -247,7 +231,6 @@
* @return the ava evaluation on the perspective candidate
* @throws org.apache.directory.api.ldap.model.exception.LdapException if there is a database access failure
*/
- @SuppressWarnings("unchecked")
private boolean evalEquality( EqualityNode<?> node, Entry entry ) throws LdapException
{
Normalizer normalizer = getNormalizer( node.getAttributeType() );
@@ -322,6 +305,11 @@
{
MatchingRule mrule = getMatchingRule( attributeType, EQUALITY_MATCH );
+ if ( mrule == null )
+ {
+ throw new LdapUnwillingToPerformException( "No EQUALITY MatchingRule for the '" + attributeType + "' attributeType" );
+ }
+
return mrule.getLdapComparator();
}
@@ -337,6 +325,11 @@
{
MatchingRule mrule = getMatchingRule( attributeType, EQUALITY_MATCH );
+ if ( mrule == null )
+ {
+ throw new LdapUnwillingToPerformException( "No EQUALITY MatchingRule for the '" + attributeType + "' attributeType" );
+ }
+
return mrule.getNormalizer();
}
diff --git a/core-api/src/main/java/org/apache/directory/server/core/api/filtering/EntryFilteringCursorImpl.java b/core-api/src/main/java/org/apache/directory/server/core/api/filtering/EntryFilteringCursorImpl.java
index 7a0c775..ec4970c 100644
--- a/core-api/src/main/java/org/apache/directory/server/core/api/filtering/EntryFilteringCursorImpl.java
+++ b/core-api/src/main/java/org/apache/directory/server/core/api/filtering/EntryFilteringCursorImpl.java
@@ -141,7 +141,7 @@
this.wrapped = wrapped;
this.operationContext = operationContext;
- this.filters = new ArrayList<EntryFilter>();
+ this.filters = new ArrayList<>();
this.filters.addAll( filters );
this.schemaManager = schemaManager;
}
@@ -577,7 +577,7 @@
sb.append( tabs ).append( "BaseEntryFilteringCursor, no wrapped\n" );
}
- if ( ( filters != null ) && ( filters.size() > 0 ) )
+ if ( ( filters != null ) && !filters.isEmpty() )
{
sb.append( tabs ).append( "Filters : \n" );
diff --git a/core-api/src/main/java/org/apache/directory/server/core/api/interceptor/BaseInterceptor.java b/core-api/src/main/java/org/apache/directory/server/core/api/interceptor/BaseInterceptor.java
index 269d460..2806786 100644
--- a/core-api/src/main/java/org/apache/directory/server/core/api/interceptor/BaseInterceptor.java
+++ b/core-api/src/main/java/org/apache/directory/server/core/api/interceptor/BaseInterceptor.java
@@ -71,7 +71,7 @@
protected DnFactory dnFactory;
/** set of operational attribute types used for representing the password policy state of a user entry */
- protected static final Set<AttributeType> PWD_POLICY_STATE_ATTRIBUTE_TYPES = new HashSet<AttributeType>();
+ protected static final Set<AttributeType> PWD_POLICY_STATE_ATTRIBUTE_TYPES = new HashSet<>();
/**
* The final interceptor which acts as a proxy in charge to dialog with the nexus partition.
@@ -312,9 +312,7 @@
return finalInterceptor;
}
- Interceptor interceptor = directoryService.getInterceptor( currentInterceptor );
-
- return interceptor;
+ return directoryService.getInterceptor( currentInterceptor );
}
diff --git a/core-api/src/main/java/org/apache/directory/server/core/api/interceptor/context/AbstractOperationContext.java b/core-api/src/main/java/org/apache/directory/server/core/api/interceptor/context/AbstractOperationContext.java
index 33ac3a5..10b509e 100644
--- a/core-api/src/main/java/org/apache/directory/server/core/api/interceptor/context/AbstractOperationContext.java
+++ b/core-api/src/main/java/org/apache/directory/server/core/api/interceptor/context/AbstractOperationContext.java
@@ -291,13 +291,6 @@
/**
- * @return the operation name
- */
- @Override
- public abstract String getName();
-
-
- /**
* @return the originalEntry
*/
public Entry getOriginalEntry()
diff --git a/core-api/src/main/java/org/apache/directory/server/core/api/interceptor/context/BindOperationContext.java b/core-api/src/main/java/org/apache/directory/server/core/api/interceptor/context/BindOperationContext.java
index 66df302..8849711 100644
--- a/core-api/src/main/java/org/apache/directory/server/core/api/interceptor/context/BindOperationContext.java
+++ b/core-api/src/main/java/org/apache/directory/server/core/api/interceptor/context/BindOperationContext.java
@@ -233,6 +233,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void throwReferral()
{
throw new NotImplementedException( I18n.err( I18n.ERR_320 ) );
@@ -242,6 +243,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isReferralThrown()
{
throw new NotImplementedException( I18n.err( I18n.ERR_321 ) );
@@ -251,6 +253,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void ignoreReferral()
{
throw new NotImplementedException( I18n.err( I18n.ERR_322 ) );
@@ -260,6 +263,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public boolean isReferralIgnored()
{
throw new NotImplementedException( I18n.err( I18n.ERR_323 ) );
diff --git a/core-api/src/main/java/org/apache/directory/server/core/api/interceptor/context/EmptyOperationContext.java b/core-api/src/main/java/org/apache/directory/server/core/api/interceptor/context/EmptyOperationContext.java
index b575614..c2d423f 100644
--- a/core-api/src/main/java/org/apache/directory/server/core/api/interceptor/context/EmptyOperationContext.java
+++ b/core-api/src/main/java/org/apache/directory/server/core/api/interceptor/context/EmptyOperationContext.java
@@ -49,6 +49,7 @@
*
* @param dn The Dn to set
*/
+ @Override
public void setDn( Dn dn )
{
if ( dn.equals( Dn.EMPTY_DN ) )
diff --git a/core-api/src/main/java/org/apache/directory/server/core/api/interceptor/context/FilteringOperationContext.java b/core-api/src/main/java/org/apache/directory/server/core/api/interceptor/context/FilteringOperationContext.java
index a89019e..e3694de 100644
--- a/core-api/src/main/java/org/apache/directory/server/core/api/interceptor/context/FilteringOperationContext.java
+++ b/core-api/src/main/java/org/apache/directory/server/core/api/interceptor/context/FilteringOperationContext.java
@@ -26,7 +26,6 @@
import org.apache.commons.lang.ArrayUtils;
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
import org.apache.directory.api.ldap.model.exception.LdapException;
-import org.apache.directory.api.ldap.model.exception.LdapNoSuchAttributeException;
import org.apache.directory.api.ldap.model.name.Dn;
import org.apache.directory.api.ldap.model.schema.AttributeType;
import org.apache.directory.api.ldap.model.schema.AttributeTypeOptions;
@@ -224,13 +223,13 @@
// We have something in the list
// first, ignore all the unkown AT and convert the strings to
// AttributeTypeOptions
- returningAttributes = new HashSet<AttributeTypeOptions>();
- Set<String> attributesString = new HashSet<String>();
+ returningAttributes = new HashSet<>();
+ Set<String> attributesString = new HashSet<>();
Set<AttributeTypeOptions> collectedAttributes = collectAttributeTypes( attributeIds );
// If we have valid, '*' or '+' attributes, we can get rid of the NoAttributes flag
- if ( ( collectedAttributes.size() > 0 ) || allUserAttributes || allOperationalAttributes )
+ if ( !collectedAttributes.isEmpty() || allUserAttributes || allOperationalAttributes )
{
noAttributes = false;
}
@@ -238,7 +237,7 @@
// Now, loop on the list of attributes, and remove all the USER attributes if
// we have the '*' attribute, and remove all the OPERATIONAL attributes if we
// have the '+' attribute
- if ( collectedAttributes.size() > 0 )
+ if ( !collectedAttributes.isEmpty() )
{
for ( AttributeTypeOptions attributeTypeOption : collectedAttributes )
{
@@ -258,7 +257,7 @@
}
}
- if ( attributesString.size() > 0 )
+ if ( !attributesString.isEmpty() )
{
// We have some valid attributes, lt's convert it to String
returningAttributesString = attributesString.toArray( ArrayUtils.EMPTY_STRING_ARRAY );
@@ -280,7 +279,7 @@
private Set<AttributeTypeOptions> collectAttributeTypes( String... attributesIds )
{
- Set<AttributeTypeOptions> collectedAttributes = new HashSet<AttributeTypeOptions>();
+ Set<AttributeTypeOptions> collectedAttributes = new HashSet<>();
if ( ( attributesIds != null ) && ( attributesIds.length != 0 ) )
{
@@ -320,12 +319,6 @@
collectedAttributes.add( attrOptions );
}
- catch ( LdapNoSuchAttributeException nsae )
- {
- LOG.warn( "Requested attribute {} does not exist in the schema, it will be ignored",
- returnAttribute );
- // Unknown attributes should be silently ignored, as RFC 2251 states
- }
catch ( LdapException le )
{
LOG.warn( "Requested attribute {} does not exist in the schema, it will be ignored",
diff --git a/core-api/src/main/java/org/apache/directory/server/core/api/interceptor/context/ModifyOperationContext.java b/core-api/src/main/java/org/apache/directory/server/core/api/interceptor/context/ModifyOperationContext.java
index 9b01801..7b83a93 100644
--- a/core-api/src/main/java/org/apache/directory/server/core/api/interceptor/context/ModifyOperationContext.java
+++ b/core-api/src/main/java/org/apache/directory/server/core/api/interceptor/context/ModifyOperationContext.java
@@ -148,9 +148,8 @@
public static List<Modification> createModItems( Entry serverEntry, ModificationOperation modOp )
- throws LdapException
{
- List<Modification> items = new ArrayList<Modification>( serverEntry.size() );
+ List<Modification> items = new ArrayList<>( serverEntry.size() );
for ( Attribute attribute : serverEntry )
{
diff --git a/core-api/src/main/java/org/apache/directory/server/core/api/interceptor/context/SearchOperationContext.java b/core-api/src/main/java/org/apache/directory/server/core/api/interceptor/context/SearchOperationContext.java
index e41c090..5ca1c8d 100644
--- a/core-api/src/main/java/org/apache/directory/server/core/api/interceptor/context/SearchOperationContext.java
+++ b/core-api/src/main/java/org/apache/directory/server/core/api/interceptor/context/SearchOperationContext.java
@@ -315,6 +315,7 @@
/**
* @see Object#toString()
*/
+ @Override
public String toString()
{
return "SearchContext for Dn '" + getDn().getName() + "', filter :'"
diff --git a/core-api/src/main/java/org/apache/directory/server/core/api/schema/DescriptionParsers.java b/core-api/src/main/java/org/apache/directory/server/core/api/schema/DescriptionParsers.java
index b7cd60c..6ba4ee4 100644
--- a/core-api/src/main/java/org/apache/directory/server/core/api/schema/DescriptionParsers.java
+++ b/core-api/src/main/java/org/apache/directory/server/core/api/schema/DescriptionParsers.java
@@ -328,7 +328,7 @@
}
// if the super objectClasses are provided make sure it exists in some schema
- if ( objectClass.getSuperiorOids() != null && objectClass.getSuperiorOids().size() > 0 )
+ if ( objectClass.getSuperiorOids() != null && !objectClass.getSuperiorOids().isEmpty() )
{
for ( String superiorOid : objectClass.getSuperiorOids() )
{
@@ -347,7 +347,7 @@
}
// if the may list is provided make sure attributes exists in some schema
- if ( objectClass.getMayAttributeTypeOids() != null && objectClass.getMayAttributeTypeOids().size() > 0 )
+ if ( objectClass.getMayAttributeTypeOids() != null && !objectClass.getMayAttributeTypeOids().isEmpty() )
{
for ( String mayAttrOid : objectClass.getMayAttributeTypeOids() )
{
@@ -360,7 +360,7 @@
}
// if the must list is provided make sure attributes exists in some schema
- if ( objectClass.getMustAttributeTypeOids() != null && objectClass.getMustAttributeTypeOids().size() > 0 )
+ if ( objectClass.getMustAttributeTypeOids() != null && !objectClass.getMustAttributeTypeOids().isEmpty() )
{
for ( String mustAttrOid : objectClass.getMustAttributeTypeOids() )
{
diff --git a/core-api/src/main/java/org/apache/directory/server/core/api/schema/SchemaPartition.java b/core-api/src/main/java/org/apache/directory/server/core/api/schema/SchemaPartition.java
index 1c80688..a0cf514 100644
--- a/core-api/src/main/java/org/apache/directory/server/core/api/schema/SchemaPartition.java
+++ b/core-api/src/main/java/org/apache/directory/server/core/api/schema/SchemaPartition.java
@@ -184,6 +184,7 @@
* Has no affect: the id is fixed at {@link SchemaPartition#SCHEMA_ID}: 'schema'.
* A warning is logged.
*/
+ @Override
public void setId( String id )
{
LOG.warn( "This partition's ID is fixed: {}", SCHEMA_ID );
@@ -197,6 +198,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void sync() throws LdapException
{
wrapped.sync();
@@ -518,7 +520,7 @@
String modifiersName = opContext.getSession().getEffectivePrincipal().getName();
String modifyTimestamp = DateUtils.getGeneralizedTime();
- List<Modification> mods = new ArrayList<Modification>( 2 );
+ List<Modification> mods = new ArrayList<>( 2 );
mods.add( new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, new DefaultAttribute(
ApacheSchemaConstants.SCHEMA_MODIFY_TIMESTAMP_AT, schemaManager
@@ -581,9 +583,7 @@
*/
public Subordinates getSubordinates( PartitionTxn partitionTxn, Entry entry ) throws LdapException
{
- Subordinates subordinates = new Subordinates();
-
- return subordinates;
+ return new Subordinates();
}
diff --git a/core-api/src/main/java/org/apache/directory/server/core/api/schema/registries/synchronizers/AbstractRegistrySynchronizer.java b/core-api/src/main/java/org/apache/directory/server/core/api/schema/registries/synchronizers/AbstractRegistrySynchronizer.java
index e74c12d..4676fd2 100644
--- a/core-api/src/main/java/org/apache/directory/server/core/api/schema/registries/synchronizers/AbstractRegistrySynchronizer.java
+++ b/core-api/src/main/java/org/apache/directory/server/core/api/schema/registries/synchronizers/AbstractRegistrySynchronizer.java
@@ -91,7 +91,7 @@
}
- protected AbstractRegistrySynchronizer( SchemaManager schemaManager ) throws Exception
+ protected AbstractRegistrySynchronizer( SchemaManager schemaManager )
{
this.schemaManager = schemaManager;
moidAT = schemaManager.getAttributeType( MetaSchemaConstants.M_OID_AT );
@@ -106,7 +106,7 @@
* @return true if the schema is loaded
* @throws Exception If The Dn is not a SchemaObject Dn
*/
- protected boolean isSchemaLoaded( Dn dn ) throws Exception
+ protected boolean isSchemaLoaded( Dn dn ) throws LdapException
{
return schemaManager.isSchemaLoaded( getSchemaName( dn ) );
}
@@ -232,7 +232,7 @@
}
- protected void checkOidIsUnique( SchemaObject schemaObject ) throws Exception
+ protected void checkOidIsUnique( SchemaObject schemaObject ) throws LdapException
{
String oid = schemaObject.getOid();
diff --git a/core-api/src/main/java/org/apache/directory/server/core/api/sp/LdapClassLoader.java b/core-api/src/main/java/org/apache/directory/server/core/api/sp/LdapClassLoader.java
index c65635a..440de4d 100644
--- a/core-api/src/main/java/org/apache/directory/server/core/api/sp/LdapClassLoader.java
+++ b/core-api/src/main/java/org/apache/directory/server/core/api/sp/LdapClassLoader.java
@@ -174,11 +174,17 @@
{
classBytes = findClassInDIT( searchContexts, name );
- LOG.debug( "Class " + name + " found under default search contexts." );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( "Class {} found under default search contexts.", name );
+ }
}
catch ( ClassNotFoundException e )
{
- LOG.debug( "Class " + name + " could not be found under default search contexts." );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( "Class {} could not be found under default search contexts.", name );
+ }
}
}
diff --git a/core-api/src/main/java/org/apache/directory/server/core/api/sp/StoredProcExecutionManager.java b/core-api/src/main/java/org/apache/directory/server/core/api/sp/StoredProcExecutionManager.java
index 8661ed3..02b48e0 100644
--- a/core-api/src/main/java/org/apache/directory/server/core/api/sp/StoredProcExecutionManager.java
+++ b/core-api/src/main/java/org/apache/directory/server/core/api/sp/StoredProcExecutionManager.java
@@ -127,13 +127,7 @@
{
engine = engineType.newInstance();
}
- catch ( InstantiationException e )
- {
- LdapException ne = new LdapException( e.getMessage(), e );
- ne.initCause( e );
- throw ne;
- }
- catch ( IllegalAccessException e )
+ catch ( InstantiationException | IllegalAccessException e )
{
LdapException ne = new LdapException( e.getMessage(), e );
ne.initCause( e );
diff --git a/core-api/src/main/java/org/apache/directory/server/core/api/sp/java/JavaStoredProcEngine.java b/core-api/src/main/java/org/apache/directory/server/core/api/sp/java/JavaStoredProcEngine.java
index 25b851e..1b957a3 100644
--- a/core-api/src/main/java/org/apache/directory/server/core/api/sp/java/JavaStoredProcEngine.java
+++ b/core-api/src/main/java/org/apache/directory/server/core/api/sp/java/JavaStoredProcEngine.java
@@ -86,15 +86,7 @@
{
return proc.invoke( null, spArgs );
}
- catch ( IllegalArgumentException e )
- {
- throw new LdapException( e );
- }
- catch ( IllegalAccessException e )
- {
- throw new LdapException( e );
- }
- catch ( InvocationTargetException e )
+ catch ( IllegalArgumentException | IllegalAccessException | InvocationTargetException e )
{
throw new LdapException( e );
}
diff --git a/core-api/src/main/java/org/apache/directory/server/core/api/subtree/SubtreeEvaluator.java b/core-api/src/main/java/org/apache/directory/server/core/api/subtree/SubtreeEvaluator.java
index 6473559..e27f568 100644
--- a/core-api/src/main/java/org/apache/directory/server/core/api/subtree/SubtreeEvaluator.java
+++ b/core-api/src/main/java/org/apache/directory/server/core/api/subtree/SubtreeEvaluator.java
@@ -117,7 +117,7 @@
*/
// Now, get the entry's relative part
- if ( ( subtree.getChopBeforeExclusions().size() != 0 ) || ( subtree.getChopAfterExclusions().size() != 0 ) )
+ if ( !subtree.getChopBeforeExclusions().isEmpty() || !subtree.getChopAfterExclusions().isEmpty() )
{
Dn entryRelativeDn = entryDn.getDescendantOf( apDn ).getDescendantOf( subtree.getBase() );
diff --git a/core-avl/src/main/java/org/apache/directory/server/core/avltree/ArrayMarshaller.java b/core-avl/src/main/java/org/apache/directory/server/core/avltree/ArrayMarshaller.java
index e4c1a11..6dffa4d 100644
--- a/core-avl/src/main/java/org/apache/directory/server/core/avltree/ArrayMarshaller.java
+++ b/core-avl/src/main/java/org/apache/directory/server/core/avltree/ArrayMarshaller.java
@@ -114,19 +114,6 @@
out.flush();
data = byteStream.toByteArray();
- // Try to deserialize, just to see
- /*
- try
- {
- deserialize( data );
- }
- catch ( NullPointerException npe )
- {
- System.out.println( I18n.err( I18n.ERR_438, Strings.dumpBytes( data ) ) );
- throw npe;
- }
- */
-
out.close();
}
catch ( IOException e )
@@ -145,8 +132,6 @@
*/
public ArrayTree<E> deserialize( byte[] data ) throws IOException
{
- //LOG.debug( "Deserializing the tree, called by {}", Reflection.getCallerClass( 2 ).getSimpleName() );
-
try
{
if ( ( data == null ) || ( data.length == 0 ) )
@@ -158,8 +143,7 @@
{
E[] array = ( E[] ) new Object[]
{};
- ArrayTree<E> tree = new ArrayTree<E>( comparator, array );
- return tree;
+ return new ArrayTree<>( comparator, array );
}
ByteArrayInputStream bin = new ByteArrayInputStream( data );
@@ -190,9 +174,7 @@
}
}
- ArrayTree<E> arrayTree = new ArrayTree<E>( comparator, nodes );
-
- return arrayTree;
+ return new ArrayTree<>( comparator, nodes );
}
catch ( NullPointerException npe )
{
diff --git a/core-avl/src/main/java/org/apache/directory/server/core/avltree/ArrayTree.java b/core-avl/src/main/java/org/apache/directory/server/core/avltree/ArrayTree.java
index 4ce7f04..6ea1387 100644
--- a/core-avl/src/main/java/org/apache/directory/server/core/avltree/ArrayTree.java
+++ b/core-avl/src/main/java/org/apache/directory/server/core/avltree/ArrayTree.java
@@ -215,7 +215,7 @@
*/
public List<K> getKeys()
{
- List<K> list = new ArrayList<K>( size );
+ List<K> list = new ArrayList<>( size );
for ( int i = 0; i < size; i++ )
{
@@ -237,7 +237,7 @@
return;
}
- boolean isFirst = false;
+ boolean isFirst = true;
for ( K key : array )
{
@@ -259,9 +259,8 @@
* Get the element at a given position
* @param position The position in the tree
* @return The found key, or null if the position is out of scope
- * @throws ArrayIndexOutOfBoundsException If the position is not within the array boundaries
*/
- public K get( int position ) throws ArrayIndexOutOfBoundsException
+ public K get( int position )
{
if ( ( position < 0 ) || ( position >= size ) )
{
diff --git a/core-avl/src/main/java/org/apache/directory/server/core/avltree/ArrayTreeCursor.java b/core-avl/src/main/java/org/apache/directory/server/core/avltree/ArrayTreeCursor.java
index a982e82..96e7dab 100644
--- a/core-avl/src/main/java/org/apache/directory/server/core/avltree/ArrayTreeCursor.java
+++ b/core-avl/src/main/java/org/apache/directory/server/core/avltree/ArrayTreeCursor.java
@@ -315,6 +315,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void close() throws IOException
{
if ( IS_DEBUG )
@@ -329,6 +330,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void close( Exception reason ) throws IOException
{
if ( IS_DEBUG )
@@ -343,6 +345,7 @@
/**
* @see Object#toString()
*/
+ @Override
public String toString( String tabs )
{
StringBuilder sb = new StringBuilder();
diff --git a/core-avl/src/main/java/org/apache/directory/server/core/avltree/AvlSingletonOrOrderedSetCursor.java b/core-avl/src/main/java/org/apache/directory/server/core/avltree/AvlSingletonOrOrderedSetCursor.java
index 1c0c625..f3428e6 100644
--- a/core-avl/src/main/java/org/apache/directory/server/core/avltree/AvlSingletonOrOrderedSetCursor.java
+++ b/core-avl/src/main/java/org/apache/directory/server/core/avltree/AvlSingletonOrOrderedSetCursor.java
@@ -55,7 +55,7 @@
/** The current position of this cursor, relative to the node */
private Position position = Position.BEFORE_FIRST;
- private Tuple<K, SingletonOrOrderedSet<V>> returnedTuple = new Tuple<K, SingletonOrOrderedSet<V>>();
+ private Tuple<K, SingletonOrOrderedSet<V>> returnedTuple = new Tuple<>();
public AvlSingletonOrOrderedSetCursor( AvlTreeMap<K, V> tree )
diff --git a/core-avl/src/main/java/org/apache/directory/server/core/avltree/AvlTreeCursor.java b/core-avl/src/main/java/org/apache/directory/server/core/avltree/AvlTreeCursor.java
index 421add6..5cdcb75 100644
--- a/core-avl/src/main/java/org/apache/directory/server/core/avltree/AvlTreeCursor.java
+++ b/core-avl/src/main/java/org/apache/directory/server/core/avltree/AvlTreeCursor.java
@@ -292,6 +292,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void close() throws IOException
{
if ( IS_DEBUG )
@@ -306,6 +307,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void close( Exception reason ) throws IOException
{
if ( IS_DEBUG )
diff --git a/core-avl/src/main/java/org/apache/directory/server/core/avltree/AvlTreeImpl.java b/core-avl/src/main/java/org/apache/directory/server/core/avltree/AvlTreeImpl.java
index f187bb5..5b4654c 100644
--- a/core-avl/src/main/java/org/apache/directory/server/core/avltree/AvlTreeImpl.java
+++ b/core-avl/src/main/java/org/apache/directory/server/core/avltree/AvlTreeImpl.java
@@ -79,18 +79,18 @@
if ( root == null )
{
- root = new LinkedAvlNode<K>( key );
+ root = new LinkedAvlNode<>( key );
first = root;
last = root;
size++;
return null;
}
- node = new LinkedAvlNode<K>( key );
+ node = new LinkedAvlNode<>( key );
temp = root;
- List<LinkedAvlNode<K>> treePath = new ArrayList<LinkedAvlNode<K>>();
+ List<LinkedAvlNode<K>> treePath = new ArrayList<>();
while ( temp != null )
{
@@ -212,7 +212,7 @@
LinkedAvlNode<K> temp = null;
LinkedAvlNode<K> y = null;
- List<LinkedAvlNode<K>> treePath = new ArrayList<LinkedAvlNode<K>>();
+ List<LinkedAvlNode<K>> treePath = new ArrayList<>();
treePath = find( key, root, treePath );
@@ -453,7 +453,7 @@
*/
public List<K> getKeys()
{
- List<K> keys = new ArrayList<K>();
+ List<K> keys = new ArrayList<>();
LinkedAvlNode<K> node = first;
while ( node != null )
@@ -835,7 +835,7 @@
x = x.right;
}
- path = new ArrayList<LinkedAvlNode<K>>( 2 );
+ path = new ArrayList<>( 2 );
path.add( x );
if ( y != null )
@@ -871,7 +871,7 @@
x = x.left;
}
- path = new ArrayList<LinkedAvlNode<K>>( 2 );
+ path = new ArrayList<>( 2 );
path.add( x );
if ( y != null )
diff --git a/core-avl/src/main/java/org/apache/directory/server/core/avltree/AvlTreeMapImpl.java b/core-avl/src/main/java/org/apache/directory/server/core/avltree/AvlTreeMapImpl.java
index bf5f454..6993a3c 100644
--- a/core-avl/src/main/java/org/apache/directory/server/core/avltree/AvlTreeMapImpl.java
+++ b/core-avl/src/main/java/org/apache/directory/server/core/avltree/AvlTreeMapImpl.java
@@ -153,18 +153,18 @@
if ( root == null )
{
- root = new LinkedAvlMapNode<K, V>( key, value );
+ root = new LinkedAvlMapNode<>( key, value );
first = root;
last = root;
size++;
return null;
}
- node = new LinkedAvlMapNode<K, V>( key, value );
+ node = new LinkedAvlMapNode<>( key, value );
temp = root;
- List<LinkedAvlMapNode<K, V>> treePath = new ArrayList<LinkedAvlMapNode<K, V>>();
+ List<LinkedAvlMapNode<K, V>> treePath = new ArrayList<>();
while ( temp != null )
{
@@ -235,7 +235,7 @@
else
{
// create avlTree, insert singleton into it, then switch modes
- dupsTree = new AvlTreeImpl<V>( valueComparator );
+ dupsTree = new AvlTreeImpl<>( valueComparator );
dupsTree.insert( existingNode.value.getSingleton() );
existingNode.value.switchToOrderedSet( dupsTree );
}
@@ -333,7 +333,7 @@
LinkedAvlMapNode<K, V> temp = null;
- List<LinkedAvlMapNode<K, V>> treePath = new ArrayList<LinkedAvlMapNode<K, V>>();
+ List<LinkedAvlMapNode<K, V>> treePath = new ArrayList<>();
treePath = find( key, root, treePath );
@@ -370,7 +370,7 @@
LinkedAvlMapNode<K, V> temp = null;
- List<LinkedAvlMapNode<K, V>> treePath = new ArrayList<LinkedAvlMapNode<K, V>>();
+ List<LinkedAvlMapNode<K, V>> treePath = new ArrayList<>();
treePath = find( key, root, treePath );
@@ -395,14 +395,7 @@
// if the tree is empty because of the removal, the entire
// node will be removed which might require balancing, so we continue
// further down in this function
- if ( ( removedVal != null ) && !dupsTree.isEmpty() )
- {
- return removedVal;//no need to balance
- }
- /*
- * if the value is not found then we should return
- */
- else if ( removedVal == null )
+ if ( ( removedVal == null ) || !dupsTree.isEmpty() )
{
return removedVal;//no need to balance
}
@@ -545,13 +538,13 @@
{
LinkedAvlMapNode<K, V> parentNode = null;
- int size = treePath.size();
+ int treePathSize = treePath.size();
for ( LinkedAvlMapNode<K, V> node : treePath )
{
int balFactor = getBalance( node );
- if ( node != root && treePath.indexOf( node ) < ( size - 1 ) )
+ if ( node != root && treePath.indexOf( node ) < ( treePathSize - 1 ) )
{
parentNode = treePath.get( treePath.indexOf( node ) + 1 );
}
@@ -659,7 +652,7 @@
*/
public List<K> getKeys()
{
- List<K> keys = new ArrayList<K>();
+ List<K> keys = new ArrayList<>();
LinkedAvlMapNode<K, V> node = first;
while ( node != null )
@@ -1082,7 +1075,7 @@
x = x.right;
}
- path = new ArrayList<LinkedAvlMapNode<K, V>>( 2 );
+ path = new ArrayList<>( 2 );
path.add( x );
if ( y != null )
@@ -1118,7 +1111,7 @@
x = x.left;
}
- path = new ArrayList<LinkedAvlMapNode<K, V>>( 2 );
+ path = new ArrayList<>( 2 );
path.add( x );
if ( y != null )
diff --git a/core-avl/src/main/java/org/apache/directory/server/core/avltree/AvlTreeMapNoDupsWrapperCursor.java b/core-avl/src/main/java/org/apache/directory/server/core/avltree/AvlTreeMapNoDupsWrapperCursor.java
index 89b3077..79735d7 100644
--- a/core-avl/src/main/java/org/apache/directory/server/core/avltree/AvlTreeMapNoDupsWrapperCursor.java
+++ b/core-avl/src/main/java/org/apache/directory/server/core/avltree/AvlTreeMapNoDupsWrapperCursor.java
@@ -48,7 +48,7 @@
private static final boolean IS_DEBUG = LOG_CURSOR.isDebugEnabled();
private final AvlSingletonOrOrderedSetCursor<K, V> wrapped;
- private final Tuple<K, V> returnedTuple = new Tuple<K, V>();
+ private final Tuple<K, V> returnedTuple = new Tuple<>();
public AvlTreeMapNoDupsWrapperCursor( AvlSingletonOrOrderedSetCursor<K, V> wrapped )
@@ -189,6 +189,10 @@
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
public void close() throws IOException
{
if ( IS_DEBUG )
@@ -200,6 +204,10 @@
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
public void close( Exception reason ) throws IOException
{
if ( IS_DEBUG )
diff --git a/core-avl/src/main/java/org/apache/directory/server/core/avltree/AvlTreeMarshaller.java b/core-avl/src/main/java/org/apache/directory/server/core/avltree/AvlTreeMarshaller.java
index da32041..71cf3ee 100644
--- a/core-avl/src/main/java/org/apache/directory/server/core/avltree/AvlTreeMarshaller.java
+++ b/core-avl/src/main/java/org/apache/directory/server/core/avltree/AvlTreeMarshaller.java
@@ -104,7 +104,6 @@
writeTree( tree.getRoot(), out );
out.flush();
data = byteStream.toByteArray();
- out.close();
}
catch ( IOException e )
{
@@ -171,7 +170,7 @@
if ( data.length == 1 && data[0] == 0 )
{
- return new AvlTreeImpl<E>( comparator );
+ return new AvlTreeImpl<>( comparator );
}
ByteArrayInputStream bin = new ByteArrayInputStream( data );
diff --git a/core-avl/src/main/java/org/apache/directory/server/core/avltree/AvlTreeSingleton.java b/core-avl/src/main/java/org/apache/directory/server/core/avltree/AvlTreeSingleton.java
index 6cceafe..5e5edc3 100644
--- a/core-avl/src/main/java/org/apache/directory/server/core/avltree/AvlTreeSingleton.java
+++ b/core-avl/src/main/java/org/apache/directory/server/core/avltree/AvlTreeSingleton.java
@@ -40,7 +40,7 @@
public AvlTreeSingleton( K key, Comparator<K> comparator )
{
- this.singleton = new LinkedAvlNode<K>( key );
+ this.singleton = new LinkedAvlNode<>( key );
this.comparator = comparator;
}
diff --git a/core-avl/src/main/java/org/apache/directory/server/core/avltree/DefaultMarshaller.java b/core-avl/src/main/java/org/apache/directory/server/core/avltree/DefaultMarshaller.java
index ccf91bd..0bce6f5 100644
--- a/core-avl/src/main/java/org/apache/directory/server/core/avltree/DefaultMarshaller.java
+++ b/core-avl/src/main/java/org/apache/directory/server/core/avltree/DefaultMarshaller.java
@@ -47,7 +47,6 @@
out.writeObject( object );
out.flush();
byte[] data = byteStream.toByteArray();
- out.close();
return data;
}
diff --git a/core-avl/src/main/java/org/apache/directory/server/core/avltree/KeyTupleAvlCursor.java b/core-avl/src/main/java/org/apache/directory/server/core/avltree/KeyTupleAvlCursor.java
index b3097b3..2cf054e 100644
--- a/core-avl/src/main/java/org/apache/directory/server/core/avltree/KeyTupleAvlCursor.java
+++ b/core-avl/src/main/java/org/apache/directory/server/core/avltree/KeyTupleAvlCursor.java
@@ -50,7 +50,7 @@
private final AvlTreeCursor<V> wrapped;
private final K key;
- private Tuple<K, V> returnedTuple = new Tuple<K, V>();
+ private Tuple<K, V> returnedTuple = new Tuple<>();
private boolean valueAvailable;
@@ -68,7 +68,7 @@
}
this.key = key;
- this.wrapped = new AvlTreeCursor<V>( avlTree );
+ this.wrapped = new AvlTreeCursor<>( avlTree );
}
@@ -255,6 +255,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void close() throws IOException
{
if ( IS_DEBUG )
@@ -274,6 +275,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void close( Exception cause ) throws IOException
{
if ( IS_DEBUG )
diff --git a/core-avl/src/main/java/org/apache/directory/server/core/avltree/avl/AvlTreeSet.java b/core-avl/src/main/java/org/apache/directory/server/core/avltree/avl/AvlTreeSet.java
index 93a9f48..f41cbb3 100644
--- a/core-avl/src/main/java/org/apache/directory/server/core/avltree/avl/AvlTreeSet.java
+++ b/core-avl/src/main/java/org/apache/directory/server/core/avltree/avl/AvlTreeSet.java
@@ -37,7 +37,7 @@
private final boolean useFreeList;
- private Stack<AvlNode<T>> freeList = new Stack<AvlNode<T>>();
+ private Stack<AvlNode<T>> freeList = new Stack<>();
public AvlTreeSet()
@@ -66,7 +66,7 @@
public final Iterator<T> iterator()
{
- return new AvlTreeIterator<T>( tree );
+ return new AvlTreeIterator<>( tree );
}
@@ -135,7 +135,7 @@
{
if ( !useFreeList || freeList.isEmpty() )
{
- return new AvlNode<T>( parent, value );
+ return new AvlNode<>( parent, value );
}
else
{
diff --git a/core-shared/src/main/java/org/apache/directory/server/core/shared/DefaultCoreSession.java b/core-shared/src/main/java/org/apache/directory/server/core/shared/DefaultCoreSession.java
index 41f311b..bfceb2a 100644
--- a/core-shared/src/main/java/org/apache/directory/server/core/shared/DefaultCoreSession.java
+++ b/core-shared/src/main/java/org/apache/directory/server/core/shared/DefaultCoreSession.java
@@ -1227,18 +1227,6 @@
{
// Don't close the transaction !!!
LOG.debug( "Search done, the transaction is still opened" );
- /*
- try
- {
- ( ( EntryFilteringCursor ) cursor ).getOperationContext().getTransaction().close();
- }
- catch ( IOException ioe )
- {
- done.addAllControls( searchContext.getResponseControls() );
-
- throw new LdapOtherException( ioe.getMessage(), ioe );
- }
- */
}
if ( sortRespCtrl != null )
diff --git a/core-shared/src/main/java/org/apache/directory/server/core/shared/ReferralManagerImpl.java b/core-shared/src/main/java/org/apache/directory/server/core/shared/ReferralManagerImpl.java
index 126286b..c4d3b16 100644
--- a/core-shared/src/main/java/org/apache/directory/server/core/shared/ReferralManagerImpl.java
+++ b/core-shared/src/main/java/org/apache/directory/server/core/shared/ReferralManagerImpl.java
@@ -143,8 +143,6 @@
/**
* {@inheritDoc}
*/
- // This will suppress PMD.EmptyCatchBlock warnings in this method
- @SuppressWarnings("PMD.EmptyCatchBlock")
@Override
public void addReferral( Entry entry )
{
diff --git a/core-shared/src/main/java/org/apache/directory/server/core/shared/SchemaService.java b/core-shared/src/main/java/org/apache/directory/server/core/shared/SchemaService.java
index f7a4a86..99a7628 100644
--- a/core-shared/src/main/java/org/apache/directory/server/core/shared/SchemaService.java
+++ b/core-shared/src/main/java/org/apache/directory/server/core/shared/SchemaService.java
@@ -400,7 +400,7 @@
Entry mods =
directoryService.getSchemaPartition().lookup( lookupContext );
- // @todo enable this optimization at some point but for now it
+ // TODO enable this optimization at some point but for now it
// is causing some problems so I will just turn it off
// Attribute modifyTimeDisk = mods.get( SchemaConstants.MODIFY_TIMESTAMP_AT );
//
@@ -436,8 +436,6 @@
throw new LdapOtherException( ioe.getMessage(), ioe );
}
- // }
-
// ---------------------------------------------------------------
// Prep Work: Transform the attributes to their OID counterpart
// ---------------------------------------------------------------
diff --git a/core-shared/src/main/java/org/apache/directory/server/core/shared/SortedEntrySerializer.java b/core-shared/src/main/java/org/apache/directory/server/core/shared/SortedEntrySerializer.java
index fb719d4..404a801 100644
--- a/core-shared/src/main/java/org/apache/directory/server/core/shared/SortedEntrySerializer.java
+++ b/core-shared/src/main/java/org/apache/directory/server/core/shared/SortedEntrySerializer.java
@@ -208,7 +208,7 @@
if ( IS_DEBUG )
{
LOG.debug( ">------------------------------------------------" );
- LOG.debug( "Serialize " + entry );
+ LOG.debug( "Serialize {}", entry );
}
return baos.toByteArray();
diff --git a/core-shared/src/main/java/org/apache/directory/server/core/shared/partition/DefaultPartitionNexus.java b/core-shared/src/main/java/org/apache/directory/server/core/shared/partition/DefaultPartitionNexus.java
index 8042409..208cf56 100644
--- a/core-shared/src/main/java/org/apache/directory/server/core/shared/partition/DefaultPartitionNexus.java
+++ b/core-shared/src/main/java/org/apache/directory/server/core/shared/partition/DefaultPartitionNexus.java
@@ -428,7 +428,7 @@
if ( IS_DEBUG )
{
- LOG.debug( "Check if Dn '" + dn + "' exists." );
+ LOG.debug( "Check if Dn '{}' exists.", dn );
}
if ( dn.isRootDse() )
@@ -595,15 +595,9 @@
{
AttributeType type = schemaManager.lookupAttributeTypeRegistry( attribute.getId() );
- if ( realIds.contains( type.getOid() ) )
- {
- serverEntry.put( attribute );
- }
- else if ( allUserAttributes && ( type.getUsage() == UsageEnum.USER_APPLICATIONS ) )
- {
- serverEntry.put( attribute );
- }
- else if ( allOperationalAttributes && ( type.getUsage() != UsageEnum.USER_APPLICATIONS ) )
+ if ( realIds.contains( type.getOid() )
+ || ( allUserAttributes && ( type.getUsage() == UsageEnum.USER_APPLICATIONS ) )
+ || ( allOperationalAttributes && ( type.getUsage() != UsageEnum.USER_APPLICATIONS ) ) )
{
serverEntry.put( attribute );
}
@@ -633,7 +627,7 @@
// Not sure we need this code...
if ( !baseDn.isSchemaAware() )
{
- baseDn = new Dn( schemaManager, baseDn );
+ searchContext.setDn( new Dn( schemaManager, baseDn ) );
}
// Normal case : do a search on the specific partition
@@ -1041,7 +1035,7 @@
* BackendNexus.
* @throws Exception if there are problems unregistering the partition
*/
- private void unregister( Partition partition ) throws LdapException
+ private void unregister( Partition partition )
{
Attribute namingContexts = rootDse.get( SchemaConstants.NAMING_CONTEXTS_AT );
diff --git a/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java b/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
index f5c6c6c..7ded3e7 100644
--- a/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
+++ b/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
@@ -530,24 +530,10 @@
for ( Method method : methods )
{
Class<?>[] param = method.getParameterTypes();
- boolean hasCorrestSig;
// check for the correct signature
- if ( ( param == null ) || ( param.length > 1 ) || ( param.length == 0 ) )
- {
- continue;
- }
-
- if ( OperationContext.class.isAssignableFrom( param[0] ) )
- {
- hasCorrestSig = true;
- }
- else
- {
- continue;
- }
-
- if ( hasCorrestSig && method.getName().equals( operation.getMethodName() ) )
+ if ( ( param != null ) && ( param.length == 1 )
+ && OperationContext.class.isAssignableFrom( param[0] ) && method.getName().equals( operation.getMethodName() ) )
{
if ( !selectedInterceptorList.contains( interceptor.getName() ) )
{
@@ -743,49 +729,34 @@
this.instanceLayout = instanceLayout;
// Create the directories if they are missing
- if ( !instanceLayout.getInstanceDirectory().exists() )
+ if ( !instanceLayout.getInstanceDirectory().exists() && !instanceLayout.getInstanceDirectory().mkdirs() )
{
- if ( !instanceLayout.getInstanceDirectory().mkdirs() )
- {
- throw new IOException( I18n.err( I18n.ERR_112_COULD_NOT_CREATE_DIRECTORY,
- instanceLayout.getInstanceDirectory() ) );
- }
+ throw new IOException( I18n.err( I18n.ERR_112_COULD_NOT_CREATE_DIRECTORY,
+ instanceLayout.getInstanceDirectory() ) );
}
- if ( !instanceLayout.getLogDirectory().exists() )
+ if ( !instanceLayout.getLogDirectory().exists() && !instanceLayout.getLogDirectory().mkdirs() )
{
- if ( !instanceLayout.getLogDirectory().mkdirs() )
- {
- throw new IOException( I18n.err( I18n.ERR_112_COULD_NOT_CREATE_DIRECTORY,
- instanceLayout.getLogDirectory() ) );
- }
+ throw new IOException( I18n.err( I18n.ERR_112_COULD_NOT_CREATE_DIRECTORY,
+ instanceLayout.getLogDirectory() ) );
}
- if ( !instanceLayout.getRunDirectory().exists() )
+ if ( !instanceLayout.getRunDirectory().exists() && !instanceLayout.getRunDirectory().mkdirs() )
{
- if ( !instanceLayout.getRunDirectory().mkdirs() )
- {
- throw new IOException( I18n.err( I18n.ERR_112_COULD_NOT_CREATE_DIRECTORY,
- instanceLayout.getRunDirectory() ) );
- }
+ throw new IOException( I18n.err( I18n.ERR_112_COULD_NOT_CREATE_DIRECTORY,
+ instanceLayout.getRunDirectory() ) );
}
- if ( !instanceLayout.getPartitionsDirectory().exists() )
+ if ( !instanceLayout.getPartitionsDirectory().exists() && !instanceLayout.getPartitionsDirectory().mkdirs() )
{
- if ( !instanceLayout.getPartitionsDirectory().mkdirs() )
- {
- throw new IOException( I18n.err( I18n.ERR_112_COULD_NOT_CREATE_DIRECTORY,
- instanceLayout.getPartitionsDirectory() ) );
- }
+ throw new IOException( I18n.err( I18n.ERR_112_COULD_NOT_CREATE_DIRECTORY,
+ instanceLayout.getPartitionsDirectory() ) );
}
- if ( !instanceLayout.getConfDirectory().exists() )
+ if ( !instanceLayout.getConfDirectory().exists() && !instanceLayout.getConfDirectory().mkdirs() )
{
- if ( !instanceLayout.getConfDirectory().mkdirs() )
- {
- throw new IOException( I18n.err( I18n.ERR_112_COULD_NOT_CREATE_DIRECTORY,
- instanceLayout.getConfDirectory() ) );
- }
+ throw new IOException( I18n.err( I18n.ERR_112_COULD_NOT_CREATE_DIRECTORY,
+ instanceLayout.getConfDirectory() ) );
}
}
@@ -888,18 +859,10 @@
{
partition.setSchemaManager( schemaManager );
- try
+ // can be null when called before starting up
+ if ( partitionNexus != null )
{
- // can be null when called before starting up
- if ( partitionNexus != null )
- {
- partitionNexus.addContextPartition( partition );
- }
- }
- catch ( LdapException le )
- {
- // We've got an exception, we cannot add the partition to the partitions
- throw le;
+ partitionNexus.addContextPartition( partition );
}
// Now, add the partition to the set of managed partitions
@@ -913,18 +876,10 @@
public void removePartition( Partition partition ) throws LdapException
{
// Do the backend cleanup first
- try
+ // can be null when called before starting up
+ if ( partitionNexus != null )
{
- // can be null when called before starting up
- if ( partitionNexus != null )
- {
- partitionNexus.removeContextPartition( partition.getSuffixDn().getNormName() );
- }
- }
- catch ( LdapException le )
- {
- // Bad ! We can't go any further
- throw le;
+ partitionNexus.removeContextPartition( partition.getSuffixDn().getNormName() );
}
// And update the set of managed partitions
@@ -1837,9 +1792,9 @@
// Warn if the default password is not changed.
boolean needToChangeAdminPassword;
- Dn adminDn = getDnFactory().create( ServerDNConstants.ADMIN_SYSTEM_DN );
- Partition partition = partitionNexus.getPartition( adminDn );
- LookupOperationContext lookupContext = new LookupOperationContext( adminSession, adminDn );
+ Dn admin = getDnFactory().create( ServerDNConstants.ADMIN_SYSTEM_DN );
+ Partition partition = partitionNexus.getPartition( admin );
+ LookupOperationContext lookupContext = new LookupOperationContext( adminSession, admin );
lookupContext.setPartition( partition );
Entry adminEntry;
@@ -1859,8 +1814,8 @@
if ( needToChangeAdminPassword )
{
- LOG.warn( "You didn't change the admin password of directory service " + "instance '" + instanceId + "'. "
- + "Please update the admin password as soon as possible " + "to prevent a possible security breach." );
+ LOG.warn( "You didn't change the admin password of directory service instance '{}'. "
+ + "Please update the admin password as soon as possible to prevent a possible security breach.", instanceId );
}
}
@@ -1868,7 +1823,7 @@
/**
* Adds test entries into the core.
*
- * @todo this may no longer be needed when JNDI is not used for bootstrapping
+ * TODO this may no longer be needed when JNDI is not used for bootstrapping
*
* @throws LdapException if the creation of test entries fails.
*/
@@ -1905,9 +1860,9 @@
// Add root context entry for system partition
Dn systemSuffixDn = getDnFactory().create( ServerDNConstants.SYSTEM_DN );
- CoreSession adminSession = getAdminSession();
+ CoreSession admin = getAdminSession();
- HasEntryOperationContext hasEntryContext = new HasEntryOperationContext( adminSession, systemSuffixDn );
+ HasEntryOperationContext hasEntryContext = new HasEntryOperationContext( admin, systemSuffixDn );
Partition partition = getPartitionNexus().getPartition( systemSuffixDn );
hasEntryContext.setPartition( partition );
@@ -1931,7 +1886,7 @@
systemEntry.put( DnUtils.getRdnAttributeType( ServerDNConstants.SYSTEM_DN ), DnUtils
.getRdnValue( ServerDNConstants.SYSTEM_DN ) );
- AddOperationContext addOperationContext = new AddOperationContext( adminSession, systemEntry );
+ AddOperationContext addOperationContext = new AddOperationContext( admin, systemEntry );
addOperationContext.setPartition( partition );
PartitionTxn writeTxn = null;
@@ -2029,7 +1984,7 @@
adminSession = new DefaultCoreSession( new LdapPrincipal( schemaManager, adminDn, AuthenticationLevel.STRONG ),
this );
- // @TODO - NOTE: Need to find a way to instantiate without dependency on DPN
+ // TODO - NOTE: Need to find a way to instantiate without dependency on DPN
partitionNexus = new DefaultPartitionNexus( new DefaultEntry( schemaManager, Dn.ROOT_DSE ) );
partitionNexus.setDirectoryService( this );
partitionNexus.initialize();
@@ -2100,8 +2055,6 @@
* @param text The ldif format file
* @return An entry.
*/
- // This will suppress PMD.EmptyCatchBlock warnings in this method
- @SuppressWarnings("PMD.EmptyCatchBlock")
private Entry readEntry( String text )
{
StringReader strIn = new StringReader( text );
@@ -2178,7 +2131,6 @@
entry.setDn( newDn );
- // TODO Let's get rid of this Attributes crap
return new DefaultEntry( schemaManager, entry );
}
catch ( Exception e )
diff --git a/core/src/main/java/org/apache/directory/server/core/DefaultOperationManager.java b/core/src/main/java/org/apache/directory/server/core/DefaultOperationManager.java
index d1393d4..0b560b6 100644
--- a/core/src/main/java/org/apache/directory/server/core/DefaultOperationManager.java
+++ b/core/src/main/java/org/apache/directory/server/core/DefaultOperationManager.java
@@ -183,10 +183,7 @@
else
{
// This is an error : we *must* have an entry if we want to be able to rename.
- LdapNoSuchObjectException ldnfe = new LdapNoSuchObjectException( I18n.err( I18n.ERR_256_NO_SUCH_OBJECT,
- opContext.getDn() ) );
-
- throw ldnfe;
+ throw new LdapNoSuchObjectException( I18n.err( I18n.ERR_256_NO_SUCH_OBJECT, opContext.getDn() ) );
}
}
}
@@ -208,10 +205,8 @@
else
{
// This is an error : we *must* have an entry if we want to be able to rename.
- LdapNoSuchObjectException ldnfe = new LdapNoSuchObjectException( I18n.err( I18n.ERR_256_NO_SUCH_OBJECT,
+ throw new LdapNoSuchObjectException( I18n.err( I18n.ERR_256_NO_SUCH_OBJECT,
opContext.getDn() ) );
-
- throw ldnfe;
}
}
@@ -221,7 +216,7 @@
// Get the Ref attributeType
Attribute refs = parentEntry.get( SchemaConstants.REF_AT );
- List<String> urls = new ArrayList<String>();
+ List<String> urls = new ArrayList<>();
try
{
@@ -263,7 +258,7 @@
// Get the Ref attributeType
Attribute refs = parentEntry.get( SchemaConstants.REF_AT );
- List<String> urls = new ArrayList<String>();
+ List<String> urls = new ArrayList<>();
// manage each Referral, building the correct URL for each of them
for ( Value url : refs )
@@ -387,13 +382,11 @@
// a different exception.
if ( addContext.isReferralIgnored() )
{
- LdapPartialResultException exception = buildLdapPartialResultException( childDn );
- throw exception;
+ throw buildLdapPartialResultException( childDn );
}
else
{
- LdapReferralException exception = buildReferralException( parentEntry, childDn );
- throw exception;
+ throw buildReferralException( parentEntry, childDn );
}
}
}
@@ -460,7 +453,7 @@
if ( IS_TIME )
{
- OPERATION_TIME.debug( "Add operation took " + ( System.nanoTime() - addStart ) + " ns" );
+ OPERATION_TIME.debug( "Add operation took {} ns", ( System.nanoTime() - addStart ) );
}
}
@@ -526,7 +519,7 @@
if ( IS_TIME )
{
- OPERATION_TIME.debug( "Bind operation took " + ( System.nanoTime() - opStart ) + " ns" );
+ OPERATION_TIME.debug( "Bind operation took {} ns", ( System.nanoTime() - opStart ) );
}
}
@@ -579,8 +572,7 @@
if ( !compareContext.isReferralIgnored() )
{
// Throw a Referral Exception
- LdapReferralException exception = buildReferralException( parentEntry, childDn );
- throw exception;
+ throw buildReferralException( parentEntry, childDn );
}
}
else if ( directoryService.getReferralManager().hasParentReferral( dn ) )
@@ -589,13 +581,11 @@
// a different exception.
if ( compareContext.isReferralIgnored() )
{
- LdapPartialResultException exception = buildLdapPartialResultException( childDn );
- throw exception;
+ throw buildLdapPartialResultException( childDn );
}
else
{
- LdapReferralException exception = buildReferralException( parentEntry, childDn );
- throw exception;
+ throw buildReferralException( parentEntry, childDn );
}
}
}
@@ -644,7 +634,7 @@
if ( IS_TIME )
{
- OPERATION_TIME.debug( "Compare operation took " + ( System.nanoTime() - opStart ) + " ns" );
+ OPERATION_TIME.debug( "Compare operation took {} ns", ( System.nanoTime() - opStart ) );
}
return result;
@@ -700,8 +690,7 @@
if ( !deleteContext.isReferralIgnored() )
{
// Throw a Referral Exception
- LdapReferralException exception = buildReferralException( parentEntry, childDn );
- throw exception;
+ throw buildReferralException( parentEntry, childDn );
}
}
else if ( directoryService.getReferralManager().hasParentReferral( dn ) )
@@ -712,13 +701,11 @@
// a different exception.
if ( deleteContext.isReferralIgnored() )
{
- LdapPartialResultException exception = buildLdapPartialResultException( childDn );
- throw exception;
+ throw buildLdapPartialResultException( childDn );
}
else
{
- LdapReferralException exception = buildReferralException( parentEntry, childDn );
- throw exception;
+ throw buildReferralException( parentEntry, childDn );
}
}
}
@@ -769,10 +756,7 @@
{
try
{
- if ( transaction != null )
- {
- transaction.abort();
- }
+ transaction.abort();
throw new LdapOtherException( ioe.getMessage(), ioe );
}
@@ -793,7 +777,7 @@
if ( IS_TIME )
{
- OPERATION_TIME.debug( "Delete operation took " + ( System.nanoTime() - opStart ) + " ns" );
+ OPERATION_TIME.debug( "Delete operation took {} ns", ( System.nanoTime() - opStart ) );
}
}
@@ -989,7 +973,7 @@
if ( IS_TIME )
{
- OPERATION_TIME.debug( "Lookup operation took " + ( System.nanoTime() - opStart ) + " ns" );
+ OPERATION_TIME.debug( "Lookup operation took {} ns", ( System.nanoTime() - opStart ) );
}
return entry;
@@ -1046,8 +1030,7 @@
// We have found a parent referral for the current Dn
Dn childDn = dn.getDescendantOf( parentEntry.getDn() );
- LdapReferralException exception = buildReferralException( parentEntry, childDn );
- throw exception;
+ throw buildReferralException( parentEntry, childDn );
}
}
else if ( referralManager.hasParentReferral( dn ) )
@@ -1061,16 +1044,14 @@
// We have found a parent referral for the current Dn
Dn childDn = dn.getDescendantOf( parentEntry.getDn() );
- LdapPartialResultException exception = buildLdapPartialResultException( childDn );
- throw exception;
+ throw buildLdapPartialResultException( childDn );
}
else
{
// We have found a parent referral for the current Dn
Dn childDn = dn.getDescendantOf( parentEntry.getDn() );
- LdapReferralException exception = buildReferralException( parentEntry, childDn );
- throw exception;
+ throw buildReferralException( parentEntry, childDn );
}
}
}
@@ -1142,7 +1123,7 @@
if ( IS_TIME )
{
- OPERATION_TIME.debug( "Modify operation took " + ( System.nanoTime() - opStart ) + " ns" );
+ OPERATION_TIME.debug( "Modify operation took {} ns", ( System.nanoTime() - opStart ) );
}
}
@@ -1204,8 +1185,7 @@
if ( !moveContext.isReferralIgnored() )
{
// Throw a Referral Exception
- LdapReferralException exception = buildReferralException( parentEntry, childDn );
- throw exception;
+ throw buildReferralException( parentEntry, childDn );
}
}
else if ( directoryService.getReferralManager().hasParentReferral( dn ) )
@@ -1216,13 +1196,11 @@
// a different exception.
if ( moveContext.isReferralIgnored() )
{
- LdapPartialResultException exception = buildLdapPartialResultException( childDn );
- throw exception;
+ throw buildLdapPartialResultException( childDn );
}
else
{
- LdapReferralException exception = buildReferralException( parentEntry, childDn );
- throw exception;
+ throw buildReferralException( parentEntry, childDn );
}
}
}
@@ -1233,10 +1211,7 @@
if ( directoryService.getReferralManager().isReferral( newSuperiorDn )
|| directoryService.getReferralManager().hasParentReferral( newSuperiorDn ) )
{
- LdapAffectMultipleDsaException exception = new LdapAffectMultipleDsaException();
- //exception.setRemainingName( dn );
-
- throw exception;
+ throw new LdapAffectMultipleDsaException();
}
}
@@ -1313,7 +1288,7 @@
if ( IS_TIME )
{
- OPERATION_TIME.debug( "Move operation took " + ( System.nanoTime() - opStart ) + " ns" );
+ OPERATION_TIME.debug( "Move operation took {} ns", ( System.nanoTime() - opStart ) );
}
}
@@ -1366,8 +1341,7 @@
if ( !moveAndRenameContext.isReferralIgnored() )
{
// Throw a Referral Exception
- LdapReferralException exception = buildReferralException( parentEntry, childDn );
- throw exception;
+ throw buildReferralException( parentEntry, childDn );
}
}
else if ( directoryService.getReferralManager().hasParentReferral( dn ) )
@@ -1378,13 +1352,11 @@
// a different exception.
if ( moveAndRenameContext.isReferralIgnored() )
{
- LdapPartialResultException exception = buildLdapPartialResultException( childDn );
- throw exception;
+ throw buildLdapPartialResultException( childDn );
}
else
{
- LdapReferralException exception = buildReferralException( parentEntry, childDn );
- throw exception;
+ throw buildReferralException( parentEntry, childDn );
}
}
}
@@ -1406,10 +1378,7 @@
{
// The parent Dn is a referral, we have to issue a AffectMultipleDsas result
// as stated by RFC 3296 Section 5.6.2
- LdapAffectMultipleDsaException exception = new LdapAffectMultipleDsaException();
- //exception.setRemainingName( dn );
-
- throw exception;
+ throw new LdapAffectMultipleDsaException();
}
}
finally
@@ -1460,10 +1429,7 @@
{
try
{
- if ( transaction != null )
- {
- transaction.abort();
- }
+ transaction.abort();
throw new LdapOtherException( ioe.getMessage(), ioe );
}
@@ -1484,7 +1450,7 @@
if ( IS_TIME )
{
- OPERATION_TIME.debug( "MoveAndRename operation took " + ( System.nanoTime() - opStart ) + " ns" );
+ OPERATION_TIME.debug( "MoveAndRename operation took {} ns", ( System.nanoTime() - opStart ) );
}
}
@@ -1554,8 +1520,7 @@
if ( !renameContext.isReferralIgnored() )
{
// Throw a Referral Exception
- LdapReferralException exception = buildReferralException( parentEntry, childDn );
- throw exception;
+ throw buildReferralException( parentEntry, childDn );
}
}
else if ( directoryService.getReferralManager().hasParentReferral( dn ) )
@@ -1566,13 +1531,11 @@
// a different exception.
if ( renameContext.isReferralIgnored() )
{
- LdapPartialResultException exception = buildLdapPartialResultException( childDn );
- throw exception;
+ throw buildLdapPartialResultException( childDn );
}
else
{
- LdapReferralException exception = buildReferralException( parentEntry, childDn );
- throw exception;
+ throw buildReferralException( parentEntry, childDn );
}
}
}
@@ -1680,7 +1643,7 @@
if ( IS_TIME )
{
- OPERATION_TIME.debug( "Rename operation took " + ( System.nanoTime() - opStart ) + " ns" );
+ OPERATION_TIME.debug( "Rename operation took {} ns", ( System.nanoTime() - opStart ) );
}
}
@@ -1733,9 +1696,7 @@
if ( !searchContext.isReferralIgnored() )
{
// Throw a Referral Exception
- LdapReferralException exception = buildReferralExceptionForSearch( parentEntry, childDn,
- searchContext.getScope() );
- throw exception;
+ throw buildReferralExceptionForSearch( parentEntry, childDn, searchContext.getScope() );
}
}
else if ( directoryService.getReferralManager().hasParentReferral( dn ) )
@@ -1746,14 +1707,11 @@
// a different exception.
if ( searchContext.isReferralIgnored() )
{
- LdapPartialResultException exception = buildLdapPartialResultException( childDn );
- throw exception;
+ throw buildLdapPartialResultException( childDn );
}
else
{
- LdapReferralException exception = buildReferralExceptionForSearch( parentEntry, childDn,
- searchContext.getScope() );
- throw exception;
+ throw buildReferralExceptionForSearch( parentEntry, childDn, searchContext.getScope() );
}
}
}
@@ -1797,7 +1755,7 @@
if ( IS_TIME )
{
- OPERATION_TIME.debug( "Search operation took " + ( System.nanoTime() - opStart ) + " ns" );
+ OPERATION_TIME.debug( "Search operation took {} ns", ( System.nanoTime() - opStart ) );
}
return cursor;
@@ -1835,7 +1793,7 @@
if ( IS_TIME )
{
- OPERATION_TIME.debug( "Unbind operation took " + ( System.nanoTime() - opStart ) + " ns" );
+ OPERATION_TIME.debug( "Unbind operation took {} ns", ( System.nanoTime() - opStart ) );
}
}
diff --git a/core/src/main/java/org/apache/directory/server/core/security/CoreKeyStoreSpi.java b/core/src/main/java/org/apache/directory/server/core/security/CoreKeyStoreSpi.java
index 5521f96..0e9c402 100644
--- a/core/src/main/java/org/apache/directory/server/core/security/CoreKeyStoreSpi.java
+++ b/core/src/main/java/org/apache/directory/server/core/security/CoreKeyStoreSpi.java
@@ -38,6 +38,7 @@
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.NotImplementedException;
import org.apache.directory.api.ldap.model.entry.Entry;
+import org.apache.directory.api.ldap.model.exception.LdapException;
import org.apache.directory.api.ldap.model.name.Dn;
import org.apache.directory.api.util.SingletonEnumeration;
import org.apache.directory.server.constants.ServerDNConstants;
@@ -74,9 +75,10 @@
}
- private Entry getTlsEntry() throws Exception
+ private Entry getTlsEntry() throws LdapException
{
Dn adminDn = directoryService.getDnFactory().create( ServerDNConstants.ADMIN_SYSTEM_DN );
+
return directoryService.getAdminSession().lookup( adminDn );
}
@@ -88,7 +90,7 @@
public Enumeration<String> engineAliases()
{
LOG.debug( "engineAliases() called." );
- return new SingletonEnumeration<String>( APACHEDS_ALIAS );
+ return new SingletonEnumeration<>( APACHEDS_ALIAS );
}
@@ -100,12 +102,7 @@
{
LOG.debug( "engineContainsAlias({}) called.", alias );
- if ( alias.equalsIgnoreCase( APACHEDS_ALIAS ) )
- {
- return true;
- }
-
- return false;
+ return alias.equalsIgnoreCase( APACHEDS_ALIAS );
}
@@ -298,7 +295,11 @@
public void engineSetKeyEntry( String alias, Key key, char[] password, Certificate[] chain )
throws KeyStoreException
{
- LOG.debug( "engineSetKeyEntry({}, key, {}, chain) called.", alias, new String( password ) );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( "engineSetKeyEntry({}, key, {}, chain) called.", alias, new String( password ) );
+ }
+
throw new NotImplementedException();
}
@@ -309,7 +310,11 @@
@Override
public int engineSize()
{
- LOG.debug( "engineSize() called." );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( "engineSize() called." );
+ }
+
return 1;
}
@@ -321,6 +326,9 @@
public void engineStore( OutputStream stream, char[] password ) throws IOException, NoSuchAlgorithmException,
CertificateException
{
- LOG.debug( "engineStore(stream, {}) called.", new String( password ) );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( "engineStore(stream, {}) called.", new String( password ) );
+ }
}
}
diff --git a/interceptors/admin/src/main/java/org/apache/directory/server/core/admin/AdministrativePointInterceptor.java b/interceptors/admin/src/main/java/org/apache/directory/server/core/admin/AdministrativePointInterceptor.java
index b6d459d..2e907c8 100644
--- a/interceptors/admin/src/main/java/org/apache/directory/server/core/admin/AdministrativePointInterceptor.java
+++ b/interceptors/admin/src/main/java/org/apache/directory/server/core/admin/AdministrativePointInterceptor.java
@@ -329,12 +329,8 @@
{
TriggerExecutionAdministrativePoint iap = new TriggerExecutionIAP( dn, uuid );
directoryService.getTriggerExecutionAPCache().add( dn, iap );
-
- continue;
}
}
-
- return;
}
@@ -425,8 +421,6 @@
{
TriggerExecutionAdministrativePoint iap = new TriggerExecutionIAP( dn, uuid );
teapCache.add( dn, iap );
-
- return;
}
}
@@ -485,8 +479,6 @@
if ( isTriggerExecutionSpecificRole( role ) || isTriggerExecutionInnerRole( role ) )
{
teapCache.remove( dn );
-
- return;
}
}
@@ -887,8 +879,6 @@
if ( isTriggerExecutionSpecificRole( role ) || isTriggerExecutionInnerRole( role ) )
{
directoryService.getTriggerExecutionAPCache().remove( dn );
-
- continue;
}
}
}
@@ -1058,10 +1048,6 @@
LOG.error( message );
throw new LdapUnwillingToPerformException( message );
}
- else
- {
- return;
- }
}
}
@@ -1226,9 +1212,10 @@
unlock();
}
- LOG.debug( "Added an Administrative Point at {}", dn );
-
- return;
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( "Added an Administrative Point at {}", dn );
+ }
}
@@ -1291,9 +1278,10 @@
unlock();
}
- LOG.debug( "Deleted an Administrative Point at {}", dn );
-
- return;
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( "Deleted an Administrative Point at {}", dn );
+ }
}
diff --git a/interceptors/authn/src/main/java/org/apache/directory/server/core/authn/AuthenticationInterceptor.java b/interceptors/authn/src/main/java/org/apache/directory/server/core/authn/AuthenticationInterceptor.java
index d9290bf..9878872 100644
--- a/interceptors/authn/src/main/java/org/apache/directory/server/core/authn/AuthenticationInterceptor.java
+++ b/interceptors/authn/src/main/java/org/apache/directory/server/core/authn/AuthenticationInterceptor.java
@@ -41,11 +41,10 @@
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
-import java.util.HashMap;
+import java.util.EnumMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
-import java.util.Map;
import java.util.Set;
import org.apache.directory.api.ldap.extras.controls.ppolicy.PasswordPolicy;
@@ -127,7 +126,7 @@
private Set<Authenticator> authenticators = new HashSet<>();
/** A map of authenticators associated with the authentication level required */
- private final Map<AuthenticationLevel, Collection<Authenticator>> authenticatorsMapByType = new HashMap<>();
+ private final EnumMap<AuthenticationLevel, Collection<Authenticator>> authenticatorsMapByType = new EnumMap<>( AuthenticationLevel.class );
private CoreSession adminSession;
@@ -468,6 +467,12 @@
}
}
+ if ( selectedAuthenticator == null )
+ {
+ throw new LdapUnwillingToPerformException( ResultCodeEnum.UNWILLING_TO_PERFORM,
+ "Cannot Bind for Dn " + bindDn.getName() + ", there is no authenticator for it" );
+ }
+
return selectedAuthenticator;
}
@@ -968,8 +973,6 @@
break;
}
}
-
- return;
}
diff --git a/interceptors/authn/src/main/java/org/apache/directory/server/core/authn/DelegatingAuthenticator.java b/interceptors/authn/src/main/java/org/apache/directory/server/core/authn/DelegatingAuthenticator.java
index 4cb9b6b..4650a9d 100644
--- a/interceptors/authn/src/main/java/org/apache/directory/server/core/authn/DelegatingAuthenticator.java
+++ b/interceptors/authn/src/main/java/org/apache/directory/server/core/authn/DelegatingAuthenticator.java
@@ -311,7 +311,6 @@
}
return principal;
-
}
catch ( LdapException e )
{
diff --git a/interceptors/authz/src/main/java/org/apache/directory/server/core/authz/AciAuthorizationInterceptor.java b/interceptors/authz/src/main/java/org/apache/directory/server/core/authz/AciAuthorizationInterceptor.java
index 344453b..a20d588 100644
--- a/interceptors/authz/src/main/java/org/apache/directory/server/core/authz/AciAuthorizationInterceptor.java
+++ b/interceptors/authz/src/main/java/org/apache/directory/server/core/authz/AciAuthorizationInterceptor.java
@@ -1181,7 +1181,7 @@
public void rename( RenameOperationContext renameContext ) throws LdapException
{
Dn oldName = renameContext.getDn();
- Entry originalEntry = null;
+ Entry originalEntry = renameContext.getOriginalEntry();
if ( renameContext.getEntry() != null )
{
@@ -1337,7 +1337,7 @@
}
- public void cacheNewGroup( String name, Entry entry ) throws Exception
+ public void cacheNewGroup( String name, Entry entry ) throws LdapException
{
groupCache.groupAdded( name, entry );
}
diff --git a/interceptors/authz/src/main/java/org/apache/directory/server/core/authz/DefaultAuthorizationInterceptor.java b/interceptors/authz/src/main/java/org/apache/directory/server/core/authz/DefaultAuthorizationInterceptor.java
index 0f133f1..9adde87 100644
--- a/interceptors/authz/src/main/java/org/apache/directory/server/core/authz/DefaultAuthorizationInterceptor.java
+++ b/interceptors/authz/src/main/java/org/apache/directory/server/core/authz/DefaultAuthorizationInterceptor.java
@@ -120,6 +120,10 @@
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
public void init( DirectoryService directoryService ) throws LdapException
{
super.init( directoryService );
@@ -182,6 +186,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void delete( DeleteOperationContext deleteContext ) throws LdapException
{
if ( deleteContext.getSession().getDirectoryService().isAccessControlEnabled() )
@@ -246,6 +251,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public Entry lookup( LookupOperationContext lookupContext ) throws LdapException
{
CoreSession session = lookupContext.getSession();
@@ -274,6 +280,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void modify( ModifyOperationContext modifyContext ) throws LdapException
{
if ( !modifyContext.getSession().getDirectoryService().isAccessControlEnabled() )
@@ -299,6 +306,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void move( MoveOperationContext moveContext ) throws LdapException
{
if ( !moveContext.getSession().getDirectoryService().isAccessControlEnabled() )
@@ -313,6 +321,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void moveAndRename( MoveAndRenameOperationContext moveAndRenameContext ) throws LdapException
{
if ( !moveAndRenameContext.getSession().getDirectoryService().isAccessControlEnabled() )
@@ -335,6 +344,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public void rename( RenameOperationContext renameContext ) throws LdapException
{
if ( !renameContext.getSession().getDirectoryService().isAccessControlEnabled() )
@@ -349,6 +359,7 @@
/**
* {@inheritDoc}
*/
+ @Override
public EntryFilteringCursor search( SearchOperationContext searchContext ) throws LdapException
{
EntryFilteringCursor cursor = next( searchContext );
@@ -530,7 +541,6 @@
// False positive, we want to keep the comment
- @SuppressWarnings("PMD.CollapsibleIfStatements")
private boolean isSearchable( OperationContext opContext, Entry entry ) throws LdapException
{
Dn principalDn = opContext.getSession().getEffectivePrincipal().getDn();
diff --git a/interceptors/authz/src/main/java/org/apache/directory/server/core/authz/GroupCache.java b/interceptors/authz/src/main/java/org/apache/directory/server/core/authz/GroupCache.java
index 615f82a..1564c72 100644
--- a/interceptors/authz/src/main/java/org/apache/directory/server/core/authz/GroupCache.java
+++ b/interceptors/authz/src/main/java/org/apache/directory/server/core/authz/GroupCache.java
@@ -212,7 +212,7 @@
* @param entry the entry inspected for member attributes
* @return the member attribute
*/
- private Attribute getMemberAttribute( Entry entry ) throws LdapException
+ private Attribute getMemberAttribute( Entry entry )
{
Attribute member = entry.get( directoryService.getAtProvider().getMember() );
@@ -255,6 +255,7 @@
catch ( LdapException e )
{
LOG.warn( "Malformed member Dn in groupOf[Unique]Names entry. Member not added to GroupCache.", e );
+ continue;
}
memberSet.add( memberDn.getNormName() );
@@ -284,6 +285,7 @@
catch ( LdapException e )
{
LOG.warn( "Malformed member Dn in groupOf[Unique]Names entry. Member not removed from GroupCache.", e );
+ continue;
}
memberSet.remove( memberDn.getNormName() );
diff --git a/interceptors/authz/src/main/java/org/apache/directory/server/core/authz/TupleCache.java b/interceptors/authz/src/main/java/org/apache/directory/server/core/authz/TupleCache.java
index 5aa7f5a..d38cc49 100644
--- a/interceptors/authz/src/main/java/org/apache/directory/server/core/authz/TupleCache.java
+++ b/interceptors/authz/src/main/java/org/apache/directory/server/core/authz/TupleCache.java
@@ -154,8 +154,7 @@
if ( aci == null )
{
- LOG.warn( "Found accessControlSubentry '" + subentryDn + "' without any "
- + SchemaConstants.PRESCRIPTIVE_ACI_AT );
+ LOG.warn( "Found accessControlSubentry '{}' without any {}", subentryDn, SchemaConstants.PRESCRIPTIVE_ACI_AT );
continue;
}
@@ -246,7 +245,7 @@
return;
}
- tuples.remove( dn.getNormName().toString() );
+ tuples.remove( dn.getNormName() );
}
@@ -283,14 +282,13 @@
}
- @SuppressWarnings("unchecked")
public List<ACITuple> getACITuples( String subentryDn )
{
List<ACITuple> aciTuples = tuples.get( subentryDn );
if ( aciTuples == null )
{
- return Collections.EMPTY_LIST;
+ return Collections.emptyList();
}
return Collections.unmodifiableList( aciTuples );
diff --git a/interceptors/authz/src/main/java/org/apache/directory/server/core/authz/support/MaxValueCountFilter.java b/interceptors/authz/src/main/java/org/apache/directory/server/core/authz/support/MaxValueCountFilter.java
index 161b577..a873325 100644
--- a/interceptors/authz/src/main/java/org/apache/directory/server/core/authz/support/MaxValueCountFilter.java
+++ b/interceptors/authz/src/main/java/org/apache/directory/server/core/authz/support/MaxValueCountFilter.java
@@ -89,7 +89,6 @@
private boolean isRemovable( MaxValueCountItem mvc, AttributeType attributeType, Entry entryView )
- throws LdapException
{
for ( Iterator<MaxValueCountElem> k = mvc.iterator(); k.hasNext(); )
{
diff --git a/interceptors/authz/src/main/java/org/apache/directory/server/core/authz/support/RelatedProtectedItemFilter.java b/interceptors/authz/src/main/java/org/apache/directory/server/core/authz/support/RelatedProtectedItemFilter.java
index dac6e8c..49f0d73 100644
--- a/interceptors/authz/src/main/java/org/apache/directory/server/core/authz/support/RelatedProtectedItemFilter.java
+++ b/interceptors/authz/src/main/java/org/apache/directory/server/core/authz/support/RelatedProtectedItemFilter.java
@@ -119,16 +119,8 @@
return true;
}
- else if ( item == ProtectedItem.ALL_USER_ATTRIBUTE_TYPES )
- {
- if ( scope != OperationScope.ATTRIBUTE_TYPE && scope != OperationScope.ATTRIBUTE_TYPE_AND_VALUE )
- {
- continue;
- }
-
- return true;
- }
- else if ( item == ProtectedItem.ALL_USER_ATTRIBUTE_TYPES_AND_VALUES )
+ else if ( ( item == ProtectedItem.ALL_USER_ATTRIBUTE_TYPES )
+ || ( item == ProtectedItem.ALL_USER_ATTRIBUTE_TYPES_AND_VALUES ) )
{
if ( scope != OperationScope.ATTRIBUTE_TYPE && scope != OperationScope.ATTRIBUTE_TYPE_AND_VALUE )
{
diff --git a/interceptors/authz/src/main/java/org/apache/directory/server/core/authz/support/RestrictedByFilter.java b/interceptors/authz/src/main/java/org/apache/directory/server/core/authz/support/RestrictedByFilter.java
index b9cfbab..41f729a 100644
--- a/interceptors/authz/src/main/java/org/apache/directory/server/core/authz/support/RestrictedByFilter.java
+++ b/interceptors/authz/src/main/java/org/apache/directory/server/core/authz/support/RestrictedByFilter.java
@@ -75,7 +75,6 @@
public boolean isRemovable( ACITuple tuple, AttributeType attributeType, Value attrValue, Entry entry )
- throws LdapException
{
for ( ProtectedItem item : tuple.getProtectedItems() )
{
diff --git a/interceptors/changelog/src/main/java/org/apache/directory/server/core/changelog/MemoryChangeLogStore.java b/interceptors/changelog/src/main/java/org/apache/directory/server/core/changelog/MemoryChangeLogStore.java
index 5975189..5fe0307 100644
--- a/interceptors/changelog/src/main/java/org/apache/directory/server/core/changelog/MemoryChangeLogStore.java
+++ b/interceptors/changelog/src/main/java/org/apache/directory/server/core/changelog/MemoryChangeLogStore.java
@@ -154,39 +154,17 @@
// This will suppress PMD.EmptyCatchBlock warnings in this method
- @SuppressWarnings("PMD.EmptyCatchBlock")
private void loadRevision() throws IOException
{
File revFile = new File( workingDirectory, REV_FILE );
if ( revFile.exists() )
{
- BufferedReader reader = null;
-
- try
+ try ( BufferedReader reader = new BufferedReader( new FileReader( revFile ) ) )
{
- reader = new BufferedReader( new FileReader( revFile ) );
String line = reader.readLine();
currentRevision = Long.valueOf( line );
}
- catch ( IOException e )
- {
- throw e;
- }
- finally
- {
- if ( reader != null )
- {
- //noinspection EmptyCatchBlock
- try
- {
- reader.close();
- }
- catch ( IOException e )
- {
- }
- }
- }
}
}
@@ -205,15 +183,10 @@
out.println( currentRevision );
out.flush();
}
- catch ( IOException e )
- {
- throw e;
- }
}
// This will suppress PMD.EmptyCatchBlock warnings in this method
- @SuppressWarnings("PMD.EmptyCatchBlock")
private void saveTags() throws IOException
{
File tagFile = new File( workingDirectory, TAG_FILE );
@@ -248,29 +221,17 @@
props.store( out, null );
out.flush();
}
- catch ( IOException e )
- {
- throw e;
- }
finally
{
if ( out != null )
{
- //noinspection EmptyCatchBlock
- try
- {
- out.close();
- }
- catch ( IOException e )
- {
- }
+ out.close();
}
}
}
// This will suppress PMD.EmptyCatchBlock warnings in this method
- @SuppressWarnings("PMD.EmptyCatchBlock")
private void loadTags() throws IOException
{
File revFile = new File( workingDirectory, REV_FILE );
@@ -316,22 +277,11 @@
latest = tag;
}
- catch ( IOException e )
- {
- throw e;
- }
finally
{
if ( in != null )
{
- //noinspection EmptyCatchBlock
- try
- {
- in.close();
- }
- catch ( IOException e )
- {
- }
+ in.close();
}
}
}
@@ -339,18 +289,14 @@
// This will suppress PMD.EmptyCatchBlock warnings in this method
- @SuppressWarnings("PMD.EmptyCatchBlock")
- private void loadChangeLog() throws IOException, LdapException
+ private void loadChangeLog() throws IOException
{
File file = new File( workingDirectory, CHANGELOG_FILE );
if ( file.exists() )
{
- ObjectInputStream in = null;
-
- try
+ try ( ObjectInputStream in = new ObjectInputStream( Files.newInputStream( file.toPath() ) ) )
{
- in = new ObjectInputStream( Files.newInputStream( file.toPath() ) );
int size = in.readInt();
ArrayList<ChangeLogEvent> changeLogEvents = new ArrayList<>( size );
@@ -367,30 +313,11 @@
this.events.clear();
this.events.addAll( changeLogEvents );
}
- catch ( Exception e )
- {
- throw e;
- }
- finally
- {
- if ( in != null )
- {
- //noinspection EmptyCatchBlock
- try
- {
- in.close();
- }
- catch ( IOException e )
- {
- }
- }
- }
}
}
// This will suppress PMD.EmptyCatchBlock warnings in this method
- @SuppressWarnings("PMD.EmptyCatchBlock")
private void saveChangeLog() throws IOException
{
File file = new File( workingDirectory, CHANGELOG_FILE );
@@ -400,21 +327,10 @@
throw new IOException( I18n.err( I18n.ERR_726_FILE_UNDELETABLE, file.getAbsolutePath() ) );
}
- try
- {
- file.createNewFile();
- }
- catch ( IOException e )
- {
- throw e;
- }
+ file.createNewFile();
- ObjectOutputStream out = null;
-
- try
+ try ( ObjectOutputStream out = new ObjectOutputStream( Files.newOutputStream( file.toPath() ) ) )
{
- out = new ObjectOutputStream( Files.newOutputStream( file.toPath() ) );
-
out.writeInt( events.size() );
for ( ChangeLogEvent event : events )
@@ -424,24 +340,6 @@
out.flush();
}
- catch ( Exception e )
- {
- throw e;
- }
- finally
- {
- if ( out != null )
- {
- //noinspection EmptyCatchBlock
- try
- {
- out.close();
- }
- catch ( IOException e )
- {
- }
- }
- }
}
@@ -631,19 +529,16 @@
sb.append( "MemoryChangeLog\n" );
sb.append( "latest tag : " ).append( latest ).append( '\n' );
- if ( events != null )
+ sb.append( "Nb of events : " ).append( events.size() ).append( '\n' );
+
+ int i = 0;
+
+ for ( ChangeLogEvent event : events )
{
- sb.append( "Nb of events : " ).append( events.size() ).append( '\n' );
-
- int i = 0;
-
- for ( ChangeLogEvent event : events )
- {
- sb.append( "event[" ).append( i++ ).append( "] : " );
- sb.append( "\n---------------------------------------\n" );
- sb.append( event );
- sb.append( "\n---------------------------------------\n" );
- }
+ sb.append( "event[" ).append( i++ ).append( "] : " );
+ sb.append( "\n---------------------------------------\n" );
+ sb.append( event );
+ sb.append( "\n---------------------------------------\n" );
}
return sb.toString();
diff --git a/interceptors/collective/src/main/java/org/apache/directory/server/core/collective/CollectiveAttributeInterceptor.java b/interceptors/collective/src/main/java/org/apache/directory/server/core/collective/CollectiveAttributeInterceptor.java
index 49daba6..e1f5b1a 100644
--- a/interceptors/collective/src/main/java/org/apache/directory/server/core/collective/CollectiveAttributeInterceptor.java
+++ b/interceptors/collective/src/main/java/org/apache/directory/server/core/collective/CollectiveAttributeInterceptor.java
@@ -306,7 +306,7 @@
/**
* Check if the entry contains any collective AttributeType (those starting with 'c-')
*/
- private boolean containsAnyCollectiveAttributes( Entry entry ) throws LdapException
+ private boolean containsAnyCollectiveAttributes( Entry entry )
{
for ( Attribute attribute : entry.getAttributes() )
{
@@ -350,7 +350,10 @@
return;
}
- LOG.debug( "Filtering entry " + entry.getDn() );
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( "Filtering entry {}", entry.getDn() );
+ }
/*
* Before we proceed we need to lookup the exclusions within the entry
diff --git a/interceptors/event/src/main/java/org/apache/directory/server/core/event/EventInterceptor.java b/interceptors/event/src/main/java/org/apache/directory/server/core/event/EventInterceptor.java
index e9a8276..6a47e08 100644
--- a/interceptors/event/src/main/java/org/apache/directory/server/core/event/EventInterceptor.java
+++ b/interceptors/event/src/main/java/org/apache/directory/server/core/event/EventInterceptor.java
@@ -449,21 +449,11 @@
SearchScope scope = criteria.getScope();
- boolean inscope = false;
-
// fix for DIRSERVER-1502
- if ( ( scope == OBJECT ) && name.equals( base ) )
- {
- inscope = true;
- }
- else if ( ( scope == ONELEVEL ) && name.getParent().equals( base ) )
- {
- inscope = true;
- }
- else if ( ( scope == SUBTREE ) && ( name.isDescendantOf( base ) || name.equals( base ) ) )
- {
- inscope = true;
- }
+ boolean inscope =
+ ( ( ( scope == OBJECT ) && name.equals( base ) )
+ || ( ( scope == ONELEVEL ) && name.getParent().equals( base ) )
+ || ( ( scope == SUBTREE ) && ( name.isDescendantOf( base ) || name.equals( base ) ) ) );
if ( inscope && evaluator.evaluate( criteria.getFilter(), base, entry ) )
{
diff --git a/interceptors/exception/src/main/java/org/apache/directory/server/core/exception/ExceptionInterceptor.java b/interceptors/exception/src/main/java/org/apache/directory/server/core/exception/ExceptionInterceptor.java
index c779483..08a97f7 100644
--- a/interceptors/exception/src/main/java/org/apache/directory/server/core/exception/ExceptionInterceptor.java
+++ b/interceptors/exception/src/main/java/org/apache/directory/server/core/exception/ExceptionInterceptor.java
@@ -111,12 +111,6 @@
}
- @Override
- public void destroy()
- {
- }
-
-
/**
* In the pre-invocation state this interceptor method checks to see if the entry to be added already exists. If it
* does an exception is raised.
@@ -168,9 +162,7 @@
}
catch ( Exception e )
{
- LdapNoSuchObjectException e2 = new LdapNoSuchObjectException(
- I18n.err( I18n.ERR_251_PARENT_NOT_FOUND, parentDn.getName() ) );
- throw e2;
+ throw new LdapNoSuchObjectException( I18n.err( I18n.ERR_251_PARENT_NOT_FOUND, parentDn.getName() ) );
}
Attribute objectClass = ( ( ClonedServerEntry ) attrs ).getOriginalEntry().get(
@@ -179,9 +171,7 @@
if ( objectClass.contains( SchemaConstants.ALIAS_OC ) )
{
String msg = I18n.err( I18n.ERR_252_ALIAS_WITH_CHILD_NOT_ALLOWED, name.getName(), parentDn.getName() );
- LdapAliasException e = new LdapAliasException( msg );
- //e.setResolvedName( DNFactory.create( parentDn.getName() ) );
- throw e;
+ throw new LdapAliasException( msg );
}
else
{
@@ -345,10 +335,7 @@
// we want to allow this.
if ( !newDn.equals( dn ) )
{
- LdapEntryAlreadyExistsException e;
- e = new LdapEntryAlreadyExistsException( I18n.err( I18n.ERR_250_ENTRY_ALREADY_EXISTS, newDn.getName() ) );
- //e.setResolvedName( DNFactory.create( newDn.getName() ) );
- throw e;
+ throw new LdapEntryAlreadyExistsException( I18n.err( I18n.ERR_250_ENTRY_ALREADY_EXISTS, newDn.getName() ) );
}
}
diff --git a/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/request/SearchRequestHandler.java b/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/request/SearchRequestHandler.java
index 00a8761..2841149 100644
--- a/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/request/SearchRequestHandler.java
+++ b/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/request/SearchRequestHandler.java
@@ -1729,7 +1729,6 @@
* @return the farthest referral ancestor or null
*/
// This will suppress PMD.EmptyCatchBlock warnings in this method
- @SuppressWarnings("PMD.EmptyCatchBlock")
public static final Entry getFarthestReferralAncestor( LdapSession session, Dn target )
{
Entry entry;