Buggy code:
@ Component ( label = "%email.service.name" , description = "%email.service.description" , immediate = true , metatype = true ) @ Service ( EmailService . class ) @ Properties ( { @ Property ( name = EmailServiceImpl . PARAM_NODE_TYPE , label = "%nodeType.label" , description = "%nodeType.description" , value = { EmailServiceImpl . DEFAULT_NODE_TYPE } ) , @ Property ( name = EmailServiceImpl . PARAM_PROPERTY_NAME , label = "%propertyName.label" , description = "%propertyName.description" , value = EmailServiceImpl . DEFAULT_PROPERTY_NAME ) , @ Property ( name = EmailServiceImpl . PARAM_SPOOL_FOLDER , label = "%spoolFolder.name" , description = "%spoolFolder.description" , value = EmailServiceImpl . DEFAULT_SPOOL_FOLDER ) } ) public class EmailServiceImpl implements EmailService { private final Logger log = LoggerFactory . getLogger ( EmailServiceImpl . class ) ; public static final String PARAM_SPOOL_FOLDER = EmailSendJobEventHandler . PARAM_SPOOL_FOLDER ; public static final String DEFAULT_SPOOL_FOLDER = EmailSendJobEventHandler . DEFAULT_SPOOL_FOLDER ; public static final String PARAM_NODE_TYPE = EmailResourceChangeListener . PARAM_NODE_TYPE ; public static final String DEFAULT_NODE_TYPE = EmailResourceChangeListener . NODE_TYPE_EMAIL ; public static final String PARAM_PROPERTY_NAME = EmailResourceChangeListener . PARAM_PROPERTY_NAME ; public static final String DEFAULT_PROPERTY_NAME = EmailResourceChangeListener . PROPERTY_NAME ; private String nodeType = EmailServiceImpl . DEFAULT_NODE_TYPE ; private String propertyName = EmailServiceImpl . DEFAULT_PROPERTY_NAME ; private String spoolFolder = EmailServiceImpl . DEFAULT_SPOOL_FOLDER ; @ Reference private Configurator configurator ; @ Reference private SlingRepository repository ; @ Reference ResourceResolverFactory resourceResolverFactory ; protected SlingRepository getRepository ( ) { } private Configuration templateConfig ; @ Activate protected void activate ( ComponentContext componentContext ) throws RepositoryException { Dictionary < ? , ? > props = componentContext . getProperties ( ) ; nodeType = OsgiUtil . toString ( props . get ( EmailServiceImpl . PARAM_NODE_TYPE ) , EmailServiceImpl . DEFAULT_NODE_TYPE ) ; propertyName = OsgiUtil . toString ( props . get ( EmailServiceImpl . DEFAULT_PROPERTY_NAME ) , EmailServiceImpl . DEFAULT_PROPERTY_NAME ) ; spoolFolder = OsgiUtil . toString ( props . get ( EmailServiceImpl . PARAM_SPOOL_FOLDER ) , EmailServiceImpl . DEFAULT_SPOOL_FOLDER ) ; if ( spoolFolder . startsWith ( "//" ) ) spoolFolder = spoolFolder . substring ( 1 ) ; if ( spoolFolder . endsWith ( "//" ) ) <START_BUG> spoolFolder = spoolFolder . substring ( 0 , ( ( spoolFolder . length ( ) ) - 2 ) ) ; <END_BUG> Session admin = repository . loginAdministrative ( null ) ; String [ ] spoolFolders = spoolFolder . split ( "//" ) ; Node n = admin . getRootNode ( ) ; for ( int i = 0 ; i < ( spoolFolders . length ) ; i ++ ) { if ( ! ( n . hasNode ( spoolFolders [ i ] ) ) ) { n = n . addNode ( spoolFolders [ i ] ) ; } else { n = n . getNode ( spoolFolders [ i ] ) ; } } admin . save ( ) ; admin . logout ( ) ; templateConfig = new Configuration ( ) ; } @ Deactivate public void deactivate ( ComponentContext componentContext ) throws RepositoryException { } public void sendEmail ( String resourceUrl , String templateUrl ) throws Exception { } public void sendEmail ( Session session , String resourceUrl , String templateUrl ) throws Exception { } public void sendEmail ( String resourceUrl , String templateUrl , HashMap < String , Object > variables ) throws Exception { } public void sendEmail ( Session session , String resourceUrl , String templateUrl , HashMap < String , Object > variables ) throws Exception { } }

Fix:
spoolFolder = spoolFolder . substring ( 0 , ( ( spoolFolder . length ( ) ) - 1 ) ) ;