Buggy code:
public class FilesAPIImpl implements FilesAPI { private static final org . apache . commons . logging . Log Log = LogFactory . getLog ( FilesAPIImpl . class ) ; protected RegistryExtension _registryExtension ; protected RegistryUtils _registryUtils ; protected RegistryExtensionConfig _config ; @ Resource public void setServletContext ( ServletContext context ) { } @ OPTIONS @ Path ( "{path:.*}" ) @ Produces ( { HTRCMediaTypes . ENTRY_XML , HTRCMediaTypes . ENTRY_JSON , MediaType . APPLICATION_XML , MediaType . APPLICATION_JSON } ) public Response listContents ( @ Context HttpServletRequest request , @ Context UriInfo uriInfo , @ PathParam ( "path" ) String path , @ DefaultValue ( "false" ) @ QueryParam ( "recursive" ) boolean recursive , @ DefaultValue ( ".*" ) @ QueryParam ( "name" ) String nameFilterRegexp , @ DefaultValue ( ".*" ) @ QueryParam ( "type" ) String typeFilterRegexp , @ DefaultValue ( "false" ) @ QueryParam ( "public" ) boolean listPublic ) { } @ HEAD @ Path ( "{path:.*}" ) public Response checkIfExists ( @ Context HttpServletRequest request , @ PathParam ( "path" ) String path , @ DefaultValue ( "false" ) @ QueryParam ( "public" ) boolean checkPublic ) { } @ GET @ Path ( "{path:.*}" ) public Response getFileOrFolder ( @ Context HttpServletRequest request , @ PathParam ( "path" ) String path , @ DefaultValue ( ".*" ) @ QueryParam ( "name" ) String nameFilterRegexp , @ DefaultValue ( ".*" ) @ QueryParam ( "type" ) String typeFilterRegexp , @ DefaultValue ( "false" ) @ QueryParam ( "public" ) boolean getPublic ) { String userName = request . getRemoteUser ( ) ; if ( userName != null ) { userName = MultitenantUtils . getTenantAwareUsername ( userName ) ; } if ( ! ( path . startsWith ( "//" ) ) ) path = "//" + path ; FilesAPIImpl . Log . debug ( String . format ( "getFileOrFolder:<seq2seq4repair_space>path=%s,<seq2seq4repair_space>nameFilter=%s,<seq2seq4repair_space>typeFilter=%s,<seq2seq4repair_space>public=%s,<seq2seq4repair_space>user=%s" , path , nameFilterRegexp , typeFilterRegexp , getPublic , userName ) ) ; if ( userName == null ) return Response . status ( UNAUTHORIZED ) . entity ( "Not<seq2seq4repair_space>authenticated" ) . type ( TEXT_PLAIN ) . build ( ) ; String filesPath = ( getPublic ) ? _config . getPublicFilesPath ( ) : _config . getUserFilesPath ( userName ) ; String resPath = filesPath + path ; try { Pattern fileNamePattern = Pattern . compile ( nameFilterRegexp ) ; Pattern mediaTypePattern = Pattern . compile ( typeFilterRegexp ) ; UserRegistry registry = _registryUtils . getUserRegistry ( userName ) ; if ( ! ( registry . resourceExists ( resPath ) ) ) return Response . status ( NOT_FOUND ) . build ( ) ; org . wso2 . carbon . registry . core . Resource resource = registry . get ( resPath ) ; String mediaType = resource . getMediaType ( ) ; if ( resource instanceof Collection ) { Collection collection = ( ( Collection ) ( resource ) ) ; List < Attachment > attachments = new ArrayList < Attachment > ( ) ; for ( String child : collection . getChildren ( ) ) { try { resource = registry . get ( child ) ; } catch ( AuthorizationFailedException afe ) { <START_BUG> FilesAPIImpl . Log . warn ( ( "getFileOrFolder:<seq2seq4repair_space>Registry<seq2seq4repair_space>authorization<seq2seq4repair_space>failure.<seq2seq4repair_space>This<seq2seq4repair_space>should<seq2seq4repair_space>not<seq2seq4repair_space>happen." + "<seq2seq4repair_space>But<seq2seq4repair_space>latest<seq2seq4repair_space>version<seq2seq4repair_space>of<seq2seq4repair_space>getChildren<seq2seq4repair_space>returns<seq2seq4repair_space>private<seq2seq4repair_space>resources<seq2seq4repair_space>too." ) ) ; <END_BUG> continue ; } if ( resource instanceof Collection ) continue ; String attachmentName = child . substring ( ( ( child . lastIndexOf ( "//" ) ) + 1 ) ) ; String attachmentType = resource . getMediaType ( ) ; if ( FileUtils . filterMatches ( attachmentName , attachmentType , fileNamePattern , mediaTypePattern ) ) { try { InputStream contentStream = resource . getContentStream ( ) ; Attachment attachment = new Attachment ( attachmentName , attachmentType , contentStream ) ; attachments . add ( attachment ) ; } catch ( RegistryException e ) { FilesAPIImpl . Log . warn ( ( ( ( "getContentStream:<seq2seq4repair_space>" + ( e . getMessage ( ) ) ) + "<seq2seq4repair_space>-<seq2seq4repair_space>" ) + child ) ) ; continue ; } } } if ( ! ( attachments . isEmpty ( ) ) ) { MultipartBody multipartBody = new MultipartBody ( attachments , true ) ; return Response . ok ( multipartBody ) . type ( "multipart//mixed" ) . build ( ) ; } else return Response . noContent ( ) . build ( ) ; } return Response . ok ( resource . getContentStream ( ) , mediaType ) . build ( ) ; } catch ( PatternSyntaxException e ) { return Response . status ( BAD_REQUEST ) . entity ( ( "Regexp<seq2seq4repair_space>syntax<seq2seq4repair_space>error:<seq2seq4repair_space>" + ( e . getMessage ( ) ) ) ) . type ( TEXT_PLAIN ) . build ( ) ; } catch ( Exception e ) { FilesAPIImpl . Log . error ( "getFileOrFolder" , e ) ; String errorMsg = String . format ( "Cannot<seq2seq4repair_space>retrieve<seq2seq4repair_space>entry:<seq2seq4repair_space>%s\n%s" , path , e . toString ( ) ) ; return Response . serverError ( ) . entity ( errorMsg ) . type ( TEXT_PLAIN ) . build ( ) ; } } @ POST @ Path ( "{path:.*}" ) @ Consumes ( MediaType . MULTIPART_FORM_DATA ) public Response uploadToFolder ( @ Context HttpServletRequest request , @ PathParam ( "path" ) String path , @ DefaultValue ( "false" ) @ QueryParam ( "public" ) boolean isPublic , @ QueryParam ( "user" ) String user , List < Attachment > attachments ) { } @ PUT @ Path ( "{path:.*}" ) public Response uploadFile ( @ Context HttpServletRequest request , @ HeaderParam ( "Content-Type" ) MediaType contentType , @ PathParam ( "path" ) String path , @ DefaultValue ( "false" ) @ QueryParam ( "public" ) boolean isPublic , @ QueryParam ( "user" ) String user , InputStream fileStream ) { } @ DELETE @ Path ( "{path:.*}" ) public Response deleteFileOrFolder ( @ Context HttpServletRequest request , @ PathParam ( "path" ) String path , @ DefaultValue ( "false" ) @ QueryParam ( "public" ) boolean delPublic ) { } }

Fix:
FilesAPIImpl . Log . warn ( ( "getFileOrFolder:<seq2seq4repair_space>Registry<seq2seq4repair_space>authorization<seq2seq4repair_space>failure.<seq2seq4repair_space>This<seq2seq4repair_space>should<seq2seq4repair_space>not<seq2seq4repair_space>happen." + "<seq2seq4repair_space>But<seq2seq4repair_space>latest<seq2seq4repair_space>Registry<seq2seq4repair_space>version's<seq2seq4repair_space>getChildren<seq2seq4repair_space>returns<seq2seq4repair_space>private<seq2seq4repair_space>resources." ) ) ;