Buggy code:
@ RequiresAuthentication @ Api ( value = "AlertReceivers" , description = "Manage<seq2seq4repair_space>stream<seq2seq4repair_space>alert<seq2seq4repair_space>receivers" ) @ Path ( "//streams//{streamId}//alerts" ) public class StreamAlertReceiverResource extends RestResource { private static final Logger LOG = LoggerFactory . getLogger ( StreamAlertReceiverResource . class ) ; private final StreamService streamService ; private final AlarmCallbackConfigurationService alarmCallbackConfigurationService ; private final EmailAlarmCallback emailAlarmCallback ; private final AlarmCallbackFactory alarmCallbackFactory ; @ Inject public StreamAlertReceiverResource ( StreamService streamService , AlarmCallbackConfigurationService alarmCallbackConfigurationService , EmailAlarmCallback emailAlarmCallback , AlarmCallbackFactory alarmCallbackFactory ) { } @ POST @ Timed @ Path ( "receivers" ) @ ApiOperation ( "Add<seq2seq4repair_space>an<seq2seq4repair_space>alert<seq2seq4repair_space>receiver" ) @ ApiResponses ( { @ ApiResponse ( code = 404 , message = "Stream<seq2seq4repair_space>not<seq2seq4repair_space>found." ) , @ ApiResponse ( code = 400 , message = "Invalid<seq2seq4repair_space>ObjectId." ) } ) public Response addReceiver ( @ ApiParam ( name = "streamId" , value = "The<seq2seq4repair_space>stream<seq2seq4repair_space>id<seq2seq4repair_space>this<seq2seq4repair_space>new<seq2seq4repair_space>alert<seq2seq4repair_space>condition<seq2seq4repair_space>belongs<seq2seq4repair_space>to." , required = true ) @ PathParam ( "streamId" ) String streamid , @ ApiParam ( name = "entity" , value = "Name//ID<seq2seq4repair_space>of<seq2seq4repair_space>user<seq2seq4repair_space>or<seq2seq4repair_space>email<seq2seq4repair_space>address<seq2seq4repair_space>to<seq2seq4repair_space>add<seq2seq4repair_space>as<seq2seq4repair_space>alert<seq2seq4repair_space>receiver." , required = true ) @ QueryParam ( "entity" ) String entity , @ ApiParam ( name = "type" , value = "Type:<seq2seq4repair_space>users<seq2seq4repair_space>or<seq2seq4repair_space>emails" , required = true ) @ QueryParam ( "type" ) String type ) throws NotFoundException { checkPermission ( STREAMS_EDIT , streamid ) ; if ( ( type == null ) || ( ( ! ( type . equals ( "users" ) ) ) && ( ! ( type . equals ( "emails" ) ) ) ) ) { StreamAlertReceiverResource . LOG . warn ( "No<seq2seq4repair_space>such<seq2seq4repair_space>type:<seq2seq4repair_space>[{}]" , type ) ; throw new BadRequestException ( ) ; } final Stream stream = streamService . load ( streamid ) ; <START_BUG> final URI streamAlertUri = UriBuilder . fromResource ( StreamAlertResource . class ) . build ( ) ; <END_BUG> if ( ( stream . getAlertReceivers ( ) . containsKey ( type ) ) || ( ( stream . getAlertReceivers ( ) . get ( type ) ) != null ) ) { if ( stream . getAlertReceivers ( ) . get ( type ) . contains ( entity ) ) { return Response . created ( streamAlertUri ) . build ( ) ; } } streamService . addAlertReceiver ( stream , type , entity ) ; return Response . created ( streamAlertUri ) . build ( ) ; } @ DELETE @ Timed @ Path ( "receivers" ) @ ApiOperation ( "Remove<seq2seq4repair_space>an<seq2seq4repair_space>alert<seq2seq4repair_space>receiver" ) @ ApiResponses ( { @ ApiResponse ( code = 404 , message = "Stream<seq2seq4repair_space>not<seq2seq4repair_space>found." ) , @ ApiResponse ( code = 400 , message = "Invalid<seq2seq4repair_space>ObjectId." ) } ) public void removeReceiver ( @ ApiParam ( name = "streamId" , value = "The<seq2seq4repair_space>stream<seq2seq4repair_space>id<seq2seq4repair_space>this<seq2seq4repair_space>new<seq2seq4repair_space>alert<seq2seq4repair_space>condition<seq2seq4repair_space>belongs<seq2seq4repair_space>to." , required = true ) @ PathParam ( "streamId" ) String streamid , @ ApiParam ( name = "entity" , value = "Name//ID<seq2seq4repair_space>of<seq2seq4repair_space>user<seq2seq4repair_space>or<seq2seq4repair_space>email<seq2seq4repair_space>address<seq2seq4repair_space>to<seq2seq4repair_space>remove<seq2seq4repair_space>from<seq2seq4repair_space>alert<seq2seq4repair_space>receivers." , required = true ) @ QueryParam ( "entity" ) String entity , @ ApiParam ( name = "type" , value = "Type:<seq2seq4repair_space>users<seq2seq4repair_space>or<seq2seq4repair_space>emails" , required = true ) @ QueryParam ( "type" ) String type ) throws NotFoundException { } @ GET @ Timed @ Path ( "sendDummyAlert" ) @ ApiOperation ( "Send<seq2seq4repair_space>a<seq2seq4repair_space>test<seq2seq4repair_space>mail<seq2seq4repair_space>for<seq2seq4repair_space>a<seq2seq4repair_space>given<seq2seq4repair_space>stream" ) @ ApiResponses ( { @ ApiResponse ( code = 404 , message = "Stream<seq2seq4repair_space>not<seq2seq4repair_space>found." ) , @ ApiResponse ( code = 400 , message = "Invalid<seq2seq4repair_space>ObjectId." ) } ) public Response sendDummyAlert ( @ ApiParam ( name = "streamId" , value = "The<seq2seq4repair_space>stream<seq2seq4repair_space>id<seq2seq4repair_space>this<seq2seq4repair_space>new<seq2seq4repair_space>alert<seq2seq4repair_space>condition<seq2seq4repair_space>belongs<seq2seq4repair_space>to." , required = true ) @ PathParam ( "streamId" ) String streamid ) throws EmailException , NotFoundException , TransportConfigurationException { } }

Fix:
final URI streamAlertUri = UriBuilder . fromResource ( StreamAlertResource . class ) . build ( streamid ) ;